/* =========================================
   1. GLOBAL VARIABLES & THEME
   ========================================= */
:root {
    /* Main Colors */
    --primary-color: #007bff;       /* App Blue */
    --primary-hover: #0056b3;
    --secondary-text: #6c757d;      /* Grey Text */
    --success-color: #198754;
    --danger-color: #dc3545;
    
    /* Backgrounds */
    --bg-color: #f0f4f8;            /* Light App Background */
    --card-bg: #ffffff;             /* White Card */
    --input-bg: #ffffff;
    --modal-bg: #ffffff;
    
    /* Text & Borders */
    --text-color: #050505;
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
}

/* DARK MODE OVERRIDES */
[data-theme="dark"] {
    --primary-color: #3d8bfd;
    --primary-hover: #6ea8fe;
    --bg-color: #121212;            /* True Black */
    --card-bg: #1e1e1e;             /* Dark Grey Cards */
    --input-bg: #2c2c2c;
    --modal-bg: #1e1e1e;
    --text-color: #e4e6eb;          /* Off-White Text */
    --secondary-text: #b0b3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: none;
}

/* =========================================
   2. BODY & RESET
   ========================================= */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding-top: 60px;    /* Top Header Height */
    padding-bottom: 80px; /* Bottom Nav Height */
    transition: background-color 0.3s ease, color 0.3s ease;
    user-select: none;    /* App-like feel (no text selection) */
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* Custom Scrollbar for nicer look */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--secondary-text); border-radius: 10px; opacity: 0.5; }

/* =========================================
   3. SPA LOGIC (CRITICAL FOR TABS)
   ========================================= */
/* Default: Hide all sections */
.content-section {
    display: none;
    animation: fadeInPage 0.3s ease-out;
}

/* Default: Show Home only (JS handles the rest) */
#home {
    display: block;
}

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

/* =========================================
   4. HEADER STYLES (MAIN & UNIVERSAL)
   ========================================= */

/* A. MAIN HOME HEADER */
.top-header { 
    height: 60px; 
    background-color: var(--card-bg); 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); 
    padding: 0 15px;  
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.app-logo { font-size: 1.6rem; font-weight: 800; color: var(--primary-color); text-decoration: none; }
.header-icon { font-size: 1.5rem; cursor: pointer; position: relative; }

/* B. UNIVERSAL DYNAMIC HEADER (NEW FIX) */
.universal-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--card-bg); /* Auto-changes in Dark Mode */
    color: var(--text-color);
    z-index: 2000; /* Always on top of Main Header */
    display: flex;
    align-items: center;
    padding: 0 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: background-color 0.3s ease;
}

.universal-header i {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-right: 15px;
    cursor: pointer;
}

.universal-header h5 {
    margin: 0;
    font-weight: 700;
    color: var(--text-color);
}

/* =========================================
   5. BOTTOM NAVIGATION (FIXED BOTTOM)
   ========================================= */
.bottom-nav {
    background-color: var(--card-bg);
    box-shadow: 0 -1px 10px rgba(0,0,0,0.05);
    height: 65px;
    padding: 0 5px;
    border-top: 1px solid var(--border-color);
    z-index: 1040; /* High Z-Index to ensure clickability */
    transition: background-color 0.3s ease;
}

.nav-item-custom {
    cursor: pointer;
    color: var(--secondary-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 20%; /* 5 icons = 20% each */
    height: 100%;
    position: relative;
    transition: all 0.2s ease;
}

.nav-item-custom i {
    font-size: 1.4rem;
    margin-bottom: 2px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-item-custom span {
    font-size: 0.7rem;
    font-weight: 600;
    display: none; 
}

/* Active State Animation */
.nav-item-custom.active { color: var(--primary-color); }
.nav-item-custom.active i { transform: translateY(-3px); }
.nav-item-custom.active span { display: block; animation: fadeText 0.3s; }

@keyframes fadeText { from { opacity: 0; } to { opacity: 1; } }

/* =========================================
   6. COMMON COMPONENTS (CARDS, TAGS)
   ========================================= */
.custom-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
    transition: background-color 0.3s ease;
}

/* User Avatar Small */
.user-avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

/* Search Tags */
.search-tag {
    background-color: rgba(0, 123, 255, 0.1);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
    display: inline-block;
    transition: background 0.2s;
    margin-bottom: 5px;
}
.search-tag:active { background-color: rgba(0, 123, 255, 0.2); }

/* =========================================
   7. BOOTSTRAP OVERRIDES (FOR DARK MODE)
   ========================================= */
/* Inputs */
.form-control {
    background-color: var(--input-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}
.form-control:focus {
    background-color: var(--input-bg);
    color: var(--text-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25);
}
/* Placeholders need explicit color in dark mode */
.form-control::placeholder { color: var(--secondary-text); }

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    border: none;
}
.btn-primary:hover { background-color: var(--primary-hover); }

/* Modal / Offcanvas Backgrounds */
.offcanvas, .modal-content {
    background-color: var(--card-bg);
    color: var(--text-color);
}
.offcanvas-header .btn-close {
    filter: invert(var(--invert-value, 0)); /* Auto adjust close icon */
}
/* Dark mode close button invert */
[data-theme="dark"] .btn-close { filter: invert(1); }

/* =========================================
   8. KEBAB MENU & EXTRAS
   ========================================= */
.menu-handle { 
    width: 100px; 
    height: 4px; 
    background: #cfd9de; 
    border-radius: 4px; 
    margin: 0 auto; 
}

.menu-list-item { 
    padding: 12px 20px; 
    display: flex; 
    align-items: center; 
    color: var(--text-color); 
    font-size: 15px; 
    font-weight: 500; 
    cursor: pointer; 
}

.menu-list-item i { 
    font-size: 1.3rem; 
    margin-right: 15px; 
    color: var(--secondary-text); 
}

.menu-list-item.danger-item { color: #f4212e; } 
.menu-list-item.danger-item i { color: #f4212e; }

.menu-divider { border-top: 1px solid var(--border-color); margin: 4px 0; }
.menu-divider-thick { border-top: 6px solid var(--bg-color); margin: 8px 0; }

.menu-cancel-btn { 
    justify-content: center; 
    font-weight: 700; 
    padding-top: 15px; 
}

.offcanvas-bottom { 
    height: auto !important; 
    max-height: 75vh; 
    border-top-left-radius: 20px; 
    border-top-right-radius: 20px; 
}
