/**
 * rAIn 2.0 - Main Stylesheet
 * CycloNetworks SAS | Le Haillan, France
 *
 * Brand Colors:
 * Primary: #abedd8
 * Secondary: #111111
 * Font: Alata
 */

/* ========================================
   CSS Variables & Reset
   ======================================== */
:root {
    --color-primary: #abedd8;
    --color-primary-light: #c8f5e8;
    --color-primary-dark: #7ed9bc;
    --color-secondary: #111111;
    --color-secondary-light: #2a2a2a;
    --color-secondary-lighter: #3a3a3a;

    --color-bg: #0a0a0a;
    --color-bg-secondary: #141414;
    --color-bg-tertiary: #1a1a1a;

    --color-text: #ffffff;
    --color-text-secondary: #b0b0b0;
    --color-text-muted: #666666;

    --color-success: #4ade80;
    --color-error: #f87171;
    --color-warning: #fbbf24;

    --color-border: #2a2a2a;
    --color-border-light: #3a3a3a;

    --font-family: 'Alata', sans-serif;
    --font-mono: 'Fira Code', 'Consolas', monospace;

    --sidebar-width: 280px;
    --header-height: 64px;
    --input-height: 60px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ========================================
   Layout
   ======================================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

.sidebar.hidden {
    transform: translateX(-100%);
    position: absolute;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo svg {
    width: 32px;
    height: 32px;
    fill: var(--color-primary);
}

.sidebar-logo h1 {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--color-primary);
}

.sidebar-logo span {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    padding: 2px 6px;
    background: var(--color-bg-tertiary);
    border-radius: 4px;
}

.new-chat-btn {
    width: 100%;
    padding: 14px 20px;
    margin: 16px 20px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-secondary);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    width: calc(100% - 40px);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(171, 237, 216, 0.3);
}

.new-chat-btn svg {
    width: 20px;
    height: 20px;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.conversations-list::-webkit-scrollbar {
    width: 6px;
}

.conversations-list::-webkit-scrollbar-track {
    background: transparent;
}

.conversations-list::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.conversation-item {
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background var(--transition-fast);
    color: var(--color-text-secondary);
}

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

.conversation-item.active {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.conversation-item svg {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    flex-shrink: 0;
}

.conversation-item span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.conversation-item .delete-btn {
    opacity: 0;
    padding: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: opacity var(--transition-fast);
}

.conversation-item:hover .delete-btn {
    opacity: 1;
}

.conversation-item .delete-btn:hover {
    color: var(--color-error);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}

.user-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-section:hover {
    background: var(--color-bg-tertiary);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-secondary);
    font-weight: 500;
    font-size: 1.1rem;
}

.user-info {
    flex: 1;
}

.user-info .name {
    font-weight: 500;
    font-size: 0.95rem;
}

.user-info .tier {
    font-size: 0.8rem;
    color: var(--color-primary);
    text-transform: capitalize;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--color-bg);
}

/* Header */
.main-header {
    height: var(--header-height);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toggle-sidebar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
    display: none;
}

.toggle-sidebar-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.toggle-sidebar-btn svg {
    width: 24px;
    height: 24px;
}

.model-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.model-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.header-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Chat Container
   ======================================== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.welcome-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
}

.welcome-logo svg {
    width: 100%;
    height: 100%;
    fill: var(--color-primary);
}

.welcome-screen h2 {
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 12px;
    color: var(--color-text);
}

.welcome-screen p {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    max-width: 500px;
    margin-bottom: 40px;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    max-width: 900px;
    width: 100%;
}

.suggestion-card {
    padding: 16px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.suggestion-card:hover {
    border-color: var(--color-primary);
    background: var(--color-bg-tertiary);
    transform: translateY(-2px);
}

.suggestion-card h4 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.suggestion-card p {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.4;
}

/* ========================================
   Messages
   ======================================== */
.message {
    display: flex;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-secondary);
}

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

.message-content {
    flex: 1;
    min-width: 0;
}

.message.user .message-content {
    display: flex;
    justify-content: flex-end;
}

.message-bubble {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    line-height: 1.7;
}

.message.assistant .message-bubble {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
}

.message.user .message-bubble {
    background: var(--color-primary);
    color: var(--color-secondary);
    max-width: 80%;
}

/* Markdown Styling in Messages */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.message-bubble h1:first-child,
.message-bubble h2:first-child,
.message-bubble h3:first-child {
    margin-top: 0;
}

.message-bubble p {
    margin-bottom: 1em;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: 1em 0;
    padding-left: 1.5em;
}

.message-bubble li {
    margin: 0.5em 0;
}

.message-bubble code {
    font-family: var(--font-mono);
    background: var(--color-bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.message-bubble pre {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 1em 0;
    overflow-x: auto;
}

.message-bubble pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
    line-height: 1.5;
}

.message-bubble blockquote {
    border-left: 3px solid var(--color-primary);
    padding-left: 16px;
    margin: 1em 0;
    color: var(--color-text-secondary);
}

.message-bubble a {
    color: var(--color-primary);
    text-decoration: none;
}

.message-bubble a:hover {
    text-decoration: underline;
}

.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.message-bubble th,
.message-bubble td {
    border: 1px solid var(--color-border);
    padding: 10px 14px;
    text-align: left;
}

.message-bubble th {
    background: var(--color-bg-tertiary);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Streaming Message States */
.message.streaming .message-bubble,
.message.streaming-content .message-bubble {
    position: relative;
}

.message.streaming-content .message-bubble::after {
    content: '▋';
    animation: blink 1s infinite;
    color: var(--color-primary);
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Message Status (for tool indicators) */
.message-status {
    display: none;
    margin-bottom: 8px;
}

/* Tool Call Indicator */
.tool-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    animation: fadeIn 0.3s ease;
}

.tool-indicator.success {
    background: rgba(74, 222, 128, 0.1);
    border-color: var(--color-success);
    color: var(--color-success);
}

.tool-indicator svg {
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
}

.tool-indicator.success svg {
    animation: none;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Thinking/Reasoning Indicator */
.thinking-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(147, 51, 234, 0.1);
    border: 1px solid rgba(147, 51, 234, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: #a78bfa;
    animation: fadeIn 0.3s ease;
}

.thinking-indicator.done {
    background: rgba(74, 222, 128, 0.1);
    border-color: var(--color-success);
    color: var(--color-success);
}

/* Thinking Container */
.thinking-container {
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.08), rgba(79, 70, 229, 0.08));
    border: 1px solid rgba(147, 51, 234, 0.2);
    transition: all var(--transition-normal);
}

.thinking-container.collapsed .thinking-content {
    max-height: 0;
    padding: 0 16px;
    opacity: 0;
}

.thinking-container.collapsed .thinking-toggle {
    transform: rotate(-90deg);
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(147, 51, 234, 0.1);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

.thinking-header:hover {
    background: rgba(147, 51, 234, 0.15);
}

.thinking-icon {
    font-size: 1.1rem;
}

.thinking-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #a78bfa;
    flex: 1;
}

.thinking-toggle {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    transition: transform var(--transition-fast);
}

.thinking-content {
    padding: 16px;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.7;
    max-height: 400px;
    overflow-y: auto;
    transition: all var(--transition-normal);
    opacity: 1;
}

.thinking-content p {
    margin-bottom: 12px;
}

.thinking-content p:last-child {
    margin-bottom: 0;
}

@keyframes thinking-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Error State */
.message.error .message-bubble {
    border-left: 3px solid var(--color-error);
    padding-left: 12px;
}

/* Generated Images */
.generated-image {
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
}

.generated-image .image-container {
    position: relative;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.generated-image .image-container::before {
    content: 'Loading image...';
    position: absolute;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.generated-image img {
    max-width: 100%;
    max-height: 512px;
    width: auto;
    height: auto;
    display: block;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1;
}

.generated-image img.loaded {
    opacity: 1;
}

.generated-image img:hover {
    filter: brightness(1.05);
}

.generated-image .image-error {
    color: var(--color-error);
    padding: 40px;
    text-align: center;
}

.generated-image .image-actions {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
}

.image-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.image-action-btn:hover {
    background: var(--color-primary);
    color: var(--color-secondary);
    border-color: var(--color-primary);
}

.image-action-btn svg {
    flex-shrink: 0;
}

.generated-image .image-caption {
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-align: center;
    margin: 0;
    background: var(--color-bg-secondary);
}

/* Search Results */
.search-results,
.youtube-results {
    margin: 12px 0;
    border-radius: var(--radius-md);
    background: var(--color-bg-secondary);
    padding: 12px;
}

.search-header,
.youtube-header {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.search-result {
    padding: 12px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border-left: 3px solid var(--color-primary);
}

.search-result:last-of-type {
    margin-bottom: 0;
}

.search-result-title {
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.search-result-title a {
    color: inherit;
    text-decoration: none;
}

.search-result-title a:hover {
    text-decoration: underline;
}

.search-result-snippet {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
    line-height: 1.4;
}

.search-result-url {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-powered-by {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-align: right;
}

/* AI Response Text after search/image results */
.ai-response-text {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.no-results {
    color: var(--color-text-muted);
    font-style: italic;
    text-align: center;
    padding: 16px;
}

/* YouTube Results */
.youtube-result {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.youtube-result:last-of-type {
    margin-bottom: 0;
}

.youtube-result-thumbnail {
    width: 120px;
    height: 68px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--color-bg);
}

.youtube-result-info {
    flex: 1;
    min-width: 0;
}

.youtube-result-title {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.youtube-result-title a {
    color: inherit;
    text-decoration: none;
}

.youtube-result-title a:hover {
    color: var(--color-primary);
}

.youtube-result-channel {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

/* ========================================
   Input Area
   ======================================== */
.input-area {
    padding: 20px 24px 24px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.input-container {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

/* Model Selector */
.model-selector-row {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 12px;
}

.model-selector {
    position: relative;
}

.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text);
    font-family: var(--font-family);
    font-size: 0.85rem;
}

.model-selector-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-bg-tertiary);
}

.model-icon {
    font-size: 1rem;
}

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

.model-dropdown-icon {
    transition: transform var(--transition-fast);
}

.model-selector.active .model-dropdown-icon {
    transform: rotate(180deg);
}

.model-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 280px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    z-index: 100;
}

.model-selector.active .model-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.model-option:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.model-option:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.model-option:hover {
    background: var(--color-bg-tertiary);
}

.model-option.selected {
    background: rgba(171, 237, 216, 0.1);
}

.model-option-icon {
    font-size: 1.5rem;
    width: 32px;
    text-align: center;
}

.model-option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-option-name {
    font-weight: 500;
    color: var(--color-text);
    font-size: 0.95rem;
}

.model-option-desc {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    transition: border-color var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--color-primary);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--color-text);
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    min-height: 24px;
}

.input-wrapper textarea::placeholder {
    color: var(--color-text-muted);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    width: 20px;
    height: 20px;
    color: var(--color-secondary);
}

.input-footer {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}

.input-footer p {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ========================================
   Auth Modal
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    text-align: center;
    margin-bottom: 32px;
}

.modal-header svg {
    width: 48px;
    height: 48px;
    fill: var(--color-primary);
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 8px;
}

.modal-header p {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-group input::placeholder {
    color: var(--color-text-muted);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.form-error {
    color: var(--color-error);
    font-size: 0.85rem;
    margin-top: 8px;
}

.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-secondary);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(171, 237, 216, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    padding: 14px 24px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-family);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 12px;
}

.btn-secondary:hover {
    background: var(--color-bg-tertiary);
    border-color: var(--color-primary);
}

.modal-footer {
    text-align: center;
    margin-top: 24px;
}

.modal-footer p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.modal-footer a {
    color: var(--color-primary);
    text-decoration: none;
    cursor: pointer;
}

.modal-footer a:hover {
    text-decoration: underline;
}

/* ========================================
   Settings Panel
   ======================================== */
.settings-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 360px;
    background: var(--color-bg-secondary);
    border-left: 1px solid var(--color-border);
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.settings-panel.active {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}

.settings-header h3 {
    font-size: 1.2rem;
    font-weight: 500;
}

.settings-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.settings-close:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.settings-close svg {
    width: 20px;
    height: 20px;
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section h4 {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    display: flex;
    flex-direction: column;
}

.setting-label span {
    font-size: 0.95rem;
}

.setting-label small {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--color-bg-tertiary);
    border-radius: 26px;
    transition: all var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--color-text);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.toggle input:checked + .toggle-slider {
    background: var(--color-primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: var(--color-secondary);
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 16px 20px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    min-width: 300px;
}

.toast.success {
    border-color: var(--color-success);
}

.toast.error {
    border-color: var(--color-error);
}

.toast.warning {
    border-color: var(--color-warning);
}

.toast svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success svg {
    color: var(--color-success);
}

.toast.error svg {
    color: var(--color-error);
}

.toast.warning svg {
    color: var(--color-warning);
}

.toast p {
    flex: 1;
    font-size: 0.95rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .toggle-sidebar-btn {
        display: flex;
    }

    .main-header {
        padding: 0 16px;
    }

    .messages-container {
        padding: 16px;
    }

    .input-area {
        padding: 16px;
    }

    .message {
        gap: 12px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    .message-bubble {
        padding: 12px 16px;
    }

    .welcome-screen h2 {
        font-size: 1.5rem;
    }

    .suggestion-cards {
        grid-template-columns: 1fr;
    }

    .settings-panel {
        width: 100%;
        max-width: 100%;
    }

    .modal {
        margin: 16px;
        padding: 24px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        top: auto;
        bottom: 80px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }
}

/* Backdrop for mobile panels */
.panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.panel-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.settings-backdrop {
    z-index: 90;
}

/* Very small screens */
@media (max-width: 480px) {
    .suggestion-cards {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Utilities
   ======================================== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Code Highlighting Override */
.hljs {
    background: var(--color-bg) !important;
}

/* ========================================
   Plan Badges & Usage Display
   ======================================== */
.plan-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-badge.plan-free {
    background: var(--color-bg-tertiary);
    color: var(--color-text-muted);
}

.plan-badge.plan-starter {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}

.plan-badge.plan-pro {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
}

.plan-badge.plan-ultra {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

/* Usage Container */
#usageContainer {
    padding: 12px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    margin: 12px;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.usage-plan-name {
    font-weight: 600;
    color: var(--color-text);
}

.usage-reset {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.usage-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.usage-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.usage-item-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.usage-item-icon {
    font-size: 0.9rem;
}

.usage-item-value {
    font-size: 0.8rem;
    color: var(--color-text);
    text-align: right;
}

.usage-item-value .used {
    color: var(--color-primary);
    font-weight: 600;
}

.usage-item-value .limit {
    color: var(--color-text-muted);
}

.usage-item-value .unlimited {
    color: var(--color-primary);
}

.usage-bar {
    height: 4px;
    background: var(--color-bg);
    border-radius: 2px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width var(--transition-normal);
}

.usage-item.warning .usage-bar-fill {
    background: var(--color-warning);
}

.usage-item.critical .usage-bar-fill {
    background: var(--color-error);
}

.upgrade-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: var(--color-secondary);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.upgrade-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(171, 237, 216, 0.3);
}

/* ========================================
   Upgrade Modal
   ======================================== */
.upgrade-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 1;
    visibility: visible;
}

.upgrade-modal {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

.upgrade-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}

.upgrade-modal .modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.upgrade-modal .modal-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.upgrade-modal .modal-close:hover {
    color: var(--color-text);
}

.upgrade-modal .modal-content {
    padding: 24px;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.plan-card {
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
}

.plan-card:hover {
    border-color: var(--color-border-light);
}

.plan-card.recommended {
    border-color: var(--color-primary);
}

.plan-card.current {
    border-color: var(--color-success);
    background: rgba(74, 222, 128, 0.05);
}

.plan-badge-recommended {
    position: absolute;
    top: -10px;
    right: 16px;
    background: var(--color-primary);
    color: var(--color-secondary);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.plan-card .plan-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.plan-price {
    margin-bottom: 4px;
}

.plan-price .price-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.plan-price .price-period {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.plan-yearly {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.plan-features li {
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.plan-features li:last-child {
    border-bottom: none;
}

.plan-features li strong {
    color: var(--color-text);
}

.plan-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.plan-actions .btn {
    width: 100%;
    text-align: center;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.plan-actions .btn-primary {
    background: var(--color-primary);
    color: var(--color-secondary);
}

.plan-actions .btn-primary:hover {
    background: var(--color-primary-dark);
}

.plan-actions .btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.plan-actions .btn-secondary:hover {
    background: var(--color-bg-tertiary);
}

/* ========================================
   Limit Reached Prompt
   ======================================== */
.limit-reached-prompt {
    padding: 20px;
    margin: 16px 0;
}

.limit-reached-content {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(248, 113, 113, 0.1));
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.limit-reached-content svg {
    color: var(--color-warning);
    margin-bottom: 12px;
}

.limit-reached-content p {
    color: var(--color-text);
    margin-bottom: 16px;
    line-height: 1.5;
}

.limit-reached-content .btn {
    margin: 0 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.limit-reached-content .btn-primary {
    background: var(--color-primary);
    color: var(--color-secondary);
    border: none;
}

.limit-reached-content .btn-secondary {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

/* ========================================
   Account Linking & Subscription Section
   ======================================== */
.btn-small {
    padding: 6px 12px;
    background: var(--color-primary);
    color: var(--color-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-small:hover {
    background: var(--color-primary-dark);
}

.btn-secondary-small {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.btn-secondary-small:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

#subscriptionSection .setting-item {
    flex-wrap: wrap;
}

#subscriptionSection .upgrade-btn {
    margin-top: 16px;
}

/* Link Account Modal */
.link-account-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 1;
    visibility: visible;
}

.link-account-modal {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.link-account-modal .modal-header {
    margin-bottom: 24px;
    border: none;
    padding: 0;
}

.link-account-modal .modal-header h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.link-account-modal .modal-header p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.link-account-modal .form-group {
    text-align: left;
    margin-bottom: 16px;
}

.link-account-modal .form-error {
    color: var(--color-error);
    font-size: 0.85rem;
    margin-bottom: 12px;
    min-height: 20px;
}

.link-account-modal .btn-primary,
.link-account-modal .btn-secondary {
    width: 100%;
    margin-bottom: 8px;
}

.link-account-modal .modal-footer {
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
}

.link-account-modal .modal-footer p {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.link-account-modal .modal-footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.link-account-modal .modal-footer a:hover {
    text-decoration: underline;
}
