/* ============================================================
   Primly Admin Portal — mobile-first stylesheet
   ──────────────────────────────────────────────────────────
   Layout strategy:
     * Mobile (< 768px): hamburger-toggled drawer, full-width
       content, single-column stat grid.
     * Tablet (≥ 768px): two-column stat grid, drawer becomes
       a permanent narrow sidebar.
     * Desktop (≥ 1024px): four-column stat grid, content max
       widths tighten for readability.

   Tap targets are never smaller than 44×44 px (Apple HIG +
   WCAG 2.5.5). Buttons use min-height 44px even when text is
   short, so thumb-friendly hit areas hold across the whole UI.
   ============================================================ */

:root {
    --green-deep:   #023e58;
    --green-mid:    #1a7a9a;
    --green-light:  #d8edf2;
    --gold:         #C9933A;
    --gold-light:   #E8B96A;
    --cream:        #FAF6EF;
    --cream-dark:   #F0EAE0;
    --white:        #FFFFFF;
    --text-dark:    #1C1C1C;
    --text-mid:     #4A4A4A;
    --text-muted:   #7A7A7A;
    --border:       #DDD5C8;
    --red:          #C0392B;
    --red-bg:       #fdecea;
    --green-success-bg: #d0f8ee;
    --gold-bg:      #fff4d6;
    --shadow-sm:    0 2px 12px rgba(2,62,88,0.08);
    --shadow-md:    0 6px 30px rgba(2,62,88,0.14);
    --radius:       12px;
    --radius-sm:    8px;
    --sidebar-w:    240px;
}

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

html, body {
    height: 100%;
    background: var(--cream);
    color: var(--text-dark);
    font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-size-adjust: 100%;
}

a { color: var(--green-mid); text-decoration: none; }
a:hover { color: var(--green-deep); }

img { max-width: 100%; height: auto; }

/* ── Top bar (mobile only by default) ───────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    background: var(--green-deep);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.hamburger {
    width: 44px;
    height: 44px;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.5rem;
}
.admin-pill {
    background: rgba(255,255,255,0.15);
    color: var(--white);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

/* ── Sidebar (drawer on mobile) ─────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    background: var(--white);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.sidebar-head {
    padding: 20px 18px;
    background: linear-gradient(135deg, var(--green-deep), var(--green-mid));
    color: var(--white);
}
.sidebar-head .name {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
}
.sidebar-head .role {
    font-size: 0.78rem;
    opacity: 0.85;
    margin-top: 2px;
}

.nav-list { list-style: none; padding: 8px 0; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    min-height: 44px;
    color: var(--text-mid);
    font-weight: 500;
    border-left: 3px solid transparent;
    cursor: pointer;
}
.nav-item:hover { background: var(--cream); color: var(--green-deep); }
.nav-item.active {
    background: var(--green-light);
    color: var(--green-deep);
    border-left-color: var(--gold);
    font-weight: 700;
}
.nav-item .nav-icon { font-size: 1.15rem; width: 24px; text-align: center; }

.sidebar-foot {
    border-top: 1px solid var(--border);
    padding: 12px 18px;
    margin-top: 8px;
}
.sidebar-foot a {
    display: block;
    padding: 8px 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ── Main content area ──────────────────────────────────────── */
.main {
    padding: 16px;
    min-height: calc(100vh - 56px);
}
.page-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.5rem;
    color: var(--green-deep);
    margin-bottom: 4px;
}
.page-sub { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 16px; }

/* ── Cards & containers ─────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.card-title {
    font-weight: 700;
    color: var(--green-deep);
    margin-bottom: 12px;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: space-between;
}
.card-title .link {
    font-size: 0.8rem;
    font-weight: 500;
}

/* ── Stat grid ──────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);   /* mobile */
    gap: 10px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    min-height: 88px;
    display: flex; flex-direction: column; justify-content: center;
}
.stat-card .stat-icon { font-size: 1.4rem; margin-bottom: 4px; }
.stat-card .stat-val  { font-weight: 700; color: var(--green-deep); font-size: 1.4rem; }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase;
                          letter-spacing: 0.04em; margin-top: 2px; }
.stat-card.alert { border-left: 4px solid var(--gold); }
.stat-card.danger { border-left: 4px solid var(--red); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 18px;
    border: 0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s, transform 0.05s;
    white-space: nowrap;
    line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--green-deep); color: var(--white);
}
.btn-primary:hover { filter: brightness(1.1); color: var(--white); }
.btn-secondary {
    background: var(--white);
    color: var(--green-deep);
    border: 1.5px solid var(--green-deep);
}
.btn-danger { background: var(--red); color: var(--white); }
.btn-gold   { background: var(--gold); color: var(--white); }
.btn-sm     { min-height: 36px; padding: 6px 14px; font-size: 0.825rem; }
.btn-full   { width: 100%; }
.btn-row    { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-dark);
}
.form-control:focus {
    outline: none;
    border-color: var(--green-mid);
    box-shadow: 0 0 0 3px rgba(26,122,154,0.15);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* ── Tables (mobile: cards, desktop: tables) ────────────────── */
.list-row {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.list-row .avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--green-mid);
    color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem;
    flex-shrink: 0;
}
.list-row .body { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; font-size: 0.95rem; white-space: nowrap;
                    overflow: hidden; text-overflow: ellipsis; }
.list-row .sub   { font-size: 0.78rem; color: var(--text-muted);
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .meta  { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; }

/* ── Filter chips ───────────────────────────────────────────── */
.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
}
.chip {
    flex-shrink: 0;
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: var(--white);
    color: var(--text-mid);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    min-height: 36px;
    display: inline-flex; align-items: center;
}
.chip.active { background: var(--green-deep); color: var(--white); border-color: var(--green-deep); }
.chip:hover { border-color: var(--green-mid); color: var(--green-deep); }
.chip.active:hover { color: var(--white); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--cream-dark);
    color: var(--text-mid);
}
.badge-success { background: var(--green-success-bg); color: #0a6e52; }
.badge-warn    { background: var(--gold-bg);          color: #a07016; }
.badge-danger  { background: var(--red-bg);           color: var(--red); }
.badge-info    { background: var(--green-light);      color: var(--green-deep); }

/* ── Flash ──────────────────────────────────────────────────── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 0.9rem;
    border-left: 4px solid;
}
.flash-success { background: var(--green-success-bg); color: #0a6e52;        border-left-color: #0a9e6e; }
.flash-error   { background: var(--red-bg);           color: var(--red);     border-left-color: var(--red); }
.flash-info    { background: var(--green-light);      color: var(--green-deep); border-left-color: var(--green-mid); }
.flash-warn    { background: var(--gold-bg);          color: #a07016;        border-left-color: var(--gold); }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; opacity: 0.35; margin-bottom: 8px; }
.empty-state .title { font-weight: 700; color: var(--green-deep); margin-bottom: 4px; }
.empty-state .sub   { font-size: 0.875rem; }

/* ── Auth (login) ───────────────────────────────────────────── */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--green-deep), var(--green-mid));
    padding: 20px;
}
.auth-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 380px;
}
.auth-logo {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.6rem;
    color: var(--green-deep);
    text-align: center;
    margin-bottom: 4px;
}
.auth-tag {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 22px;
}

/* ── Breadcrumbs (FSP) ──────────────────────────────────────── */
.breadcrumbs {
    display: flex; flex-wrap: wrap; gap: 4px;
    font-size: 0.85rem; color: var(--text-muted);
    margin-bottom: 14px;
}
.breadcrumbs a { color: var(--green-mid); }
.breadcrumbs .sep::before { content: "›"; padding: 0 6px; color: var(--text-muted); }

/* ── Utility ────────────────────────────────────────────────── */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mb-2 { margin-bottom: 12px; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.flex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-row.between { justify-content: space-between; }
.hidden-mobile { display: none; }
.no-scroll { overflow: hidden; }

/* ────────────────────────────────────────────────────────────
   Tablet
   ──────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .form-row  { grid-template-columns: 1fr 1fr; }
    .hidden-mobile { display: initial; }
}

/* ────────────────────────────────────────────────────────────
   Desktop — permanent sidebar, no overlay
   ──────────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
    .topbar {
        padding-left: calc(var(--sidebar-w) + 24px);
    }
    .hamburger { display: none; }
    .sidebar {
        transform: translateX(0);
        width: var(--sidebar-w);
        max-width: var(--sidebar-w);
        box-shadow: none;
        top: 0;
    }
    .sidebar-overlay { display: none; }
    .main {
        margin-left: var(--sidebar-w);
        padding: 24px 32px;
        max-width: 1200px;
    }
    body.no-scroll { overflow: auto; }   /* drawer-disable no-op */
}
