/* Gemini Dark Mode Theme (ai-style.css) */
:root {
    --bg-dark: #131314;
    --bg-card: #1e1f20;
    --text-main: #e3e3e3;
    --text-muted: #c4c7c5;
    --accent-blue: #a8c7fa;
    --search-bg: #1e1f20;
    --pill-bg: #1e1f20;
    --pill-hover: #2d2e2f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
}

.gpt-layout {
    display: flex;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Dynamic Viewport Height */
    width: 100vw;
    background: var(--bg-dark);
    overflow: hidden;
}

/* Sidebar (Dark) */
.sidebar {
    width: 260px;
    background: #1e1f20;
    /* Slightly lighter than main bg */
    border-right: 1px solid #333;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    flex-shrink: 0;
    transition: width 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
}

/* Collapsed State */
.gpt-layout.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    border: none;
    opacity: 0;
}

/* Toggle Button Visibility */
.gpt-layout.sidebar-collapsed #main-header-toggle {
    display: block !important;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1.2rem;
    border-radius: 24px;
    /* More rounded */
    background: #282a2c;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
    margin-bottom: 2rem;
}

.new-chat-btn:hover {
    background: #37393b;
    color: white;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.75rem;
    color: #8e8ea0;
    margin: 1rem 0.5rem 0.5rem;
    font-weight: 600;
}

.nav-label-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-main);
    margin: 1rem 0.5rem 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 8px;
}

.nav-label-group:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chevron {
    color: var(--text-muted);
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    border-radius: 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem;
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100vh;
    background: var(--bg-dark) !important;
    color: var(--text-main);
}

.chat-scroll-area {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 2rem;
}

.gpt-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: start;
    /* Align left logic */
    justify-content: center;
    min-height: 100%;
    padding: 2rem;
}

/* Welcome Section */
.welcome-section {
    margin-bottom: 3rem;
    text-align: left;
    width: 100%;
}

.gradient-text {
    font-size: 3.5rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
    background: linear-gradient(to right, #4285F4, #9B72CB, #D96570);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.sub-text {
    font-size: 3.5rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
    color: #444746;
    /* Darker grey for unselected state look */
}

/* Suggestions Pills */
.gpt-suggestions {
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.suggestion-pill {
    background: var(--pill-bg);
    border: none;
    border-radius: 12px;
    padding: 1rem;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 180px;
    height: 180px;
    /* Square-ish cards per user screenshot actually looks like pills but maybe square pills */
    /* Wait, the user screenshot showed WIDE cards. The Gemini Dark screenshot showed pills. */
    /* Let's go with the horizontal scroll pill look which is more modern */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 120px;
    min-width: 160px;
}

.suggestion-pill:hover {
    background: var(--pill-hover);
}

.suggestion-icon {
    background: rgba(0, 0, 0, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.suggestion-icon svg {
    width: 20px;
    height: 20px;
    color: var(--accent-blue);
}

/* Search Bar Area */
.chat-input-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1rem 1.5rem;
    background: var(--bg-dark);
    z-index: 10;
}

.gpt-search-wrapper {
    width: 100%;
    max-width: 850px;
}

.gpt-search-box {
    background: var(--search-bg);
    border-radius: 36px;
    padding: 0.8rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    /* No border usually */
}

.gpt-search-box:focus-within {
    background: #2b2c2e;
}

.gpt-search-box textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 1rem;
    resize: none;
    outline: none;
    height: 24px;
    padding: 0;
    line-height: 24px;
}

.search-actions-left,
.search-actions-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-shrink: 0;
}

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

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Send Button */
.gpt-send-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.gpt-send-btn.active {
    background: white;
    color: black;
}

.gpt-send-btn.active:hover {
    background: #dcdcdc;
}

/* Model Selector specific */
.model-selector {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding-right: 1rem;
    /* Hide default arrow if possible or use svg */
}

.gpt-footer-text {
    text-align: center;
    font-size: 0.75rem;
    color: #666;
    padding-top: 1rem;
}


/* Chat History */
.chat-history {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.chat-message {
    padding: 1.5rem 0;
    display: flex;
    gap: 1rem;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.chat-message.user .message-content {
    background: #2b2c2e;
    padding: 1rem 1.5rem;
    border-radius: 20px;
}

.message-avatar {
    width: 30px;
    height: 30px;
    background: #444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    overflow: hidden;
    /* Ensure image stays inside */
    flex-shrink: 0;
}

.chat-message.ai .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Hide welcome when chatting */
.chat-main.chat-active .welcome-section,
.chat-main.chat-active .gpt-suggestions {
    display: none;
}

/* Profile Popup Menu */
.user-menu-container {
    position: relative;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
    user-select: none;
}

.user-menu-container:hover {
    background-color: var(--pill-hover);
}

.user-menu-container .user-menu {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-main);
    text-decoration: none;
    width: 100%;
}

.profile-popup {
    display: none;
    position: absolute;
    bottom: 110%;
    /* Place above the footer */
    left: 10px;
    width: 240px;
    background-color: #202123;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    flex-direction: column;
}

.profile-popup.active {
    display: flex;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    border-bottom: 1px solid #444;
    margin-bottom: 0.5rem;
}

.profile-header-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

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

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: background-color 0.1s;
    cursor: pointer;
}

.menu-item:hover {
    background-color: var(--pill-hover);
}

.menu-item svg {
    color: var(--text-muted);
    width: 16px;
    height: 16px;
}

.menu-section-divider {
    height: 1px;
    background-color: #444;
    margin: 0.5rem 0;
}

@media (max-width: 768px) {
    .gpt-layout {
        position: relative;
        overflow-x: hidden;
        /* Prevent horizontal scroll */
    }

    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 300px;
        height: 100%;
        z-index: 1000;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
        /* Ensure transition works with visibility toggle */
    }

    /* Adjust gradient text size for mobile */
    .gradient-text,
    .sub-text {
        font-size: 2rem;
        /* reduced from 2.5rem */
        padding-left: 0.5rem;
        /* Add slight padding to prevent edge sticking */
        word-wrap: break-word;
        /* Ensure wrapping */
    }

    .gpt-container {
        padding: 4rem 1rem 1rem 1rem;
        /* Added top padding for hamburger */
        align-items: center;
        width: 100%;
        box-sizing: border-box;
    }

    .suggestion-pill {
        min-width: 140px;
        padding: 0.8rem;
    }

    /* Ensure search box fits */
    .gpt-search-wrapper {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .chat-input-area {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .gpt-search-box {
        padding: 0.4rem 0.4rem 0.4rem 1rem;
        /* Balanced padding */
        width: 100%;
        gap: 0.5rem;
        align-items: center;
        border-radius: 40px;
        /* Stronger pill shape */
    }

    .search-actions-left {
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }

    .search-actions-right {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        /* Space between mic, model, send */
        margin-left: auto;
        min-width: auto;
    }

    .gpt-search-box textarea {
        min-width: 20px;
        flex-grow: 1;
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    /* Model selector management */
    .search-actions-right .model-selector {
        display: block !important;
        max-width: 85px;
        font-size: 0.85rem;
        padding-right: 0.2rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 600;
        /* Make it pop like screenshot */
        color: #e3e3e3;
    }

    .search-actions-right .icon-btn {
        display: block !important;
        padding: 6px;
        color: #c4c7c5;
    }

    /* Send Button: White Circle Style */
    .gpt-send-btn {
        display: flex !important;
        opacity: 1 !important;
        background: white !important;
        color: black !important;
        border-radius: 50%;
        padding: 0;
        width: 38px;
        height: 38px;
        justify-content: center;
        align-items: center;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        transition: transform 0.1s;
    }

    .gpt-send-btn svg {
        width: 20px;
        height: 20px;
        fill: black;
        /* Try to fill if possible, or stroke */
        stroke-width: 2.5;
        /* Bolder stroke */
    }

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

    .chat-message {
        padding: 1rem 0;
    }

    .chat-message.user .message-content {
        max-width: 100%;
    }
}