:root {
    /* Vibrant, Modern Palette */
    --primary: #6C63FF;
    /* Vibrant Indigo */
    --primary-dark: #5a52d5;
    --secondary: #00F5D4;
    /* Teal Accent */
    --bg-color: #F8F9FE;
    --surface: #ffffff;
    --text-primary: #2D3748;
    --text-secondary: #718096;
    --error: #FF6B6B;
    --success: #00D1B2;

    /* Effects */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --header-height: 60px;
    --sidebar-width: 260px;
    --bottom-nav-height: 60px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* 
   CRITICAL: Visibility Control
   Default state: HIDDEN
   Only shown when body has .authenticated AND media query matches
*/

/* Base state for all navigation: HIDDEN */
#main-header,
#sidebar,
#bottom-nav {
    display: none !important;
}

/* AUTHENTICATED STATE RULES */

/* Header: Visible on all authenticated views */
body.authenticated #main-header {
    display: flex !important;
}

/* Sidebar: Visible ONLY on Desktop + Authenticated */
@media (min-width: 768px) {
    body.authenticated #sidebar {
        display: block !important;
        transform: translateX(0);
    }
}

/* Sidebar (Mobile): Hidden by default, toggled via JS class .open */
@media (max-width: 767px) {
    body.authenticated #sidebar {
        display: block !important;
        /* Allow it to exist, but transform hides it */
        transform: translateX(-100%);
    }

    body.authenticated #sidebar.open {
        transform: translateX(0);
    }
}

/* Bottom Nav: Visible ONLY on Mobile + Authenticated */
@media (max-width: 767px) {
    body.authenticated .bottom-nav {
        display: flex !important;
    }
}

/* Auth Container (Login/Register) Center-Aligned */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Content Area */
#main-content {
    flex: 1;
    width: 100%;
    padding: 20px;
    margin-top: 0;
    /* Adjusted dynamically */
    transition: all 0.3s ease;
}

/* Authenticated Layout Adjustments */
body.authenticated #main-content {
    padding-bottom: 80px;
    /* Space for bottom nav */
    margin-top: var(--header-height);
}

/* Typography */
h1,
h2,
h3 {
    margin-bottom: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* 
   ----------------
   Components 
   ----------------
*/

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    text-align: center;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.btn-secondary {
    background: #E2E8F0;
    color: var(--text-primary);
}

/* Forms */
.auth-container {
    background: var(--surface);
    padding: 40px 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    margin: auto;
    /* Center vertically and horizontally if parent flex allows */
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color 0.2s;
    background: #F7FAFC;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* 
   ----------------
   Navigation 
   ----------------
*/

/* Header (Mobile & Desktop) */
#main-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 0 20px;
    justify-content: space-between;
    align-items: center;
}

#main-header h1 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary);
}

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

.dropdown-menu {
    position: absolute;
    top: 60px;
    right: 20px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 200px;
    padding: 8px 0;
    display: none;
    flex-direction: column;
    z-index: 200;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-menu a {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.dropdown-menu a:hover {
    background: var(--bg-color);
}

/* 
   ----------------
   Navigation Components - AUTHENTICATED ONLY
   ---------------- 
*/

/* Default State: HIDDEN */
#sidebar,
.bottom-nav {
    display: none !important;
}

/* Sidebar Styling (Only applies when authenticated) */
body.authenticated .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 20px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99;
}

body.authenticated .sidebar a {
    display: block;
    padding: 15px 30px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: all 0.2s;
}

body.authenticated .sidebar a:hover,
body.authenticated .sidebar a.active {
    background: #F0F4FF;
    color: var(--primary);
    border-left-color: var(--primary);
}

body.authenticated .sidebar.open {
    transform: translateX(0);
}

/* Bottom Nav Styling (Only applies when authenticated) */
body.authenticated .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex !important;
    /* Visible by default on mobile */
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 90;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

body.authenticated .b-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    gap: 4px;
    flex: 1;
    height: 100%;
}

body.authenticated .b-nav-item svg {
    width: 24px;
    height: 24px;
    transition: transform 0.2s;
}

body.authenticated .b-nav-item.active {
    color: var(--primary);
}

body.authenticated .b-nav-item.active svg {
    transform: translateY(-2px);
}

/* 
   ----------------
   Responsive Adjustments
   ----------------
*/
@media (min-width: 768px) {

    /* Desktop: Hide Bottom Nav, Show Sidebar */
    body.authenticated .bottom-nav {
        display: none !important;
    }

    body.authenticated #sidebar {
        transform: translateX(0);
        /* Always visible */
        display: block !important;
    }

    body.authenticated #main-content {
        margin-left: var(--sidebar-width);
        padding-bottom: 20px;
    }

    #hamburger-btn {
        display: none;
    }
}

/* Helper Utility */
.screen {
    display: none;
}

.message {
    position: fixed;
    top: 90px;
    right: 20px;
    background: var(--text-primary);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transform: translateX(120%);
    transition: transform 0.3s;
    z-index: 300;
}

.message.show {
    transform: translateX(0);
}

.success {
    background: var(--success);
}

.error {
    background: var(--error);
}