:root {
    --bg-color: transparent;
    --chat-bg: transparent;
    --input-bg: #111111;
    /* Slightly lighter than pure black */
    --input-border: #333333;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --accent-color: #3b82f6;
    /* Blue like the screenshot */
    --hover-bg: #27272a;
    --chip-bg: #111111;
    --chip-border: #333333;
    --chip-hover: #27272a;
    --message-user-bg: #27272a;
    --message-bot-bg: transparent;
    --bg-surface: #09090b;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

.history-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    overflow: hidden;
    background-color: #050505;
    border-right: 1px solid var(--input-border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
    z-index: 30;
}

.app-container.history-open .history-sidebar {
    width: 280px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px 8px 12px;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.history-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-action-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text-secondary);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.history-action-btn:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.history-action-btn.danger {
    border-color: rgba(245, 108, 108, 0.5);
    color: #f56c6c;
}

.history-action-btn.danger:hover {
    background-color: rgba(245, 108, 108, 0.12);
    border-color: rgba(245, 108, 108, 0.8);
    color: #ffcccc;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    padding: 10px 10px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    border: 1px solid transparent;
    background: transparent;
    font-size: 13px;
    line-height: 1.35;
    user-select: none;
}

.history-item:hover {
    background-color: rgba(39, 39, 42, 0.7);
    color: var(--text-primary);
}

.history-item.active {
    background-color: transparent;
    color: var(--text-primary);
    border-color: transparent;
}

.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
    position: relative;
    height: 100%;
}

.chat-header {
    display: none;
    height: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
}

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible;
}

/* Messages Area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    display: none;
    /* Hidden initially, shown when chatting */
}

.messages-container.active {
    display: flex;
}

/* Welcome Screen & Input Area */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    box-sizing: border-box;
    transition: all 0.3s ease;
    position: relative;
}

.welcome-screen:not(.minimized) {
    transform: none;
}

.welcome-screen:not(.minimized) .welcome-main {
    position: absolute;
    left: 50%;
    top: 40%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 850px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.welcome-screen:not(.minimized) .welcome-modules {
    position: absolute;
    left: 50%;
    top: 33%;
    transform: translateX(-50%);
    margin-top: clamp(140px, 18vh, 240px);
    width: 100%;
    max-width: 850px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
}

.welcome-screen.minimized .welcome-main,
.welcome-screen.minimized .welcome-modules {
    position: static;
    transform: none;
    margin-top: 0;
    width: 100%;
    max-width: 850px;
}

.welcome-screen.minimized {
    justify-content: flex-end;
    flex: 0 0 auto;
    background: transparent;
    transform: none;
}

.main-title {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 40px;
    text-align: center;
    color: var(--text-primary);
}

.welcome-screen.minimized .main-title {
    display: none;
}

/* Input Area */
.input-area-wrapper {
    width: 100%;
    max-width: 818px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-container {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 24px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.input-container:focus-within {
    border-color: #555;
}

#chat-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    resize: none;
    width: 100%;
    outline: none;
    min-height: 24px;
    max-height: 200px;
    font-family: inherit;
    line-height: 1.5;
    padding: 8px 0;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.input-actions-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.input-actions-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.image-n-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 16px;
    background-color: transparent;
    color: var(--text-secondary);
}

.image-n-container:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.image-n-label {
    font-size: 13px;
    line-height: 1;
    user-select: none;
}

.image-n-input {
    width: 64px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 4px 8px;
    font-size: 13px;
    outline: none;
}

.image-n-input:focus {
    border-color: rgba(59, 130, 246, 0.55);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

/* Model Selector (Custom Dropdown) */
.model-selector-container {
    position: relative;
    display: inline-block;
}

.model-selector-btn {
    display: flex;
    align-items: center;
    background-color: transparent;
    border: none;
    border-radius: 16px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    gap: 8px;
    transition: background-color 0.15s linear, color 0.15s linear, border-color 0.15s linear;
    font-family: inherit;
}

.model-selector-btn:hover,
.model-selector-btn.active {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.model-icon-display {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.model-name-display {
    font-weight: 500;
}

.model-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    /* Show above the input area */
    left: 0;
    background-color: #09090b;
    border: 1px solid #333;
    border-radius: 12px;
    width: 280px;
    display: none;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    z-index: 99999;
    overflow: hidden;
    flex-direction: column;
}

.model-dropdown-header {
    padding: 10px 12px 10px 12px;
    border-bottom: 1px solid #27272a;
    background-color: #09090b;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
}

.provider-selector-container {
    position: relative;
    display: inline-block;
}

.provider-toggle-btn {
    padding: 6px 10px;
}

.provider-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    width: 220px;
    background-color: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
    padding: 8px;
    display: none;
    z-index: 99999;
}

.provider-dropdown-menu.active {
    display: block;
}

.provider-list-scroll {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px;
}

.provider-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    user-select: none;
}

.provider-item:hover {
    background: var(--hover-bg);
    border-color: rgba(255, 255, 255, 0.12);
}

.provider-item.selected {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.35);
}

.provider-item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.85;
}

.model-dropdown-menu.active {
    display: flex;
    animation: fadeInBottom 0.2s ease-out;
}

.size-selector-container {
    position: relative;
    display: inline-block;
}

.size-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background-color: #09090b;
    border: 1px solid #333;
    border-radius: 12px;
    width: 160px;
    display: none;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    z-index: 99999;
    overflow: hidden;
    flex-direction: column;
}

.size-dropdown-menu.active {
    display: flex;
    animation: fadeInBottom 0.2s ease-out;
}

.size-list-scroll {
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.size-item {
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    user-select: none;
}

.size-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.size-item.selected {
    background-color: rgba(59, 130, 246, 0.18);
    color: #cfe2ff;
}

@keyframes fadeInBottom {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.model-search-box {
    padding: 12px;
    border-bottom: 1px solid #27272a;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #09090b;
}

.model-search-box i {
    color: #71717a;
    font-size: 14px;
}

.model-search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    outline: none;
    font-family: inherit;
}

.model-list-scroll {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-gutter: stable;
}

.model-group-title {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #71717a;
    text-transform: capitalize;
    margin-top: 4px;
}

.model-group-title:first-child {
    margin-top: 0;
}

.model-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0);
    transition: background-color 0.15s linear;
    color: #e4e4e7;
    font-size: 14px;
    will-change: background-color;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.model-item:hover {
    background-color: #27272a;
}

.model-item.selected {
    background-color: #1d4ed8;
    /* Blue selected state */
    color: white;
}

.model-item-icon {
    width: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Send Button */
.send-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #3f3f46;
    /* darker gray */
}

/* Suggestion Chips */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.welcome-screen.minimized .suggestion-chips {
    display: none;
}

.chip-row-2 {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

/* New Dropdown Chip Styles */
.chip-wrapper {
    position: relative;
    display: inline-block;
}

.chip {
    background-color: transparent;
    border: 1px solid var(--chip-border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.chip:hover {
    background-color: var(--chip-hover);
    color: var(--text-primary);
}

.chip-arrow {
    font-size: 10px;
    margin-left: 4px;
}

.chip-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-surface);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 8px;
    min-width: 270px;
    display: none;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    z-index: 99999;
}

.chip-dropdown.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    border-radius: 8px;
    transition: background-color 0.2s;
    text-align: left;
    white-space: normal;
    line-height: 1.4;
}

.dropdown-item:hover {
    background-color: var(--hover-bg);
}

.model-empty {
    padding: 10px 12px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.35;
}

.model-empty-action {
    margin: 6px 8px 10px 8px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s, border-color 0.2s;
}

.model-empty-action:hover {
    background-color: var(--hover-bg);
    border-color: rgba(255, 255, 255, 0.22);
}

/* Image Preview Area */
.image-preview-area {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.image-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--input-border);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .file-preview {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.22);
    color: var(--text-secondary);
    font-size: 11px;
    text-align: center;
    word-break: break-word;
}

.image-preview-item .file-preview i {
    font-size: 14px;
    color: var(--text-primary);
}

.remove-image-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.remove-image-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}


/* Chat Messages */
.message {
    display: flex;
    gap: 16px;
    width: 100%;
    line-height: 1.6;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.message.user .avatar {
    background-color: transparent;
    color: var(--text-secondary);
}

.message.assistant .avatar {
    background-color: transparent;
    color: var(--accent-color);
}

.msg-content {
    flex: 1;
    font-size: 16px;
    color: var(--text-primary);
    overflow-wrap: break-word;
}

.retry-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(245, 108, 108, 0.12);
    border: 1px solid rgba(245, 108, 108, 0.5);
    color: #f56c6c;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.retry-btn:hover {
    background: rgba(245, 108, 108, 0.18);
    border-color: rgba(245, 108, 108, 0.8);
    color: #ffcccc;
}

.msg-content p {
    margin-top: 0;
}

/* Code Blocks */
pre {
    background-color: #0d0d0d;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid #333;
}

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}
