/* ================================================================
   BiographyNepal — Admin Panel Stylesheet (admin.css)
   Responsive: Mobile-first, tablet 769-1024px, laptop 1025px+
   ================================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
    --admin-sidebar-w: 252px;
    --admin-sidebar-w-collapsed: 62px;
    --admin-sidebar-bg: #1E293B;
    --admin-sidebar-hover: #2D3F55;
    --admin-topbar-h: 62px;
    --admin-bg: #0F172A;
    --admin-card-bg: #1E293B;
    --admin-border: #334155;
    --admin-gold: #D4A853;
    --admin-gold-dim: rgba(212,168,83,0.15);
    --admin-text: #E2E8F0;
    --admin-text-muted: #94A3B8;
    --admin-danger: #EF4444;
    --admin-success: #22C55E;
    --admin-warning: #F59E0B;
    --admin-radius: 0.65rem;
    --admin-transition: 0.22s ease;
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.admin-body {
    margin: 0;
    background: var(--admin-bg);
    color: var(--admin-text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.92rem;
    overflow-x: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--admin-sidebar-w);
    height: 100vh;
    background: var(--admin-sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--admin-transition), transform var(--admin-transition);
    z-index: 1040;
    scrollbar-width: thin;
    scrollbar-color: var(--admin-border) transparent;
    border-right: 1px solid var(--admin-border);
}

/* Collapsed (desktop icon-only) */
.admin-sidebar.collapsed { width: var(--admin-sidebar-w-collapsed); }
.admin-sidebar.collapsed .sidebar-brand span,
.admin-sidebar.collapsed .nav-link span,
.admin-sidebar.collapsed .sidebar-submenu,
.admin-sidebar.collapsed .sidebar-section-label { display: none; }
.admin-sidebar.collapsed .nav-link { justify-content: center; padding: 0.7rem 0; }
.admin-sidebar.collapsed .nav-link i { margin-right: 0 !important; font-size: 1.1rem; }
.admin-sidebar.collapsed .sidebar-brand a { justify-content: center; }
.admin-sidebar.collapsed .sidebar-brand i { margin-right: 0 !important; }

/* ── Brand ────────────────────────────────────────────────── */
.sidebar-brand {
    padding: 0 1.25rem;
    height: var(--admin-topbar-h);
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.sidebar-brand a {
    color: var(--admin-gold);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
    width: 100%;
}
.sidebar-brand a i { font-size: 1.1rem; flex-shrink: 0; }

/* ── Sidebar Nav ──────────────────────────────────────────── */
.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    flex-shrink: 0;
}
.sidebar-nav .nav-item { width: 100%; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.72rem;
    padding: 0.62rem 1.2rem;
    color: var(--admin-text-muted);
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background var(--admin-transition), color var(--admin-transition);
    border-radius: 0;
    white-space: nowrap;
    font-size: 0.9rem;
    min-height: 44px; /* touch-friendly */
}
.sidebar-nav .nav-link i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: var(--admin-sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--admin-gold-dim);
    color: var(--admin-gold);
    border-left: 3px solid var(--admin-gold);
    padding-left: calc(1.2rem - 3px);
}
.sidebar-nav .nav-link.dropdown-toggle::after { margin-left: auto; }

/* Section label */
.sidebar-section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
    padding: 0.9rem 1.2rem 0.3rem;
    font-weight: 600;
}

/* ── Submenu ──────────────────────────────────────────────── */
.sidebar-submenu { padding: 0.2rem 0 0.3rem 1rem; background: rgba(0,0,0,0.15); }
.sidebar-submenu .sub-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.42rem 1.2rem;
    color: var(--admin-text-muted);
    text-decoration: none;
    font-size: 0.84rem;
    transition: color var(--admin-transition), background var(--admin-transition);
    min-height: 38px;
    border-radius: 0;
}
.sidebar-submenu .sub-link:hover { color: #fff; background: var(--admin-sidebar-hover); }
.sidebar-submenu .sub-link.active { color: var(--admin-gold); }

.sidebar-divider { border-top: 1px solid var(--admin-border); margin: 0.3rem 0; flex-shrink: 0; }

/* push logout to bottom */
.sidebar-spacer { flex: 1 1 auto; }

/* ── Main Content ──────────────────────────────────────────── */
.admin-main {
    margin-left: var(--admin-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--admin-transition);
}
.admin-main.expanded { margin-left: var(--admin-sidebar-w-collapsed); }

/* ── Top Bar ─────────────────────────────────────────────── */
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--admin-topbar-h);
    background: var(--admin-card-bg);
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 0.75rem;
    flex-shrink: 0;
}
.admin-topbar .page-title {
    font-weight: 600;
    color: var(--admin-text);
    font-size: 0.97rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-toggle {
    color: var(--admin-text-muted);
    padding: 0.4rem 0.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 0.4rem;
    min-width: 38px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--admin-transition), background var(--admin-transition);
    flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--admin-gold); background: var(--admin-gold-dim); }

/* User chip in topbar */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.topbar-avatar {
    width: 34px;
    height: 34px;
    background: var(--admin-gold-dim);
    border: 1px solid var(--admin-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--admin-gold);
    font-size: 0.85rem;
    flex-shrink: 0;
}
.topbar-username {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--admin-text-muted);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Content Area ──────────────────────────────────────────── */
.admin-content {
    flex: 1;
    padding: 1.5rem;
}

/* ── Cards ────────────────────────────────────────────────── */
.admin-card {
    background: var(--admin-card-bg);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.admin-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--admin-text);
}

/* ── Dashboard Stat Cards ──────────────────────────────────── */
.stat-card {
    background: var(--admin-card-bg);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color var(--admin-transition), transform 0.15s;
}
.stat-card:hover { border-color: rgba(212,168,83,0.4); transform: translateY(-2px); }
.stat-icon {
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.76rem; color: var(--admin-text-muted); margin-top: 0.15rem; }

/* ── Tables ───────────────────────────────────────────────── */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--admin-radius);
    border: 1px solid var(--admin-border);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px; /* prevents ugly collapse on small screens */
}
.admin-table th {
    background: #0a1628;
    color: var(--admin-text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--admin-border);
    white-space: nowrap;
}
.admin-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--admin-border);
    vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.admin-table img.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; }

/* action buttons inside table */
.table-actions { display: flex; gap: 0.4rem; flex-wrap: nowrap; align-items: center; }
.table-actions .btn { min-height: 32px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label { color: var(--admin-text-muted); font-size: 0.82rem; margin-bottom: 0.35rem; }
.form-control,
.form-select {
    background: #0F172A !important;
    border-color: var(--admin-border) !important;
    color: var(--admin-text) !important;
    outline: none !important;
    box-shadow: none !important;
    min-height: 42px;
    font-size: 0.9rem;
}
.form-control:focus,
.form-select:focus {
    background: #0F172A !important;
    border-color: var(--admin-gold) !important;
    box-shadow: 0 0 0 0.18rem rgba(212,168,83,0.2) !important;
    color: var(--admin-text) !important;
}
.form-control::placeholder { color: #475569; }
textarea.form-control { resize: vertical; min-height: 120px; }
.input-group-text {
    background: #0a1628 !important;
    border-color: var(--admin-border) !important;
    color: var(--admin-text-muted) !important;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-gold {
    background: linear-gradient(135deg, #D4A853, #B8892E);
    color: #000;
    border: none;
    font-weight: 600;
}
.btn-gold:hover { background: linear-gradient(135deg, #e0b860, #c99a38); color: #000; }
.btn-outline-gold {
    border: 1px solid var(--admin-gold);
    color: var(--admin-gold);
    background: transparent;
}
.btn-outline-gold:hover { background: var(--admin-gold); color: #000; }

/* mobile-friendly button sizing */
.btn { min-height: 36px; }
.btn-sm { min-height: 30px; }

/* ── Status Badges ────────────────────────────────────────── */
.badge-published { background: #14532d; color: #86efac; border-radius: 999px; }
.badge-draft     { background: #3f2c06; color: #fef08a; border-radius: 999px; }
.badge-pending   { background: #1e3a5f; color: #93c5fd; border-radius: 999px; }
.badge-approved  { background: #14532d; color: #86efac; border-radius: 999px; }
.badge-rejected  { background: #7f1d1d; color: #fca5a5; border-radius: 999px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { border-radius: var(--admin-radius); border: none; }
.alert-success { background: #14532d; color: #86efac; }
.alert-danger  { background: #450a0a; color: #fca5a5; }
.alert-info    { background: #0c2340; color: #93c5fd; }
.alert-warning { background: #451a03; color: #fdba74; }

/* ── Pagination ───────────────────────────────────────────── */
.page-link {
    background: var(--admin-card-bg);
    border-color: var(--admin-border);
    color: var(--admin-text);
    min-width: 38px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.page-link:hover { background: var(--admin-sidebar-hover); color: var(--admin-gold); }
.page-item.active .page-link { background: var(--admin-gold); border-color: var(--admin-gold); color: #000; }

/* ── TinyMCE wrapper ──────────────────────────────────────── */
.tox-tinymce { border: 1px solid var(--admin-border) !important; border-radius: 0.4rem !important; }

/* ── Image Preview ────────────────────────────────────────── */
.img-preview {
    max-width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid var(--admin-border);
    margin-top: 0.5rem;
}

/* ── Badge pills ──────────────────────────────────────────── */
.admin-table .badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.3em 0.65em;
    border-radius: 999px;
}
.admin-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(212,168,83,0.12);
    color: var(--admin-gold);
    border: 1px solid rgba(212,168,83,0.3);
}

/* ── Quick Action Buttons ─────────────────────────────────── */
.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    background: var(--admin-sidebar-hover);
    border-radius: var(--admin-radius);
    color: var(--admin-text);
    text-decoration: none;
    font-weight: 600;
    transition: background var(--admin-transition), color var(--admin-transition);
    font-size: 0.88rem;
    min-height: 52px;
}
.quick-action-btn:hover { background: #3d5068; color: var(--admin-gold); }
.quick-action-btn i { width: 20px; text-align: center; color: var(--admin-gold); flex-shrink: 0; }

/* ── Dashboard Welcome Banner ─────────────────────────────── */
.dashboard-welcome {
    background: linear-gradient(135deg, #1E293B 0%, #162032 100%);
    border: 1px solid var(--admin-border);
    border-left: 4px solid var(--admin-gold);
    border-radius: var(--admin-radius);
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.dashboard-welcome-icon { font-size: 2rem; color: var(--admin-gold); flex-shrink: 0; }
.dashboard-welcome-text .title { font-size: 1.05rem; font-weight: 700; color: var(--admin-text); }
.dashboard-welcome-text .subtitle { font-size: 0.82rem; color: var(--admin-text-muted); }

/* ── Admin Login Page ─────────────────────────────────────── */
.login-card {
    width: 100%;
    max-width: 420px;
    animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile overlay backdrop ──────────────────────────────── */
.admin-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1035;
    cursor: pointer;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}
.admin-sidebar-backdrop.show { display: block; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════════════════════════ */

/* ── Tablet (769px – 1024px): icon-only sidebar by default ── */
@media (min-width: 769px) and (max-width: 1024px) {
    .admin-sidebar { width: var(--admin-sidebar-w-collapsed); }
    .admin-sidebar .sidebar-brand span,
    .admin-sidebar .nav-link span,
    .admin-sidebar .sidebar-submenu,
    .admin-sidebar .sidebar-section-label { display: none; }
    .admin-sidebar .nav-link { justify-content: center; padding: 0.7rem 0; }
    .admin-sidebar .nav-link i { margin-right: 0 !important; font-size: 1.1rem; }
    .admin-sidebar .sidebar-brand a { justify-content: center; }
    .admin-sidebar .sidebar-brand i { margin-right: 0 !important; }

    /* When expanded on tablet */
    .admin-sidebar.expanded-tablet { width: var(--admin-sidebar-w); }
    .admin-sidebar.expanded-tablet .sidebar-brand span,
    .admin-sidebar.expanded-tablet .nav-link span,
    .admin-sidebar.expanded-tablet .sidebar-submenu,
    .admin-sidebar.expanded-tablet .sidebar-section-label { display: block; }
    .admin-sidebar.expanded-tablet .nav-link { justify-content: flex-start; padding: 0.62rem 1.2rem; }
    .admin-sidebar.expanded-tablet .nav-link i { margin-right: 0 !important; }
    .admin-sidebar.expanded-tablet .sidebar-brand a { justify-content: flex-start; }

    .admin-main { margin-left: var(--admin-sidebar-w-collapsed); }
    .admin-main.expanded { margin-left: var(--admin-sidebar-w-collapsed); }
    .admin-main.tablet-expanded { margin-left: var(--admin-sidebar-w); }

    .admin-content { padding: 1.25rem; }

    .topbar-username { display: none; }
}

/* ── Mobile (≤ 768px): sidebar slides off-screen ─────────── */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        width: var(--admin-sidebar-w);
        box-shadow: none;
    }
    .admin-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }
    /* reset any desktop collapsed state on mobile */
    .admin-sidebar.mobile-open .sidebar-brand span,
    .admin-sidebar.mobile-open .nav-link span,
    .admin-sidebar.mobile-open .sidebar-section-label { display: block !important; }
    .admin-sidebar.mobile-open .nav-link { justify-content: flex-start !important; padding: 0.62rem 1.2rem !important; }
    .admin-sidebar.mobile-open .nav-link i { margin-right: 0.72rem !important; }
    .admin-sidebar.mobile-open .sidebar-brand a { justify-content: flex-start !important; }
    .admin-sidebar.mobile-open .sidebar-submenu { display: block !important; }

    .admin-main { margin-left: 0 !important; }

    .admin-content { padding: 0.9rem; }

    /* Topbar on mobile */
    .admin-topbar { padding: 0 0.9rem; gap: 0.5rem; }
    .admin-topbar .page-title { font-size: 0.9rem; }
    .topbar-username { display: none; }

    /* Cards */
    .admin-card { padding: 1rem; }
    .admin-card-header { gap: 0.5rem; }
    .admin-card-header .btn { font-size: 0.78rem; padding: 0.35rem 0.65rem; }

    /* Stat cards: 2-column grid */
    .stat-cards-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    .stat-card { padding: 0.9rem 1rem; gap: 0.75rem; }
    .stat-icon { width: 42px; height: 42px; font-size: 1.2rem; }
    .stat-value { font-size: 1.35rem; }
    .stat-label { font-size: 0.71rem; }

    /* Quick actions: 2 col */
    .quick-actions-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }
    .quick-action-btn { padding: 0.75rem 0.9rem; font-size: 0.82rem; }

    /* Tables: horizontal scroll */
    .table-responsive-wrapper { border-radius: 0.5rem; }
    .admin-table { min-width: 480px; }
    .admin-table th, .admin-table td { padding: 0.65rem 0.75rem; font-size: 0.83rem; }

    /* Pagination: smaller */
    .pagination { flex-wrap: wrap; gap: 0.2rem; }
    .page-link { min-width: 34px; min-height: 34px; font-size: 0.82rem; }

    /* Dashboard welcome */
    .dashboard-welcome { padding: 1rem; gap: 0.75rem; }
    .dashboard-welcome-icon { font-size: 1.5rem; }

    /* Hide optional columns on mobile via utility class */
    .d-mobile-none { display: none !important; }

    /* Forms */
    .form-control, .form-select { min-height: 44px; font-size: 1rem; }
}

/* ── Small phone (≤ 400px) ────────────────────────────────── */
@media (max-width: 400px) {
    .stat-cards-grid { grid-template-columns: 1fr; }
    .quick-actions-grid { grid-template-columns: 1fr; }
    .admin-topbar .page-title { max-width: 140px; }
}
