/* 
  Theme: Deep Space Glassmorphism 
  Fonts: Outfit (Headings), Space Grotesk (UI), System (Body)
*/

:root {
    /* Colors */
    --bg-dark: #09090b;
    --bg-darker: #050507;

    --primary-gradient: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);
    /* Emerald to Sky */
    --accent-color: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.5);

    --glass-bg: rgba(20, 20, 25, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.03);

    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;

    --input-bg: rgba(0, 0, 0, 0.3);

    /* Spacing & Radius */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Effects */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 50% 10%, #0f172a 0%, #000000 100%);
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: float 20s infinite alternate;
}

.shape-1 {
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: #10b981;
    animation-delay: -5s;
}

.shape-2 {
    bottom: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: #0ea5e9;
    animation-delay: -2s;
}

.shape-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: #2dd4bf;
    opacity: 0.2;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 30px);
    }
}

/* Layout */
.main-container {
    width: 100%;
    height: 100%;
    max-width: 1600px;
    display: flex;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.glass-panel-top {
    background: linear-gradient(to top, var(--bg-dark) 80%, transparent 100%);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
}

.glass-panel-sm {
    background: rgba(20, 20, 25, 0.4);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg);
    transition: var(--transition-smooth);
    z-index: 10;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: 32px;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 28px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-area h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.logo-area .dot {
    color: var(--accent-color);
}

.new-chat-btn-wrapper {
    margin-bottom: 24px;
}

.btn-secondary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    background: var(--glass-highlight);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-label {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 14px;
}

.history-item:hover,
.history-item.active {
    background: var(--glass-highlight);
    color: var(--text-primary);
}

.history-item .material-symbols-rounded {
    font-size: 18px;
    opacity: 0.7;
}

.sidebar-footer {
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--glass-border);
    margin-top: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-size: 13px;
    font-weight: 600;
}

.user-info .status {
    font-size: 11px;
    color: #4ade80;
    /* Green */
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: rgba(0, 0, 0, 0.1);
}

.chat-header {
    height: 64px;
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
}

.model-badge {
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.model-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-glow);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: var(--glass-highlight);
    color: var(--text-primary);
}

/* Messages */
.messages-container {
    flex: 1;
    padding: 20px 15% 120px 15%;
    /* Bottom padding for input area space */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

/* Mobile responsive padding */
@media (max-width: 768px) {
    .messages-container {
        padding: 20px 5% 120px 5%;
    }

    .sidebar {
        position: absolute;
        left: -100%;
        height: 100%;
        background: var(--bg-dark);
    }

    .sidebar.open {
        left: 0;
    }
}

.message {
    display: flex;
    gap: 16px;
    max-width: 800px;
    width: 100%;
    align-self: center;
    /* Center rendering column */
    animation: fadeIn 0.3s ease-up;
}

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

.message-content {
    line-height: 1.6;
    font-size: 15px;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    max-width: 80%;
}

.bot-message .message-content {
    background: var(--glass-highlight);
    border: 1px solid var(--glass-border);
    border-top-left-radius: 4px;
}

.user-message .message-content {
    background: var(--primary-gradient);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

.bot-avatar {
    background: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
    min-width: 32px;
}

/* Markdown Styles inside messages */
.message-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
}

.message-content ul,
.message-content ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.message-content p {
    margin-bottom: 8px;
}

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

/* Input Area */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.input-wrapper {
    width: 100%;
    max-width: 800px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    display: flex;
    align-items: flex-end;
    /* Align bottom for textarea growth */
    padding: 8px 8px 8px 20px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.input-wrapper:focus-within {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 25px rgba(16, 185, 129, 0.15);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px;
    resize: none;
    max-height: 200px;
    padding: 10px 0;
    outline: none;
    line-height: 1.5;
}

.send-btn {
    background: var(--text-primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--bg-dark);
}

.send-btn:disabled {
    background: var(--glass-border);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.disclaimer {
    font-size: 11px;
    color: var(--text-tertiary);
}

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

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

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

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

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    width: 90%;
    max-width: 450px;
    padding: 40px;
    border-radius: var(--radius-lg);
    background: #13131a;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 24px;
    text-align: center;
}

.modal-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    margin-bottom: 8px;
}

.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.input-group {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    transition: 0.2s;
}

.input-group:focus-within {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.input-group input {
    width: 100%;
    padding: 16px 12px;
    background: transparent;
    border: none;
    color: white;
    outline: none;
}

.input-group .icon {
    color: var(--text-tertiary);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    padding: 16px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.3);
}

.helper-text {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    align-items: center;
}

.dot-pulse {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: pulse 1.4s infinite;
}

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

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

@keyframes pulse {

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

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}