:root {
    /* Spiritual, Elegant, Modern Dark Theme */
    --bg-dark: #0f1115;
    --bg-sidebar: #16181d;
    --primary: #f59e0b; /* Saffron/Gold */
    --primary-hover: #d97706;
    --accent: #ef4444; /* Deep Red/Kumkum */
    --text-light: #f8fafc;
    --text-dim: #94a3b8;
    --chat-user: #1e222a;
    --chat-ai: transparent;
    --danger: #ef4444;
    --border-subtle: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Outfit', 'Tiro Devanagari Hindi', sans-serif;
    background: radial-gradient(circle at top right, #1f1a17, var(--bg-dark));
    color: var(--text-light);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- LANDING & AUTH OVERLAY --- */
.landing-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(15,17,21,0.98) 0%, rgba(22,24,29,0.95) 100%), url('https://www.transparenttextures.com/patterns/stardust.png');
    display: flex; justify-content: center; align-items: center;
    z-index: 2000; backdrop-filter: blur(8px); transition: opacity 0.5s ease-in-out;
}
.auth-box {
    background: rgba(30, 33, 40, 0.7); border: 1px solid var(--border-subtle);
    padding: 45px 40px; border-radius: 20px; width: 380px; text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
}
.auth-box h1 { font-size: 32px; color: var(--primary); margin-bottom: 8px; font-weight: 800; letter-spacing: 1px; }
.auth-box p.subtitle { font-size: 15px; color: var(--text-dim); margin-bottom: 30px; }
.auth-box input {
    width: 100%; padding: 14px 16px; margin-bottom: 18px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15); background: rgba(0,0,0,0.3); color: white; outline: none;
    font-size: 15px; transition: border-color 0.3s, box-shadow 0.3s;
}
.auth-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
.btn-main {
    width: 100%; padding: 14px; border: none; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #ea580c); color: #fff; font-weight: 700; font-size: 16px;
    cursor: pointer; transition: all 0.3s ease; letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(234, 88, 12, 0.3);
}
.btn-main:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(234, 88, 12, 0.4); }
.toggle-text { margin-top: 20px; font-size: 14px; color: var(--text-dim); cursor: pointer; }
.toggle-text span { color: var(--primary); font-weight: 600; transition: color 0.3s;}
.toggle-text span:hover { color: #fcd34d; text-decoration: underline; }
.hidden { display: none !important; }

/* --- DASHBOARD SIDEBAR --- */
.sidebar {
    width: 280px; background: var(--bg-sidebar); display: flex; flex-direction: column;
    border-right: 1px solid var(--border-subtle); transition: 0.3s;
}
.sidebar-header { padding: 25px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border-subtle);}
.sidebar-header i { color: var(--primary); font-size: 26px; }
.sidebar-header h2 { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }

.new-chat-btn {
    margin: 20px; padding: 14px; border: 1px solid rgba(245, 158, 11, 0.3); border-radius: 10px;
    background: rgba(245, 158, 11, 0.05); color: var(--primary); display: flex; align-items: center; justify-content: center; gap: 10px;
    cursor: pointer; transition: all 0.3s; font-weight: 600; font-size: 15px;
}
.new-chat-btn:hover { background: rgba(245, 158, 11, 0.1); border-color: var(--primary); transform: translateY(-1px); }

.chat-history { flex: 1; overflow-y: auto; padding: 10px 20px; }
.history-item {
    padding: 12px; margin-bottom: 8px; border-radius: 8px; font-size: 14px;
    color: var(--text-dim); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background 0.3s, color 0.3s, transform 0.2s;
    animation: fadeIn 0.4s ease-out forwards;
}
.history-item:active { transform: scale(0.98); }
.history-item:hover { background: rgba(255,255,255,0.06); color: white; }

/* User Control Area */
.user-controls { padding: 20px; border-top: 1px solid var(--border-subtle); background: rgba(0,0,0,0.3); }
.user-info { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #1e293b, #334155); display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px;}
.user-details h4 { font-size: 15px; margin-bottom: 3px; font-weight: 600;}
.user-details p { font-size: 12px; color: var(--text-dim); }
.premium-badge { color: var(--primary); font-weight: 700; font-size: 12px; display: flex; align-items: center; gap: 4px; }

.upgrade-btn {
    width: 100%; padding: 12px; background: linear-gradient(135deg, #f59e0b, #ea580c);
    border: none; border-radius: 8px; color: white; font-weight: 700; cursor: pointer; margin-bottom: 12px;
    display: flex; justify-content: center; gap: 8px; align-items: center; box-shadow: 0 4px 12px rgba(234, 88, 12, 0.2); transition: all 0.3s;
}
.upgrade-btn:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 15px rgba(234, 88, 12, 0.3); }
.logout-btn { width: 100%; padding: 10px; background: transparent; border: 1px solid rgba(255,255,255,0.15); color: var(--text-dim); border-radius: 8px; cursor: pointer; transition: all 0.3s; font-weight: 500;}
.logout-btn:hover { background: rgba(255,255,255,0.1); color: white; border-color: rgba(255,255,255,0.3);}

/* --- MAIN CHAT AREA --- */
.main-chat { flex: 1; display: flex; flex-direction: column; background: transparent; position: relative;}

.premium-alert {
    background: rgba(239, 68, 68, 0.1); border-left: 4px solid var(--danger); color: #fca5a5;
    text-align: center; padding: 12px; font-size: 14px; font-weight: 600; backdrop-filter: blur(5px);
}

.chat-messages {
    flex: 1; overflow-y: auto; padding: 40px 15%; display: flex; flex-direction: column; gap: 35px;
    scroll-behavior: smooth;
    transition: opacity 0.3s ease-in-out;
}
.chat-messages.fade-out { opacity: 0; }

.message-row { display: flex; gap: 20px; width: 100%; align-items: flex-start; opacity: 0; animation: fadeIn 0.4s forwards ease-out; }
.message-row.user { flex-direction: row-reverse; }

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

.msg-avatar { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.msg-avatar.ai { background: linear-gradient(135deg, var(--primary), #ea580c); color: white; border: 1px solid rgba(255,255,255,0.1); }
.msg-avatar.user { background: #1e293b; color: var(--text-dim); border: 1px solid var(--border-subtle); }

.message-bubble {
    max-width: 80%; padding: 18px 24px; border-radius: 18px; font-size: 16px; line-height: 1.7; letter-spacing: 0.3px;
}
.user .message-bubble { background: var(--chat-user); border-bottom-right-radius: 4px; border-top-right-radius: 4px; color: var(--text-light); box-shadow: 0 4px 15px rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.03); }
.ai .message-bubble { background: transparent; border: none; color: #e2e8f0; padding-left: 0; }

/* Basic Markdown-like bold formatting for AI */
.ai .message-bubble strong { color: var(--primary); font-weight: 600; }
.ai .message-bubble br { content: ""; display: block; margin: 8px 0; }

/* Input Area */
.input-container { padding: 30px 15%; background: linear-gradient(to top, var(--bg-dark) 60%, transparent); backdrop-filter: blur(8px); }
.input-box {
    display: flex; align-items: center; background: rgba(30, 41, 59, 0.6); padding: 8px 10px 8px 24px;
    border-radius: 20px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 10px 30px rgba(0,0,0,0.4); transition: 0.3s;
    backdrop-filter: blur(10px);
}
.input-box:focus-within { border-color: rgba(245, 158, 11, 0.4); background: rgba(30, 41, 59, 0.8); box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 0 2px rgba(245, 158, 11, 0.1); }
.input-box input {
    flex: 1; background: transparent; border: none; color: white; padding: 14px 0; font-size: 16px; outline: none; letter-spacing: 0.3px;
}
.input-box input::placeholder { color: #64748b; }
.input-box button {
    background: linear-gradient(135deg, var(--primary), #ea580c); color: white; border: none; width: 48px; height: 48px; border-radius: 14px;
    cursor: pointer; display: flex; justify-content: center; align-items: center; transition: all 0.2s; box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
    font-size: 18px;
}
.input-box button:hover { transform: scale(1.05); box-shadow: 0 6px 18px rgba(234, 88, 12, 0.5); }
.input-box button:active { transform: scale(0.95); }

/* Loader */
.typing-indicator { display: flex; gap: 6px; padding: 10px 5px; }
.dot { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; opacity: 0.7;}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); opacity: 0.3;} 40% { transform: scale(1); opacity: 1;} }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }



/* --- MOBILE SPECIFIC & RESPONSIVE UI --- */
.mobile-header {
    display: none;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: rgba(22, 24, 29, 0.95);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
    z-index: 50;
    position: sticky;
    top: 0;
}
.mobile-header h2 { font-size: 18px; color: var(--text-light); }
.menu-btn {
    background: transparent; border: none; color: var(--text-light); font-size: 22px; cursor: pointer;
}

.mobile-close-btn {
    display: none; position: absolute; right: 15px; top: 25px; background: transparent; border: none;
    color: var(--text-dim); font-size: 24px; cursor: pointer;
}

.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6); z-index: 90; backdrop-filter: blur(2px);
    transition: opacity 0.3s;
}

/* Base chat layout updates for consistency */
.chat-messages { padding: 30px 10%; }
.input-container { padding: 25px 10%; }

@media (max-width: 1024px) {
    .chat-messages { padding: 30px 5%; }
    .input-container { padding: 20px 5%; }
}

@media (max-width: 768px) {
    body {
        /* Prevent elastic scroll on mobile for an app-like feel */
        overscroll-behavior-y: none;
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        padding: 15px 20px;
        background: rgba(15, 17, 21, 0.85); /* Slightly darker, very blurred */
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    }

    .mobile-header h2 { font-size: 18px; font-weight: 800; background: linear-gradient(90deg, #f59e0b, #ea580c); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}

    .menu-btn {
        color: var(--primary); font-size: 24px; padding: 5px;
    }

    .mobile-close-btn {
        display: block; position: absolute; right: 20px; top: 25px;
        color: var(--text-light); font-size: 24px; padding: 5px; opacity: 0.7;
    }
    .mobile-close-btn:active { opacity: 1; transform: scale(0.95); }

    .sidebar {
        position: fixed; left: -100%; z-index: 100; height: 100vh; width: 85%; max-width: 320px;
        box-shadow: 20px 0 50px rgba(0,0,0,0.8);
        transition: left 0.4s cubic-bezier(0.25, 1, 0.5, 1); /* Snappy spring animation */
        background: rgba(22, 24, 29, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-right: 1px solid rgba(255,255,255,0.1);
    }
    .sidebar.active { left: 0; }

    .main-chat { height: 100vh; display: flex; flex-direction: column; }

    .chat-messages {
        flex: 1; padding: 20px 15px;
        padding-bottom: 20px; /* Space above input */
        gap: 25px;
    }

    .input-container {
        position: relative; /* Stick to bottom naturally in flex column */
        width: 100%;
        padding: 15px;
        padding-bottom: env(safe-area-inset-bottom, 15px); /* iPhone Notch support */
        background: linear-gradient(to top, rgba(15,17,21,1) 70%, transparent);
        backdrop-filter: blur(10px);
        border-top: none;
    }

    .input-box {
        padding: 6px 6px 6px 20px;
        background: rgba(30, 41, 59, 0.8);
        border: 1px solid rgba(255,255,255,0.15);
        box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    }

    .input-box input { padding: 10px 0; font-size: 15px; }
    .input-box button { width: 40px; height: 40px; font-size: 16px; border-radius: 12px; }

    .message-bubble {
        max-width: 88%; font-size: 15px; padding: 14px 18px; line-height: 1.6;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    .msg-avatar { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }
    .message-row { gap: 12px; }

    .auth-box { width: 92%; padding: 35px 25px; border-radius: 24px; }
}

.text-success { color: #10b981 !important; }
.text-danger { color: #ef4444 !important; }
