/* ============================================================
   Camp 2026 Portal — Shared Styles  (assets/css/camp.css)
   Single source of truth. Included by _head.php on every page.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---- Tokens ---- */
:root {
    --emerald:         #059669;
    --emerald-dark:    #047857;
    --emerald-light:   #d1fae5;
    --gray-bg:         #f3f4f6;
    --gray-border:     #e5e7eb;
    --text-dark:       #1f2937;
    --text-muted:      #6b7280;
    --danger:          #dc2626;
    --warning:         #d97706;
    --radius:          12px;
    --surface:         #ffffff;
    --surface-2:       #f3f4f6;
    --sidebar-w:       230px;
    --transition-ui:   background .2s, color .2s;
}

/* ---- Dark mode ---- */
[data-theme="dark"] {
    --gray-bg:       #0f1115;
    --gray-border:   #2a2d35;
    --text-dark:     #e7e9ec;
    --text-muted:    #9aa0a8;
    --surface:       #181a20;
    --surface-2:     #1f2229;
    --emerald-light: #0d2b22;
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg { max-width: 100%; }

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--gray-bg);
    color: var(--text-dark);
    transition: var(--transition-ui);
    padding-bottom: env(safe-area-inset-bottom, 0);
    overflow-x: hidden;
}

a { color: var(--emerald); text-decoration: none; }
button { font-family: inherit; }

/* ============================================================
   SHELL LAYOUT
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--gray-border);
    padding: 20px 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    transition: var(--transition-ui), width .2s;
}
.sidebar .brand {
    padding: 4px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 15px;
    color: var(--text-dark);
    text-align: center;
    line-height: 1.3;
}
.sidebar .brand-text { white-space: nowrap; }
.sidebar .brand span { color: var(--emerald); }
.sidebar .brand-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 10px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--text-dark); }
.sidebar nav a.active {
    color: var(--emerald-dark);
    background: var(--emerald-light);
    border-left-color: var(--emerald);
    font-weight: 600;
}

/* ---- Main content area ---- */
.main-content {
    flex: 1 1 0;
    min-width: 0;
    padding: 28px 32px;
    max-width: 1800px;
    width: 100%;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--gray-bg);
    padding: 10px 0;
    transition: padding .2s, box-shadow .2s;
    flex-wrap: wrap;
}
.topbar.condensed { padding: 6px 0; box-shadow: 0 4px 12px rgba(0,0,0,.04); }
.topbar h1 { font-size: 22px; font-weight: 800; margin: 0; transition: font-size .2s; }
.topbar.condensed h1 { font-size: 18px; }
.topbar .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s, transform .1s;
}
.btn:active { transform: scale(.96); }
.btn-primary  { background: var(--emerald); color: #fff; }
.btn-primary:hover { background: var(--emerald-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text-dark); border: 1px solid var(--gray-border); }
.btn-secondary:hover { background: var(--gray-bg); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-sm       { padding: 6px 12px; font-size: 12px; }
.btn-block    { width: 100%; }

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--gray-border);
    color: var(--text-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .1s, background .15s;
}
.btn-icon:active { transform: scale(.88); }

/* Notification dot on bell icon */
.btn-icon .dot {
    position: absolute;
    top: 5px; right: 5px;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--surface);
    display: none;
}
.btn-icon .dot.show { display: block; }
[data-theme="dark"] .btn-icon .dot { border-color: var(--surface); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-dark); }
label .req { color: var(--danger); }

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: var(--surface);
    color: var(--text-dark);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px var(--emerald-light);
}
textarea { resize: vertical; min-height: 70px; }

.checkbox-row { display: flex; align-items: flex-start; gap: 8px; }
.checkbox-row input { width: auto; margin-top: 3px; }
.checkbox-row label { font-weight: 400; font-size: 13px; margin: 0; }

fieldset { border: 1px solid var(--gray-border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
fieldset legend { font-size: 13px; font-weight: 700; color: var(--emerald-dark); padding: 0 6px; }

/* ============================================================
   AUTH LAYOUT (login / registration pages)
   ============================================================ */
.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #f3f4f6 0%, #e7f7ef 100%);
}
.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,.06);
    width: 100%;
    max-width: 480px;
    padding: 36px;
}
.auth-card.wide { max-width: 760px; }

.brand-header { text-align: center; margin-bottom: 28px; }
.brand-header .logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin: 0 auto 12px;
}
.brand-header .badge {
    display: inline-block;
    background: var(--emerald-light);
    color: var(--emerald-dark);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 100px;
    margin-bottom: 10px;
}
.brand-header h1 { font-size: 22px; font-weight: 800; margin: 4px 0; }
.brand-header p { color: var(--text-muted); font-size: 14px; margin: 0; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px 20px;
    border: 1px solid var(--gray-border);
    cursor: pointer;
    transition: transform .1s, background .2s;
}
.stat-card:active { transform: scale(.97); }
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat-card.accent .value { color: var(--emerald); }

/* ============================================================
   CARDS & TABLES
   ============================================================ */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--gray-border);
    padding: 22px;
    margin-bottom: 20px;
    transition: background .2s;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.card-header h2 { font-size: 16px; font-weight: 700; margin: 0; }

.charts-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 18px; margin-bottom: 18px; }
.chart-card canvas { max-height: 280px; max-width: 100%; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    white-space: nowrap;
}
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-border); }
table.data-table tr:hover td { background: var(--surface-2); }

.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-paid      { background: #d1fae5; color: #065f46; }
.badge-part-paid { background: #fef3c7; color: #92400e; }
.badge-unpaid    { background: #fee2e2; color: #991b1b; }

.progress-bar { background: var(--gray-border); border-radius: 100px; height: 8px; overflow: hidden; }
.progress-bar > div { background: var(--emerald); height: 100%; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; min-width: 160px; }

/* ============================================================
   ALERTS & TOASTS
   ============================================================ */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: none; }
.alert.show { display: block; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error   { background: #fee2e2; color: #991b1b; }

#toast-container {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: calc(100vw - 40px);
}
.toast {
    background: #1f2937;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 6px 20px rgba(0,0,0,.15);
    min-width: 220px;
    pointer-events: auto;
    animation: toast-in .2s ease;
}
.toast.success { background: var(--emerald-dark); }
.toast.error   { background: var(--danger); }
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   DASHBOARD-SPECIFIC: ACTIVITY FEED & OCCUPANCY
   ============================================================ */
.activity-feed { display: flex; flex-direction: column; }
.activity-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-border);
    transition: transform .1s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item .icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: #ecfdf5; color: #059669;
    font-size: 16px;
}
.activity-item .icon.reg { background: #eff6ff; color: #2563eb; }
.activity-item .text  { font-size: 13px; color: var(--text-dark); }
.activity-item .time  { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.activity-item.is-new .icon { animation: pulseNew 1.4s ease 2; }
@keyframes pulseNew {
    0%   { box-shadow: 0 0 0 0 rgba(5,150,105,.5); }
    100% { box-shadow: 0 0 0 9px rgba(5,150,105,0); }
}

.occupancy-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.occupancy-row .room-name { width: 120px; font-size: 13px; color: var(--text-dark); flex-shrink: 0; }
.occupancy-row .bar-track { flex: 1; height: 10px; background: var(--gray-border); border-radius: 6px; overflow: hidden; }
.occupancy-row .bar-fill  { height: 100%; background: #059669; border-radius: 6px; transition: width .8s ease; }
.occupancy-row .bar-fill.full { background: var(--danger); }
.occupancy-row .count     { width: 54px; text-align: right; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }

/* ============================================================
   SKELETON LOADER
   ============================================================ */
.skeleton {
    background: linear-gradient(90deg, var(--gray-border) 25%, #e5e7eb 37%, var(--gray-border) 63%);
    background-size: 400% 100%;
    animation: skeletonShine 1.4s ease infinite;
    border-radius: 8px;
}
@keyframes skeletonShine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ============================================================
   MOBILE: STAT CAROUSEL
   ============================================================ */
.stat-carousel-wrap { display: none; }
.stat-carousel {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.stat-carousel::-webkit-scrollbar { display: none; }
.stat-carousel .stat-card { min-width: 78%; scroll-snap-align: start; }
.carousel-dots { display: flex; justify-content: center; gap: 6px; margin: 8px 0 18px; }
.carousel-dots .dot-i { width: 6px; height: 6px; border-radius: 50%; background: var(--gray-border); transition: background .15s, width .15s; }
.carousel-dots .dot-i.active { background: var(--emerald); width: 16px; border-radius: 3px; }

/* ============================================================
   MOBILE: BOTTOM NAV
   ============================================================ */
.bottom-nav { display: none; }
.bottom-nav-inner { display: flex; justify-content: space-around; }
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    transition: transform .1s, color .15s;
}
.bottom-nav a i { font-size: 21px; }
.bottom-nav a.active { color: var(--emerald-dark); }
.bottom-nav a:active { transform: scale(.9); }

/* ============================================================
   MOBILE: FAB + BOTTOM SHEET
   ============================================================ */
.fab { display: none; }

.sheet-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 150;
}
.sheet-backdrop.show { display: block; }

.bottom-sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 151;
    background: var(--surface);
    border-radius: 18px 18px 0 0;
    padding: 8px 18px calc(20px + env(safe-area-inset-bottom, 0));
    transform: translateY(100%);
    transition: transform .25s ease-out;
    box-shadow: 0 -10px 30px rgba(0,0,0,.15);
    max-height: 85dvh;
    overflow-y: auto;
}
.bottom-sheet.show { transform: translateY(0); }
.bottom-sheet .grabber { width: 36px; height: 4px; background: var(--gray-border); border-radius: 4px; margin: 8px auto 14px; }
.bottom-sheet .sheet-title { font-weight: 700; font-size: 15px; margin-bottom: 12px; }

.sheet-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 4px;
    font-size: 14px; font-weight: 600;
    color: var(--text-dark);
    border: none;
    border-bottom: 1px solid var(--gray-border);
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background .1s;
}
.sheet-action:last-child { border-bottom: none; }
.sheet-action i { font-size: 19px; color: var(--emerald); width: 22px; text-align: center; }
.sheet-action:active { background: var(--gray-bg); }

/* ============================================================
   MOBILE: PULL-TO-REFRESH
   ============================================================ */
.ptr-indicator {
    position: fixed; top: 0; left: 50%;
    transform: translate(-50%, -60px);
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--emerald); color: #fff;
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    box-shadow: 0 4px 14px rgba(0,0,0,.15);
    transition: transform .15s ease-out;
}
.ptr-indicator.pulling { transition: none; }
.ptr-indicator i { font-size: 18px; }
.ptr-indicator.spin i { animation: ptrSpin .7s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVE BREAKPOINTS — TABLET (769px–1024px)
   Keep the sidebar, but narrow it and tighten spacing so nothing
   feels cramped on iPad-class devices before hitting phone layout.
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    :root { --sidebar-w: 76px; }
    .sidebar nav a span.label,
    .sidebar nav a { justify-content: center; text-align: center; }
    .sidebar .brand { padding: 4px 8px 16px; font-size: 0; }
    .sidebar .brand-logo { width: 40px; height: 40px; }
    .sidebar nav a { flex-direction: column; gap: 4px; font-size: 10.5px; padding: 10px 6px; }
    .main-content { padding: 22px 20px; }
    .charts-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS — PHONE (≤768px)
   ============================================================ */
@media (max-width: 768px) {
    /* Layout */
    .app-shell  { display: block !important; }
    .sidebar    { display: none !important; }
    .main-content {
        padding: 16px 16px 90px !important;
        max-width: 100% !important;
    }

    /* Prevent iOS zoom-on-focus: inputs need ≥16px font-size */
    input, select, textarea { font-size: 16px !important; }

    /* Stat grid → carousel swap */
    .stat-grid         { display: none !important; }
    .stat-carousel-wrap { display: block !important; }

    /* Charts stack vertically */
    .charts-grid       { display: block !important; }
    .charts-grid > .card { margin-bottom: 18px; }

    /* Topbar */
    .topbar { flex-wrap: nowrap !important; align-items: center !important; }
    .topbar h1 { font-size: 18px !important; }
    .topbar .subtitle { font-size: 11px !important; }
    .topbar-actions .btn-secondary { display: none !important; }
    .btn-icon { width: 36px; height: 36px; font-size: 16px; }

    /* Bottom nav */
    .bottom-nav {
        display: block !important;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
        background: var(--surface);
        border-top: 1px solid var(--gray-border);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
        box-shadow: 0 -4px 16px rgba(0,0,0,.06);
    }

    /* FAB */
    .fab {
        display: flex !important;
        align-items: center; justify-content: center;
        position: fixed;
        right: 18px;
        bottom: calc(76px + env(safe-area-inset-bottom, 0));
        width: 56px; height: 56px;
        border-radius: 50%;
        background: var(--emerald); color: #fff; border: none;
        font-size: 24px;
        box-shadow: 0 6px 18px rgba(5,150,105,.4);
        z-index: 110;
        transition: transform .15s;
    }
    .fab:active { transform: scale(.9) rotate(90deg); }

    /* Forms */
    .form-row { flex-direction: column; }

    .auth-card { padding: 26px 22px; }
    .brand-header .logo { width: 52px; height: 52px; }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS — SMALL PHONE (≤380px)
   ============================================================ */
@media (max-width: 380px) {
    .main-content { padding: 12px 12px 86px !important; }
    .topbar h1 { font-size: 16.5px !important; }
    .stat-carousel .stat-card { min-width: 86%; padding: 15px 16px; }
    .card { padding: 16px; }
    .btn { padding: 10px 14px; font-size: 13px; }
    .auth-card { padding: 20px 16px; }
    .brand-header .logo { width: 46px; height: 46px; }
}

/* ============================================================
   LANDSCAPE PHONES (short viewport height)
   ============================================================ */
@media (max-height: 480px) and (orientation: landscape) {
    .bottom-nav a { padding: 4px 0; font-size: 10px; }
    .bottom-nav a i { font-size: 18px; }
    .fab { width: 48px; height: 48px; font-size: 20px; bottom: calc(58px + env(safe-area-inset-bottom, 0)); }
    .auth-shell { padding: 14px; }
    .auth-card { padding: 20px; }
}

/* ============================================================
   LARGE DESKTOP: keep content from stretching too wide
   ============================================================ */
@media (min-width: 1600px) {
    .main-content { padding: 32px 48px; }
}