/* ==========================================================================
   GemmaLab Premium CSS Stylesheet
   Designed with vibrant dark aesthetics, glassmorphism, and responsive grids.
   ========================================================================== */

:root {
    --bg-darker: #06070c;
    --bg-dark: #0f111a;
    --bg-card: rgba(17, 19, 31, 0.55);
    --bg-card-hover: rgba(25, 28, 45, 0.7);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(138, 92, 246, 0.25);
    
    --text-primary: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;
    
    --accent-purple: hsl(265, 85%, 65%);
    --accent-purple-light: hsl(265, 90%, 75%);
    --accent-glow: hsla(265, 85%, 65%, 0.45);
    --accent-blue: hsl(210, 85%, 60%);
    
    --success-green: hsl(150, 75%, 55%);
    --warning-orange: hsl(35, 85%, 55%);
    --danger-red: hsl(0, 80%, 60%);
    
    --font-sans: 'Outfit', 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'Fira Code', 'Courier New', monospace;
    --sidebar-width: 320px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Background Glowing Orbs */
.glow-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    mix-blend-mode: screen;
    animation: pulse 12s infinite alternate ease-in-out;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
    bottom: -150px;
    right: -150px;
    animation-delay: -3s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent-purple-light) 0%, transparent 70%);
    top: 30%;
    right: 20%;
    animation-delay: -6s;
}

@keyframes pulse {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.15) translate(40px, 30px); }
}

/* App Layout Grid */
.app-layout {
    position: relative;
    z-index: 2;
    display: flex;
    width: 100%;
    height: 100vh;
}

/* Sidebar Styling */
.sidebar-panel {
    width: var(--sidebar-width);
    height: 100%;
    background: rgba(10, 11, 18, 0.85);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: var(--transition-smooth);
}

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

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-purple-light);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo-title {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 50%, var(--accent-purple-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-subtitle {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.close-sidebar-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.close-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

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

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

.setting-select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    transition: var(--transition-smooth);
}

.setting-select:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px var(--border-glow);
}

.select-wrapper::after {
    content: '▼';
    font-size: 0.6rem;
    color: var(--text-muted);
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.setting-textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    transition: var(--transition-smooth);
}

.setting-textarea:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px var(--border-glow);
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-val {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-purple-light);
}

.setting-slider {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    appearance: none;
    cursor: pointer;
}

.setting-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-purple-light);
    box-shadow: 0 0 8px var(--accent-glow);
    transition: var(--transition-smooth);
}

.setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
}

.danger-btn {
    width: 100%;
    padding: 14px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    color: #fca5a5;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ffffff;
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}

.danger-btn svg {
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.status-dot.green {
    background: var(--success-green);
    box-shadow: 0 0 8px var(--success-green);
}

.status-dot.orange {
    background: var(--warning-orange);
    box-shadow: 0 0 8px var(--warning-orange);
}

/* Main Chat Window */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: rgba(15, 17, 26, 0.3);
    backdrop-filter: blur(10px);
}

.chat-header {
    height: 72px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 11, 18, 0.4);
}

.menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.model-badge {
    background: hsla(265, 85%, 65%, 0.15);
    border: 1px solid hsla(265, 85%, 65%, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-purple-light);
    letter-spacing: 0.5px;
}

/* Chat Feed */
.chat-feed {
    flex: 1;
    padding: 32px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Welcome Onboarding Screen */
.welcome-screen {
    max-width: 600px;
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(138, 92, 246, 0.1);
    border: 1px solid rgba(138, 92, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-purple-light);
    margin-bottom: 8px;
    box-shadow: 0 0 20px rgba(138, 92, 246, 0.15);
}

.welcome-icon svg {
    width: 32px;
    height: 32px;
}

.welcome-screen h2 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.welcome-screen p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 12px;
}

.prompt-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    margin-top: 16px;
}

.suggestion-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    text-align: left;
    cursor: pointer;
    outline: none;
    transition: var(--transition-smooth);
}

.suggestion-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(138, 92, 246, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.suggestion-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-purple-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.suggestion-desc {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Chat Messages Bubble System */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
}

.message-sender {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-left: 12px;
}

.chat-message.user .message-sender {
    text-align: right;
    padding-left: 0;
    padding-right: 12px;
}

.message-bubble {
    padding: 16px 20px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, var(--accent-purple) 0%, #7c3aed 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.25);
}

.chat-message.assistant .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Thinking Indicator Accordion */
.thinking-accordion {
    margin-bottom: 12px;
    background: rgba(138, 92, 246, 0.03);
    border-left: 3px solid var(--accent-purple);
    border-radius: 4px 10px 10px 4px;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.thinking-header {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.thinking-title-area {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-purple-light);
}

.thinking-pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-purple-light);
    border-radius: 50%;
    animation: thinkingGlow 1.2s infinite ease-in-out;
}

@keyframes thinkingGlow {
    0%, 100% { opacity: 0.3; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.2); }
}

.thinking-icon {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.thinking-accordion.open .thinking-icon {
    transform: rotate(180deg);
}

.thinking-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
    font-style: italic;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.thinking-accordion.open .thinking-content {
    max-height: 500px;
    padding-bottom: 14px;
    overflow-y: auto;
}

/* Markdown Rendering */
.message-bubble p {
    margin-bottom: 12px;
}

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

.message-bubble ul, .message-bubble ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.message-bubble li {
    margin-bottom: 6px;
}

.message-bubble code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-purple-light);
}

.code-block-container {
    background: #08090f;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 16px 0;
    overflow: hidden;
}

.code-block-header {
    background: rgba(255, 255, 255, 0.02);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.copy-code-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.75rem;
    transition: var(--transition-smooth);
}

.copy-code-btn:hover {
    color: #ffffff;
}

.code-block-container pre {
    padding: 16px;
    overflow-x: auto;
    margin: 0;
}

.code-block-container code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: #cbd5e1;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Typing Indicator */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px !important;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    opacity: 0.4;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* Chat Input Footer Area */
.chat-input-area {
    padding: 16px 24px 32px 24px;
    background: linear-gradient(to top, var(--bg-darker) 70%, transparent 100%);
}

.input-form {
    max-width: 800px;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-wrapper {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px 12px;
    display: flex;
    align-items: flex-end;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: var(--transition-smooth);
}

.input-wrapper:focus-within {
    border-color: var(--accent-purple);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 15px var(--border-glow);
}

.prompt-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.5;
    padding: 8px;
    max-height: 150px;
    resize: none;
}

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

.send-btn {
    background: var(--accent-purple);
    color: #ffffff;
    border: none;
    outline: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-purple-light);
    box-shadow: 0 0 12px var(--accent-glow);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.2);
    cursor: not-allowed;
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.input-footer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 900px) {
    .sidebar-panel {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        top: 0;
        bottom: 0;
        z-index: 100;
    }
    
    .sidebar-panel.open {
        left: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    .close-sidebar-btn {
        display: flex;
    }
    
    .menu-btn {
        display: flex;
    }
}

@media (max-width: 600px) {
    .prompt-suggestions {
        grid-template-columns: 1fr;
    }
    
    .chat-message {
        max-width: 92%;
    }
    
    .chat-feed {
        padding: 20px 16px;
    }
    
    .chat-input-area {
        padding: 12px 16px 20px 16px;
    }
}
