/* ===================================================================
   ADMIN DASHBOARD STYLES
   Modern, Clean, Professional Design
   =================================================================== */

:root {
    /* Colors */
    --primary: #BD0809;
    --primary-hover: #d60a0b;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    
    /* Light Mode */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 6px rgba(0, 0, 0, 0.12), 0 12px 32px rgba(0, 0, 0, 0.12);
}

body.dark-mode {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --text-tertiary: #6e6e6e;
    --border-color: #2a2a2a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 4px 6px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.hidden {
    display: none !important;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 9999;
}

.loader {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-secondary);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.back-link {
    display: block;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--primary);
}

/* ===== BUTTONS ===== */
.primary-btn, .secondary-btn, .icon-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.primary-btn {
    background: var(--primary);
    color: white;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.secondary-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.secondary-btn:hover {
    background: var(--border-color);
}

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-tertiary);
    font-size: 1.2rem;
}

.icon-btn:hover {
    background: var(--border-color);
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.dashboard-header {
    background: var(--bg-secondary);
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    border-top: 3px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.header-left h1 {
    font-size: 1.15rem;
    margin-bottom: 0.15rem;
    white-space: nowrap;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-back-btn {
    text-decoration: none;
    white-space: nowrap;
}

.header-email {
    color: var(--text-secondary);
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#admin-email {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ===== NAVIGATION TABS ===== */
.dashboard-nav {
    background: var(--bg-secondary);
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
}

.nav-tab {
    background: none;
    border: none;
    padding: 0.75rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== MAIN CONTENT ===== */
.dashboard-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.tab-content h2 {
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 1rem 1.1rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Color-coded left borders per card type */
.stat-card:nth-child(1) { border-left-color: #3B82F6; }
.stat-card:nth-child(2) { border-left-color: #8B5CF6; }
.stat-card:nth-child(3) { border-left-color: var(--primary); }
.stat-card:nth-child(4) { border-left-color: var(--warning); }
.stat-card:nth-child(5) { border-left-color: var(--success); }
.stat-card:nth-child(6) { border-left-color: #06B6D4; }
.stat-card:nth-child(7) { border-left-color: #10B981; }
.stat-card:nth-child(8) { border-left-color: #F59E0B; }
.stat-card:nth-child(9) { border-left-color: #6366F1; }

.stat-icon {
    font-size: 1.6rem;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 8px;
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.1rem;
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.stat-info p {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== SECTION CARDS ===== */
.section-card {
    background: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

.section-card h3 {
    font-size: 1.05rem;
    margin-bottom: 0.85rem;
}

/* ===== ACTIVITY LIST ===== */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.activity-item {
    padding: 0.65rem 0.9rem;
    background: var(--bg-tertiary);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: background 0.15s ease;
    border-left: 2px solid transparent;
}

.activity-item:hover {
    background: var(--border-color);
    border-left-color: var(--primary);
}

.activity-info {
    flex: 1;
    min-width: 0;
}

.activity-user {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-details {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

.activity-time {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== REPORTS LIST ===== */
.reports-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.report-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--warning);
}

.report-card.resolved {
    border-left-color: var(--success);
    opacity: 0.7;
}

.report-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.report-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.report-actions {
    display: flex;
    gap: 0.5rem;
}

.report-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.report-question {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.report-issue {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ===== DATABASE STATS ===== */
.db-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.db-stat-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.db-stat-item strong {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.db-stat-item span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== EXPORT BUTTONS ===== */
.export-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ===== SEARCH BOX ===== */
.search-box {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box input,
.search-box select {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.search-box input:focus,
.search-box select:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===== QUESTION RESULTS ===== */
.question-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.question-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.question-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.question-text {
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.question-answer {
    color: var(--success);
    font-size: 0.95rem;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-hover);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
}

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: var(--border-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.modal-body label:first-child {
    margin-top: 0;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.modal-body textarea {
    resize: vertical;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

/* ===== UTILITIES ===== */
.loading, .info, .error-message {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.error-message {
    color: var(--error);
}

/* ===== ADMIN MOBILE MENU ===== */
.admin-hamburger {
    display: none; /* hidden on desktop */
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    position: relative;
}
.admin-hamburger:hover { border-color: var(--text-secondary); }
.admin-hamburger.active { border-color: var(--primary); }

.admin-hamburger-bar {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text-primary);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.25s ease;
}
.admin-hamburger-bar::before,
.admin-hamburger-bar::after {
    content: '';
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text-primary);
    position: absolute;
    left: 0;
    transition: all 0.25s ease;
}
.admin-hamburger-bar::before { top: -5px; }
.admin-hamburger-bar::after  { top: 5px; }

.admin-hamburger.active .admin-hamburger-bar { background: transparent; }
.admin-hamburger.active .admin-hamburger-bar::before { top: 0; transform: rotate(45deg); }
.admin-hamburger.active .admin-hamburger-bar::after  { top: 0; transform: rotate(-45deg); }

/* Mobile slide-in menu */
.admin-mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 270px;
    max-width: 80vw;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 30px rgba(0,0,0,0.4);
    z-index: 999;
    flex-direction: column;
    overflow-y: auto;
    padding-top: 60px;
    animation: adminSlideIn 0.2s ease;
}
.admin-mobile-menu.open { display: flex; }
@keyframes adminSlideIn {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.admin-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 998;
}
.admin-mobile-overlay.open { display: block; }

.admin-mobile-menu-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-mobile-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.admin-mobile-nav {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.admin-mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.admin-mobile-nav-item:hover { background: var(--bg-tertiary); }
.admin-mobile-nav-item.active {
    color: var(--primary);
    font-weight: 700;
    border-left-color: var(--primary);
    background: rgba(189, 8, 9, 0.05);
}

.admin-mobile-actions {
    padding: 0.5rem 0;
    margin-top: auto;
}

.admin-mobile-action-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background 0.15s;
}
.admin-mobile-action-item:hover { background: var(--bg-tertiary); }
.admin-mobile-signout { color: var(--error); font-weight: 600; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    /* ── Header ── */
    .dashboard-header {
        padding: 0.6rem 0.75rem;
        gap: 0.4rem;
    }
    
    .header-left h1 {
        font-size: 0.95rem;
    }

    .header-left .subtitle {
        font-size: 0.65rem;
    }

    /* Hide desktop header buttons, show hamburger */
    .header-desktop {
        display: none !important;
    }
    .admin-hamburger {
        display: flex;
    }

    /* Hide desktop nav tabs on mobile */
    .desktop-nav {
        display: none !important;
    }

    /* ── Navigation Tabs ── */
    .dashboard-nav {
        padding: 0 0.5rem;
        gap: 0;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tab {
        padding: 0.6rem 0.7rem;
        font-size: 0.72rem;
        min-width: 0;
    }

    /* ── Content Area ── */
    .dashboard-content {
        padding: 0.75rem;
    }

    .tab-content h2 {
        font-size: 1.15rem;
        margin-bottom: 1rem;
    }
    
    /* ── Stats Grid ── */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .stat-card {
        padding: 0.65rem 0.75rem;
        gap: 0.5rem;
        border-radius: 8px;
    }

    .stat-icon {
        font-size: 1.2rem;
        width: 32px;
        height: 32px;
        border-radius: 6px;
    }

    .stat-info h3 {
        font-size: 1.15rem;
    }

    .stat-info p {
        font-size: 0.65rem;
    }

    /* ── Section Cards ── */
    .section-card {
        padding: 0.85rem;
        border-radius: 8px;
        margin-bottom: 0.85rem;
    }

    .section-card h3 {
        font-size: 0.92rem;
        margin-bottom: 0.6rem;
    }

    /* ── Activity List ── */
    .activity-item {
        padding: 0.5rem 0.65rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .activity-user {
        font-size: 0.78rem;
    }

    .activity-details {
        font-size: 0.72rem;
    }

    .activity-time {
        font-size: 0.68rem;
    }

    /* ── Section Header ── */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .section-header button {
        width: 100%;
    }

    /* ── Reports ── */
    .report-card {
        padding: 1rem;
        border-radius: 10px;
    }

    .report-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .report-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .report-actions button {
        flex: 1;
        min-width: 0;
        padding: 0.45rem 0.5rem;
        font-size: 0.75rem;
        text-align: center;
        justify-content: center;
    }

    .report-question {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    .report-meta {
        font-size: 0.78rem;
    }

    /* ── Search Box ── */
    .search-box {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .search-box input,
    .search-box select {
        min-width: 0;
        font-size: 0.9rem;
        padding: 0.65rem;
    }

    .search-box .primary-btn {
        width: 100%;
    }

    /* ── Question Cards ── */
    .question-card {
        padding: 1rem;
        border-radius: 10px;
    }

    .question-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .question-header > div {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .question-header > div button {
        flex: 1;
    }

    .question-text {
        font-size: 0.88rem;
    }

    /* ── Database Stats ── */
    .db-stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .db-stat-item {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    .db-stat-item strong {
        font-size: 1.2rem;
    }

    .db-stat-item span {
        font-size: 0.75rem;
    }

    /* ── Export Buttons ── */
    .export-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .export-buttons button {
        width: 100%;
        padding: 0.65rem 1rem;
        font-size: 0.85rem;
    }

    /* ── Buttons ── */
    .primary-btn {
        padding: 0.6rem 1rem;
        font-size: 0.88rem;
    }

    .secondary-btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.82rem;
    }

    /* ── Modal ── */
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 16px 16px 0 0;
    }

    .modal-header {
        padding: 1rem 1.25rem;
    }

    .modal-header h3 {
        font-size: 1.05rem;
    }

    .modal-body {
        padding: 1rem 1.25rem;
    }

    .modal-body input,
    .modal-body select,
    .modal-body textarea {
        font-size: 0.9rem;
        padding: 0.65rem;
    }

    .modal-footer {
        padding: 1rem 1.25rem;
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
    }

    /* ── Login Card ── */
    .login-card {
        padding: 2rem 1.5rem;
        width: 95%;
    }

    .login-card h1 {
        font-size: 1.5rem;
    }
}

/* Extra small phones */
@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .nav-tab {
        padding: 0.5rem 0.5rem;
        font-size: 0.65rem;
    }

    .stat-card {
        padding: 0.5rem 0.6rem;
    }

    .stat-info h3 {
        font-size: 1rem;
    }
}
