/* Base Settings and Variables */
:root {
    --bg-main: #0a0a0c;
    --bg-sidebar: rgba(20, 20, 24, 0.7);
    --bg-panel: rgba(30, 30, 36, 0.6);
    --bg-input: rgba(45, 45, 50, 0.5);

    --text-primary: #f0f0f5;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-primary: #8b5cf6;
    --accent-secondary: #3b82f6;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));

    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Outfit', var(--font-sans);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, everything scrollable inside */
    display: flex;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 10;
}

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

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

.logo h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: #fdfaf6;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.8), 0 0 20px rgba(139, 92, 246, 0.4);
}

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

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

.setting-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.info-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    cursor: help;
}

.glass-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.glass-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

/* Sliders */
.glass-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    outline: none;
}

.glass-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--glass-shadow);
    transition: transform 0.1s;
}

.glass-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--accent-primary);
}

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

.secondary-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
    /* For smaller screens */
}

/* Header */
.chat-header {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.model-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    scroll-behavior: smooth;
}

.welcome-container {
    text-align: center;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fadeIn 0.8s ease-out forwards;
}

.welcome-title {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 600;
    color: #fdfaf6;
    text-shadow: 0 0 15px rgba(139, 92, 246, 0.8), 0 0 30px rgba(139, 92, 246, 0.4);
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    animation: slideUp 0.3s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

.message.user {
    /* Different styling for user */
    flex-direction: row-reverse;
}

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

.user .avatar {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
}

.ai .avatar {
    background: var(--accent-gradient);
    color: white;
}

.message-content {
    background: transparent;
    max-width: calc(100% - 52px);
    /* 36px avatar + 16px gap */
}

.user .message-content {
    background: var(--bg-panel);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.ai .message-content {
    padding-top: 6px;
    /* Align with avatar */
    color: var(--text-primary);
    line-height: 1.6;
}

/* Markdown Styles in Responses */
.ai .message-content p {
    margin-bottom: 12px;
}

.ai .message-content pre {
    background: #1e1e1e;
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.ai .message-content code {
    font-family: monospace;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
}

.ai .message-content pre code {
    background: transparent;
    padding: 0;
}

.ai .message-content ul,
.ai .message-content ol {
    margin: 0 0 12px 24px;
}

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

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

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

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

@keyframes bounce {

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

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.chat-input-container {
    padding: 0 24px 24px;
    max-width: 848px;
    /* 800 + 24*2 padding */
    width: 100%;
    margin: 0 auto;
}

.input-wrapper {
    position: relative;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    align-items: flex-end;
    box-shadow: var(--glass-shadow);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--border-hover);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 200px;
    padding: 4px 0;
    line-height: 1.5;
}

.chat-input:focus {
    outline: none;
}

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

.send-btn {
    background: var(--text-primary);
    color: var(--bg-main);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin-left: 12px;
    flex-shrink: 0;
}

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

.send-btn:disabled {
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.footer-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 12px;
}

/* Animations */
@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-content {
        display: none;
        /* In completely realistic app, we'd add a toggle */
    }

    .chat-history {
        padding: 20px 16px;
    }

    .chat-input-container {
        padding: 0 16px 16px;
    }
}