:root {
    --bg-matte-black: #0a0a0a;
    --bg-matte-lighter: #151515;
    --gold-primary: #D4AF37;
    --gold-bright: #FFDF00;
    --gold-dark: #996515;
    --text-main: #e0e0e0;
    --text-muted: #888;
    --glass-bg: rgba(20, 20, 20, 0.7);
    --glass-border: rgba(212, 175, 55, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --gold-glow: 0 0 15px rgba(212, 175, 55, 0.5);
}

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

body {
    background-color: var(--bg-matte-black);
    background-image: url('bg.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    height: 100vh;
    overflow: hidden;
    position: fixed; /* prevent mobile scroll */
    width: 100vw;
}

.cinzel {
    font-family: 'Cinzel', serif;
}

.gold-text {
    color: var(--gold-primary);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

/* Background Animation is now simplified due to static image */
.bg-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at center, rgba(26,26,26,0.3) 0%, rgba(5,5,5,0.7) 100%);
    pointer-events: none;
}

/* Glassmorphism Reusables */
.glass-panel {
    background: rgba(15, 15, 15, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 24px;
    box-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.6);
}

/* Buttons and Inputs */
input {
    width: 100%;
    padding: 15px 20px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 20px;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    outline: none;
    transition: all 0.3s ease;
    font-size: 1rem;
}

input:focus {
    border-color: var(--gold-primary);
    box-shadow: var(--gold-glow);
}

button {
    cursor: pointer;
    border: none;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
}

.gold-btn {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
    color: #000;
    padding: 12px 24px;
    border-radius: 24px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.gold-btn:hover {
    box-shadow: var(--gold-glow);
    transform: translateY(-2px);
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-bright));
}

.icon-only {
    padding: 12px;
    border-radius: 50%;
    width: 45px;
    height: 45px;
}

/* Login Overlay */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.5s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-box {
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border-radius: 30px;
}

.login-box h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.login-box p {
    color: var(--text-muted);
    margin-bottom: 25px;
    line-height: 1.5;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gold-primary);
}

.input-group input {
    padding-left: 45px;
}

/* App Layout */
.layout {
    display: flex;
    height: 100vh;
    height: 100dvh; /* Better mobile handling */
    padding: 15px;
    gap: 15px;
}

.layout.hidden {
    display: none;
}

/* Sidebar */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
    font-size: 1.8rem;
    letter-spacing: 2px;
}

.sidebar-header .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-btn {
    background: transparent;
    color: var(--text-main);
    padding: 12px 15px;
    border-radius: 8px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
}

.nav-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold-primary);
}

.nav-btn.active {
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.2), transparent);
    border-left: 3px solid var(--gold-primary);
    color: var(--gold-primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.user-info i {
    color: var(--gold-primary);
}

#user-display {
    flex: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

#logout-btn {
    background: transparent;
    color: var(--text-muted);
}

#logout-btn:hover {
    color: #ff4757;
}

/* Main Content Area */
.main-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Prevents overflow in flex child */
    overflow: hidden;
}

.content-section {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.content-section.active {
    opacity: 1;
    pointer-events: all;
    position: relative;
}

/* Chat Section */
.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.chat-header h3 {
    color: var(--gold-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
    z-index: 1;
}

/* Scrollbar customization */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 10px;
}

.message {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 20px;
    line-height: 1.6;
    animation: fadeIn 0.3s ease forwards;
}

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

.msg-user {
    align-self: flex-end;
    background: rgba(212, 175, 55, 0.15);
    border-bottom-right-radius: 4px;
    border: 1px solid var(--glass-border);
}

.msg-ai {
    align-self: flex-start;
    background: rgba(30, 30, 30, 0.85);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.msg-ai strong {
    color: var(--gold-primary);
}

.chat-input-container {
    padding: 15px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 10px;
    z-index: 2;
    background: rgba(10, 10, 10, 0.9);
}

/* Grid Sections (Tasks, Mysteries, Research) */
.section-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--glass-border);
}

.grid-container {
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    overflow-y: auto;
}

.card {
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--gold-glow);
    background: rgba(212, 175, 55, 0.05);
}

.card h4 {
    color: var(--gold-primary);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }
    .sidebar {
        width: 100%;
        padding: 10px;
    }
    .sidebar-header {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }
    .sidebar-header h2 {
        font-size: 1.5rem;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
    }
    .nav-btn {
        white-space: nowrap;
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    .chat-header h3 {
        font-size: 1.1rem;
    }
    .chat-input-container {
        padding: 10px;
        padding-bottom: env(safe-area-inset-bottom, 20px); /* For iOS home bar */
    }
    .message {
        max-width: 90%;
        padding: 12px 15px;
        font-size: 0.95rem;
    }
}
