/* ===== CSS Variables ===== */
:root {
    --bg-primary: #000000;
    --bg-secondary: #0f1115;
    /* Updated to match sidebar tone */
    --bg-card: rgba(20, 30, 40, 0.7);
    --text-primary: #ffffff;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-color: #60a5fa;
    --accent-secondary: #93c5fd;
    --accent-glow: rgba(96, 165, 250, 0.4);
    --accent-glow-strong: rgba(96, 165, 250, 0.6);
    --input-bg: rgba(30, 40, 50, 0.8);
    --input-border: rgba(96, 165, 250, 0.3);
    --chip-bg: rgba(30, 40, 50, 0.6);
    --chip-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    /* Slate 50 */
    --bg-secondary: #f1f5f9;
    /* Slate 100 */
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --accent-color: #3b82f6;
    /* Blue 500 */
    --accent-secondary: #60a5fa;
    /* Blue 400 */
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-glow-strong: rgba(59, 130, 246, 0.3);
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --chip-bg: #e2e8f0;
    --chip-border: transparent;
}

[data-theme="light"] body {
    background-image:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at bottom right, rgba(147, 197, 253, 0.1) 0%, transparent 40%);
}

[data-theme="light"] .google-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #475569;
}

/* Light Theme Specifics */
/* Light Theme Specifics */
[data-theme="light"] .message.user {
    background: transparent;
    /* Fix: Remove full-width background */
    box-shadow: none;
}

[data-theme="light"] .message.user .message-content {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

[data-theme="light"] .message.ai {
    background: transparent;
    border: none;
    box-shadow: none;
}

[data-theme="light"] .message.ai .message-content {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .input-container {
    background: #ffffff;
    /* Solid white for visibility */
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .message-input {
    color: #000000;
    /* Pure black text */
}

[data-theme="light"] .message-input::placeholder {
    color: #64748b;
    /* Darker slate placeholder */
}

/* Fix: Prevent input turning grey on focus */
[data-theme="light"] .input-container:focus-within {
    background: #ffffff !important;
    border-color: #3b82f6;
    /* Blue border on focus */
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

[data-theme="light"] .sidebar {
    border-right: 1px solid #cbd5e1;
    background: #f1f5f9 !important;
    /* Force light background */
}

/* Sidebar Text & Items (Light Mode) */
[data-theme="light"] .sidebar-section-title {
    color: #64748b;
}

[data-theme="light"] .history-item {
    color: #334155;
}

[data-theme="light"] .history-item:hover {
    background: #e2e8f0;
}

[data-theme="light"] .history-item.active {
    background: #eff6ff;
    color: #2563eb;
    border-left: 3px solid #2563eb;
}

/* Delete Button Styles */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 0.5rem !important;
    /* Make space for button */
}

.history-text-wrapper {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 0.5rem;
}

.delete-chat-btn {
    opacity: 0;
    /* Hidden by default */
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.history-item:hover .delete-chat-btn {
    opacity: 1;
    /* Show on hover */
}

.delete-chat-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444 !important;
    /* Red color */
}

/* Mobile: Always show delete button */
@media (max-width: 768px) {
    .delete-chat-btn {
        opacity: 0.7;
    }
}

[data-theme="light"] .sidebar-link {
    color: #334155;
}

[data-theme="light"] .sidebar-link:hover {
    background: #e2e8f0;
}

[data-theme="light"] .new-chat-btn-sidebar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #2563eb;
}

[data-theme="light"] .new-chat-btn-sidebar:hover {
    background: #eff6ff;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

*::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at top left, rgba(96, 165, 250, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(96, 165, 250, 0.05) 0%, transparent 50%);
    color: var(--text-primary);
    line-height: 1.6;
    /* Gemini-style: Horizontal flex layout */
    display: flex;
    flex-direction: row;
    height: 100%;
    overflow: hidden;
}

/* Main Wrapper - Flex grow to fill remaining space */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    /* Prevent flex item from overflowing */
    position: relative;
    transition: all 0.3s ease-in-out;
}

/* ===== Auth Modal ===== */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.auth-modal.active {
    display: flex;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* More subtle border */
    border-radius: 2.5rem;
    /* Rounder card */
    padding: 0;
    /* Remove padding from container */
    width: 90%;
    max-width: 850px;
    /* Wider for horizontal layout */
    display: flex;
    flex-direction: row;
    /* Horizontal by default */
    overflow: hidden;
    /* Ensure split visual stays inside */
    backdrop-filter: blur(40px);
}

/* LEFT SIDE: Visual */
.auth-card-visual {
    flex: 2;
    /* 40% width */
    background: linear-gradient(135deg, rgba(30, 40, 50, 0.8), rgba(10, 15, 20, 0.9));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 3rem 2rem;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.auth-card-visual h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* RIGHT SIDE: Form */
.auth-card-form {
    flex: 3;
    /* 60% width */
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* MOBILE RESPONSIVE: Stack vertically */
@media (max-width: 768px) {
    .auth-card {
        flex-direction: column;
        max-width: 400px;
        /* Back to narrow card */
    }

    .auth-card-visual {
        padding: 2rem 1.5rem 1rem;
        background: transparent;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .auth-card-form {
        padding: 1.5rem 2rem 2rem;
    }
}

/* Removed: Top gradient bar was here but removed per user request */

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 48px;
    height: 48px;
    color: var(--accent-color);
    filter: drop-shadow(0 0 12px var(--accent-glow-strong));
    margin-bottom: 1rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.google-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: #ffffff;
    border: none;
    border-radius: 3rem;
    /* Pill shape */
    font-size: 1rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.google-btn:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--chip-border);
}

.auth-divider span {
    padding: 0 1rem;
    font-size: 0.875rem;
}

#authForm input {
    width: 100%;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    background: rgba(0, 0, 0, 0.2);
    /* Darker input bg */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2rem;
    /* Pill shape */
    font-size: 1rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    transition: all 0.2s ease;
}

#authForm input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#authForm input::placeholder {
    color: var(--text-muted);
}

.auth-error {
    color: #f87171;
    font-size: 0.875rem;
    text-align: center;
    min-height: 1.25rem;
    margin-bottom: 0.5rem;
}

.auth-submit-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-secondary) 100%);
    border: none;
    border-radius: 3rem;
    /* Pill shape */
    font-size: 1rem;
    font-weight: 500;
    color: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    box-shadow: 0 0 15px var(--accent-glow);
}

.auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--accent-glow-strong);
}

.auth-toggle {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-toggle a {
    color: var(--accent-color);
    text-decoration: none;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* ===== Header ===== */
.header {
    padding: 1rem 1.5rem 1rem 4rem;
    /* Adjusted for fixed hamburger */
    /* Relative positioning within main-wrapper flex */
    position: relative;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    /* Don't shrink header */
    background: var(--bg-primary);
    /* Ensure background */
}

/* MOBILE HEADER FIX */
@media (max-width: 600px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .logo-text {
        display: none;
        /* Hide "Dertleş" text on mobile, keep only icon */
    }

    .user-name {
        display: none;
        /* Hide full username on mobile */
    }

    .header-right {
        gap: 0.5rem;
    }

    .logout-btn,
    .login-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }

    .theme-toggle,
    .icon-btn {
        width: 36px;
        height: 36px;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.logo:hover {
    opacity: 0.8;
    transform: scale(0.98);
}

.logo-icon {
    width: 38px;
    /* Increased from 32px */
    height: 38px;
    /* Increased from 32px */
    color: var(--accent-color);
    filter: drop-shadow(0 0 12px var(--accent-glow-strong));
    animation: gentlePulse 3s ease-in-out infinite;
}

@keyframes gentlePulse {

    0%,
    100% {
        filter: drop-shadow(0 0 12px var(--accent-glow));
    }

    50% {
        filter: drop-shadow(0 0 20px var(--accent-glow-strong));
    }
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 600;
    /* Semi-Bold (was 500) */
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

/* ===== Suggestion Chips ===== */
.chips {
    display: flex;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    justify-content: center;
    /* Center properly */
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    margin-bottom: 0.5rem;
    /* Add space below chips */
}

.chip {
    padding: 0.6rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--chip-border);
    border-radius: 2rem;
    /* Fully rounded chips */
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chip:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.2);
}

.chip.hidden {
    display: none !important;
    /* Force hide */
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: var(--accent-color);
    font-weight: 500;
    font-size: 0.95rem;
}

.logout-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.login-btn {
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-secondary) 100%);
    border: none;
    border-radius: 0.5rem;
    color: var(--bg-primary);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px var(--accent-glow);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--accent-glow-strong);
}



/* ===== Theme Toggle ===== */
.theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.theme-icon {
    width: 20px;
    height: 20px;
}

/* Dark theme: show sun icon (to switch to light) */
.theme-icon.sun {
    display: block;
}

.theme-icon.moon {
    display: none;
}

/* Light theme: show moon icon (to switch to dark) */
[data-theme="light"] .theme-icon.sun {
    display: none;
}

[data-theme="light"] .theme-icon.moon {
    display: block;
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 0 15vh;
    /* Added bottom padding to lift center up */
    height: 100%;
    overflow: hidden;
    /* Center vertically to bring input closer to welcome */
    justify-content: center;
    gap: 1rem;
}

/* ===== Welcome Screen ===== */
.welcome {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* Start from top, not center */
    align-items: flex-start;
    text-align: left;
    padding: 2rem 2rem 0.5rem 2rem;
    /* Reduced bottom padding */
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    flex: 0;
    /* Don't push input down */
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.welcome.hidden {
    display: none;
}

.welcome-small {
    font-size: 3rem;
    /* Reduced from 3.5rem */
    font-weight: 500;
    letter-spacing: -0.02em;
    margin-bottom: 0rem;
    background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.welcome-title {
    font-size: 3rem;
    /* Reduced from 3.5rem */
    font-weight: 500;
    color: var(--text-muted);
    /* Muted color for question */
    line-height: 1.1;
    margin-bottom: 2rem;
    letter-spacing: -0.03em;
}

.welcome-subtitle {
    display: none;
    /* Hide subtitle for cleaner look */
}

@media (max-width: 768px) {

    /* WELCOME STAYS AT TOP - Visible when keyboard opens */
    /* WELCOME SCREEN MOBILE POLISH */
    .welcome {
        justify-content: flex-start;
        align-items: flex-start;
        /* Left align */
        text-align: left;
        /* Left align text */
        flex: 0;
        padding: 0rem 1.5rem 0rem !important;
        /* "Yer var daha" - Zero padding */
        margin-top: -1.5rem !important;
        /* Aggressive pull-up into header space */
        z-index: 50;
        /* Ensure it sits nicely */
    }

    .welcome-small {
        font-size: 2.2rem !important;
        /* Smaller to fit single line with name */
        margin-bottom: 0.2rem;
        line-height: 1.2;
    }

    .welcome-title {
        font-size: 2.2rem !important;
        /* Match title size */
        text-align: left;
    }

    .welcome-title {
        font-size: 1.5rem !important;
        line-height: 1.4;
        opacity: 0.65;
    }

    .chips {
        display: none !important;
    }

    .main {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
}

/* ===== Chat Messages ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    /* Reduced side padding for wider content */
    padding: 0.5rem max(1rem, calc(50% - 450px));
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    user-select: text;
}

.chat-messages::-webkit-scrollbar {
    display: none;
}

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

.message {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
    width: 100%;
    /* Ensure message takes full available width */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

.message.user {
    align-items: flex-end;
}

.message.ai {
    align-items: flex-start;
}

.message-content {
    max-width: 90%;
    padding: 1rem 1.5rem;
    border-radius: 1.5rem;
    /* Rounder bubbles */
    font-size: 1.05rem;
    line-height: 1.6;
    letter-spacing: 0.01em;
    user-select: text;
    cursor: text;
}

/* User Bubble: Dark Card Style */
.message.user .message-content {
    background: var(--chip-bg);
    /* Darker, clearly defined */
    border: none;
    color: var(--text-primary);
    border-radius: 2rem 2rem 0 2rem;
    /* Specialized rounded corner */
}

/* AI Bubble: Clean, Transparent/Minimal */
.message.ai .message-content {
    background: transparent;
    color: var(--text-primary);
    padding-left: 0;
    border: none;
    /* No border */
    border-left: none;
    /* Remove accent border */
    margin-left: 0;
}

/* Typing indicator */
/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    width: fit-content;
    margin-top: 0.5rem;
    margin-left: 0;
    align-self: flex-start;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--accent-color);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out both;
    box-shadow: 0 0 8px var(--accent-glow);
}

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

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

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

@keyframes typingPulse {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 12px var(--accent-glow-strong);
    }
}

/* ===== Input Area (Floating Capsule) ===== */
.input-area {
    padding: 0.5rem 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    /* Mobile: Safe area for notched phones */
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* MOBILE: Fixed input bar at bottom */
@media (max-width: 768px) {
    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: none;
        background: var(--bg-primary);
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        padding: 0.75rem 1rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        z-index: 50;
    }

    /* Adjust main content to not be hidden behind fixed input */
    .main {
        padding-bottom: 100px;
        /* Space for fixed input bar */
    }

    .chat-messages {
        padding-bottom: 100px;
        /* Extra scroll space */
    }
}

.input-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(20, 30, 45, 0.85);
    /* Glassmorphism base */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3rem;
    /* Full capsule */
    padding: 0.6rem 0.6rem 0.6rem 1.5rem;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.input-container:focus-within {
    background: rgba(30, 45, 65, 0.95);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow:
        0 0 0 4px rgba(255, 255, 255, 0.1),
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 0 60px rgba(255, 255, 255, 0.05);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    resize: none;
    min-height: 24px;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
}

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

.send-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    /* Prevent shrinking */
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-secondary) 100%);
    border: none;
    border-radius: 50%;
    /* Circular button */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow:
        0 4px 15px rgba(96, 165, 250, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

/* Pulse ring animation */
.send-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.send-btn:hover::before {
    opacity: 0.3;
    animation: pulse-ring 1.5s ease-out infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }

    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.send-btn svg {
    width: 20px;
    height: 20px;
    color: var(--bg-primary);
    transition: transform 0.2s ease;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow:
        0 8px 25px rgba(96, 165, 250, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.send-btn:hover svg {
    transform: translateX(2px) translateY(-2px);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* ===== Chips ===== */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    padding-top: 0.5rem;
}

.chips.hidden {
    display: none;
}

.chip {
    background: var(--chip-bg);
    border: 1px solid var(--chip-border);
    border-radius: 2rem;
    padding: 0.7rem 1.15rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(5px);
}

.chip:hover {
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.3);
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.1);
}

/* ===== Scrollbar ===== */
.chat-messages {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.chat-messages::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(96, 165, 250, 0.4);
}

/* ===== Icon Buttons ===== */
.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

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

/* ===== History Modal ===== */
.history-card {
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    margin: 1rem 0;
    max-height: 60vh;
}

.history-item {
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 2rem;
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    color: var(--text-secondary);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: none;
}

.history-title {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.history-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.auth-submit-btn.secondary {
    background: transparent;
    border: 1px solid var(--input-border);
    margin-top: 0;
}

.auth-submit-btn.secondary:hover {
    border-color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .header {
        padding: 1rem 1.25rem;
    }

    .main {
        padding: 5rem 1rem 1.5rem;
    }

    .welcome-title {
        font-size: 1.65rem;
    }

    .welcome-small {
        font-size: 1rem;
    }

    .message-content {
        max-width: 92%;
    }

    .chip {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    .input-container {
        padding: 0.75rem 1rem;
    }
}

/* ===== NEW SIDEBAR STYLES ===== */

/* Global Fixed Hamburger Button */
.global-menu-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 2000;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transition: background 0.2s;
}

.global-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Theme Icon Toggling */
.theme-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

/* Default (Dark Mode): Show Sun, Hide Moon */
.theme-icon.moon {
    display: none;
}

.theme-icon.sun {
    display: block;
}

/* Light Mode: Show Moon, Hide Sun */
[data-theme="light"] .theme-icon.sun {
    display: none;
}

[data-theme="light"] .theme-icon.moon {
    display: block;
}

[data-theme="light"] .theme-toggle:hover .theme-icon {
    transform: rotate(15deg);
}

/* Sidebar Container - Gemini Style */
/* Sidebar Container - Gemini Style */
.sidebar {
    /* DESKTOP: Flex item (width-based toggle) */
    width: 375px;
    /* Increased from 300px per request */
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--chip-border);
    display: flex;
    flex-direction: column;
    padding: 0;
    /* Removing padding from container to prevent jump */
    height: 100%;
    overflow: hidden;
    white-space: nowrap;

    /* Smooth transition */
    transition: width 0.3s ease-in-out, transform 0.3s ease-in-out;
}

/* Inner Wrapper to maintain fixed layout during shrink */
.sidebar-inner-wrapper {
    width: 375px;
    /* Matched width */
    /* Fixed width prevents squashing */
    min-width: 375px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 5rem 1rem 1rem 1rem;
    /* Padding moved here */
}

/* Desktop: Sidebar CLOSED state (width: 0) */
body.sidebar-closed .sidebar {
    width: 0;
    padding: 0;
    border-right: none;
}

/* Open State (GLOBAL - works on all screen sizes) */
.sidebar.active {
    transform: translateX(0);
}

/* Inner Menu Toggle REMOVED */

/* DESKTOP: Show internal hamburger ONLY when sidebar is OPEN */
@media (min-width: 769px) {
    .sidebar-header {
        display: none;
        /* Hidden by default */
    }

    body:not(.sidebar-closed) .sidebar-header {
        display: flex;
        /* Show when sidebar open */
    }

    body:not(.sidebar-closed) .menu-btn-inner {
        display: flex;
        /* Show the button */
    }
}

.menu-btn-inner:hover {
    background: rgba(231, 232, 233, 0.1);
}

/* New Chat Button (Gemini Pill Style) */
.new-chat-btn-sidebar {
    width: 100%;
    padding: 10px 16px;
    background: #2b2c2d;
    color: #e3e3e3;
    border: none;
    border-radius: 16px;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 1rem;
    margin-top: 1rem;
}

.new-chat-btn-sidebar:hover {
    background: #373839;
}

.new-chat-btn-sidebar svg {
    color: #a8c7fa;
}

/* Sidebar Content */
.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 0.85rem;
    color: #c4c7c5;
    margin: 0.5rem 1rem;
    font-weight: 500;
}

/* History Items */
.history-item {
    padding: 10px 16px;
    margin: 2px 0;
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    border: none !important;
    /* Force no border */
    background: transparent;
}

.history-item:hover {
    background: #2b2c2d;
}

.history-item.active {
    background: #004a77;
    color: #c2e7ff;
}

/* Footer / Settings */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
}

.sidebar-link {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    color: #e3e3e3;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.sidebar-link:hover {
    background: #2b2c2d;
}

/* === Desktop Logic (Min-width 769px) === */
@media (min-width: 769px) {

    /* Sidebar already styled globally - just ensure no transform */
    .sidebar {
        transform: none !important;
    }

    /* No Overlay on Desktop */
    .sidebar-overlay {
        display: none !important;
    }

    /* Header is inside main-wrapper, no need to shift */
    .header {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
    }
}

/* === Mobile Logic (Max-width 768px) === */
@media (max-width: 768px) {

    /* Mobile: Sidebar is overlay, not flex item */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        transform: translateX(-100%);
        z-index: 1000;
    }

    /* Mobile: Sidebar OPEN state */
    .sidebar.active {
        transform: translateX(0);
    }

    /* Mobile: Body shouldn't use sidebar-closed class */
    body.sidebar-closed .sidebar {
        width: 85%;
        max-width: 320px;
        padding: 1rem;
    }

    /* Overlay Logic */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 900;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
    }

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

    /* Main wrapper takes full width on mobile */
    .main-wrapper {
        width: 100%;
    }

    /* Mobile: Logo Hidden per User Request */
    .header .logo {
        display: none !important;
    }

    /* Ensure Text is Visible */
    /* Mobile: Header Layout - Align content to right since logo is hidden */
    .header {
        justify-content: flex-end;
        /* Natural flex alignment for single child */
    }

    /* Reset Header Right margin */
    .header-right {
        margin-left: 0;
    }
}

/* =========================================
   LIGHT THEME OVERRIDES (High Specificity)
   ========================================= */

/* Fix: Blue User Bubble -> REMOVED. Replaced with Subtle/Invisible Style per user request */
[data-theme="light"] .message.user .message-content {
    background: #f1f5f9 !important;
    /* Very faint grey, almost invisible */
    color: #0f172a !important;
    /* Dark text */
    box-shadow: none !important;
    border: 1px solid transparent;
    /* Optional: keep structure but invisible border */
}

/* Fix: Transparent User Container */
[data-theme="light"] .message.user {
    background: transparent !important;
    box-shadow: none !important;
}

/* Fix: AI Bubble (White/Clean) -> REMOVED. Replaced with Invisible Style per user request */
[data-theme="light"] .message.ai .message-content {
    background: transparent !important;
    /* Invisible */
    border: none !important;
    box-shadow: none !important;
    color: #0f172a !important;
    /* Keep text visible */
    padding-left: 0 !important;
    /* Align text naturally */
}

/* Fix: AI Container */
[data-theme="light"] .message.ai {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Fix: Input Container (White & Focus State) */
[data-theme="light"] .input-container {
    background: #ffffff !important;
    border: 1px solid #cbd5e1;
}

[data-theme="light"] .input-container:focus-within {
    background: #ffffff !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.15) !important;
    transform: translateY(-2px);
}

/* Fix: Input Text visibility */
[data-theme="light"] .message-input {
    color: #000000 !important;
}

[data-theme="light"] .message-input::placeholder {
    color: #64748b !important;
    display: block;
}

/* ===== Modal Styles (Settings) ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal {
    background: var(--bg-card);
    width: 90%;
    max-width: 450px;
    border-radius: 16px;
    border: 1px solid var(--chip-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--chip-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--chip-border);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-title {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.setting-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.danger-zone {
    border-top: 1px solid rgba(239, 68, 68, 0.2);
    margin-top: 0.5rem;
    padding-top: 1.5rem;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

.btn-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-warning:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
}

/* Nickname Wrapper Responsive */
.nickname-wrapper {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .nickname-wrapper {
        flex-direction: column;
    }

    #saveNicknameBtn {
        width: 100% !important;
        height: 48px;
        /* Taller button for easier tapping */
    }
}
@media (max-width: 768px) {
    .sidebar {
        touch-action: pan-y; /* Fix stuck dragging */
    }
}

@media (max-width: 768px) {
    .sidebar, .sidebar-overlay {
        touch-action: pan-y;
    }
}

@media (max-width: 768px) {
    .sidebar {
        will-change: transform; /* Hardware acceleration hint */
    }
}
