/* =====================================================================
   ADT GPS TRACKER  |  adt-core.css
   The shared foundation. Loaded on every redesigned page.

   Tokens are taken from profile.php, which was the most mature page in
   the project, so the rest of the site now matches the dashboard rather
   than the other way round.

   Dark mode responds to EITHER html.dark-mode or body.dark-mode, so a
   page that has not been migrated yet keeps working during the change.

   Nothing here is page specific. Layout for each zone lives in
   adt-public.css, adt-user.css, adt-admin.css.
   ===================================================================== */


/* =====================================================================
   1. TOKENS
   ===================================================================== */

:root {
    /* brand */
    --primary:        #4361ee;
    --primary-dark:   #3a0ca3;
    --primary-soft:   rgba(67, 97, 238, 0.10);
    --secondary:      #7209b7;

    /* status */
    --success:        #4cc9f0;
    --danger:         #f72585;
    --warning:        #f8961e;
    --info:           #4895ef;

    /* status text — darker variants, readable on a light background.
       The brand cyan is too pale for body text on white.            */
    --success-ink:    #047857;
    --danger-ink:     #be123c;
    --warning-ink:    #b45309;
    --info-ink:       #1d4ed8;

    /* surfaces */
    --bg:             #f5f7ff;
    --surface:        #ffffff;
    --surface-2:      #ffffff;
    --surface-alt:    #f0f4ff;

    /* text */
    --text:           #212529;
    --muted:          #6c757d;

    /* lines and depth */
    --border:         rgba(0, 0, 0, 0.09);
    --border-strong:  rgba(0, 0, 0, 0.20);
    --shadow-sm:      0 1px 3px rgba(16, 24, 40, 0.06);
    --shadow:         0 4px 12px rgba(16, 24, 40, 0.08);
    --shadow-lg:      0 12px 28px rgba(16, 24, 40, 0.12);

    /* shape */
    --radius-sm:      8px;
    --radius:         12px;
    --radius-lg:      16px;
    --radius-pill:    999px;

    /* rhythm */
    --gap-xs:         .4rem;
    --gap-sm:         .75rem;
    --gap:            1.25rem;
    --gap-lg:         2rem;

    /* layout */
    --header-height:  70px;
    --sidebar-width:  280px;
    --content-max:    1200px;

    /* type */
    --font: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, system-ui, sans-serif;
}

/* --- dark theme -------------------------------------------------- */
html.dark-mode,
body.dark-mode {
    --primary-soft:   rgba(124, 157, 255, 0.14);

    --success-ink:    #4cc9f0;
    --danger-ink:     #f72585;
    --warning-ink:    #f8961e;
    --info-ink:       #7c9dff;

    --bg:             #0f1117;
    --surface:        #1e2130;
    --surface-2:      #1a1d27;
    --surface-alt:    #252a3a;

    --text:           #e2e8f0;
    --muted:          #94a3b8;

    --border:         rgba(255, 255, 255, 0.08);
    --border-strong:  rgba(255, 255, 255, 0.22);
    --shadow-sm:      0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow:         0 4px 14px rgba(0, 0, 0, 0.40);
    --shadow-lg:      0 12px 30px rgba(0, 0, 0, 0.50);

    color-scheme: dark;
}

/* link colour lifts in dark mode so it stays readable */
html.dark-mode a,
body.dark-mode a { color: #7c9dff; }


/* =====================================================================
   2. RESET AND BASE
   ===================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
    min-height: 100vh;
    transition: background-color .25s ease, color .25s ease;
}

img, svg { max-width: 100%; display: block; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }

/* keyboard users must always see where they are */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* respect the visitor's motion setting */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}


/* =====================================================================
   3. LAYOUT
   ===================================================================== */

/* .container means PAGE WRAPPER and nothing else.
   The flex row inside a header is .nav-inner.        */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 1rem;
}

.nav-inner {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: .85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-sm);
}

.stack   { display: flex; flex-direction: column; gap: var(--gap); }
.row     { display: flex; align-items: center; gap: var(--gap-sm); flex-wrap: wrap; }
.spacer  { flex: 1 1 auto; }

@media (min-width: 768px) {
    .container  { padding: 0 2rem; }
    .nav-inner  { padding: .85rem 2rem; }
    body        { font-size: 16px; }
    h1          { font-size: 2.4rem; }
}


/* =====================================================================
   4. SITE HEADER
   ===================================================================== */

.site-header {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

#branding h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}
#branding h1 a { color: inherit; text-decoration: none; }
#branding h1 i { margin-right: .35rem; }

.site-header ul {
    display: flex;
    list-style: none;
    align-items: center;
    gap: 1.1rem;
}

.site-header ul li a {
    color: var(--text);
    font-weight: 500;
    font-size: .93rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem 0;
    text-decoration: none;
    transition: color .2s;
}
.site-header ul li a:hover { color: var(--primary); text-decoration: none; }

@media (min-width: 768px) {
    #branding h1 { font-size: 1.5rem; }
}

/* on narrow screens the nav wraps under the logo instead of squashing */
@media (max-width: 600px) {
    .nav-inner { flex-wrap: wrap; justify-content: center; }
    .site-header ul { gap: .9rem; flex-wrap: wrap; justify-content: center; }
    .site-header ul li a span.label { display: none; }
}


/* =====================================================================
   5. BUTTONS
   ===================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .75rem 1.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color .2s, border-color .2s, color .2s,
                transform .15s, box-shadow .2s;
}
.btn:hover { text-decoration: none; }

.btn:disabled,
.btn.is-disabled {
    background: var(--muted);
    border-color: var(--muted);
    color: #fff;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: .7;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-outline {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
}

.btn-danger  { background: var(--danger);  border-color: var(--danger);  color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #05323d; }
.btn-ghost   { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-alt);
    border-color: var(--text);
    transform: translateY(-2px);
}

.btn-sm    { padding: .45rem .85rem; font-size: .85rem; }
.btn-block { width: 100%; }

html.dark-mode .btn-outline,
body.dark-mode .btn-outline { border-color: #7c9dff; color: #7c9dff; }
html.dark-mode .btn-outline:hover:not(:disabled),
body.dark-mode .btn-outline:hover:not(:disabled) { background: #7c9dff; color: #0f1117; }


/* =====================================================================
   6. FORMS
   ===================================================================== */

.form-group { margin-bottom: var(--gap); }

.form-group label {
    display: block;
    margin-bottom: .45rem;
    font-weight: 500;
    font-size: .92rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: .75rem .9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.form-control::placeholder { color: var(--muted); opacity: .8; }
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-control:disabled,
.form-control[readonly] { background: var(--surface-alt); cursor: not-allowed; }

select.form-control { appearance: none; padding-right: 2.2rem; }

.hint { font-size: .8rem; color: var(--muted); margin-top: .35rem; }

.password-container { position: relative; }
.password-toggle {
    position: absolute;
    right: .8rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--muted);
    padding: .25rem;
}
.password-toggle:hover { color: var(--primary); }

/* a 6 digit OTP box */
.otp-input {
    text-align: center;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: .55rem;
    padding-left: 1.1rem;
    font-variant-numeric: tabular-nums;
}


/* =====================================================================
   7. ALERTS
   ===================================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .9rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    margin-bottom: var(--gap);
    font-size: .92rem;
    line-height: 1.5;
}
.alert i { margin-top: .15rem; flex-shrink: 0; }
.alert a { font-weight: 600; text-decoration: underline; }

.alert-error,
.alert-danger {
    background: rgba(247, 37, 133, .10);
    border-color: rgba(247, 37, 133, .30);
    color: var(--danger-ink);
}
.alert-success {
    background: rgba(16, 185, 129, .10);
    border-color: rgba(16, 185, 129, .30);
    color: var(--success-ink);
}
.alert-warning {
    background: rgba(248, 150, 30, .12);
    border-color: rgba(248, 150, 30, .32);
    color: var(--warning-ink);
}
.alert-info {
    background: rgba(72, 149, 239, .10);
    border-color: rgba(72, 149, 239, .30);
    color: var(--info-ink);
}

html.dark-mode .alert-success,
body.dark-mode .alert-success {
    background: rgba(76, 201, 240, .10);
    border-color: rgba(76, 201, 240, .30);
}


/* =====================================================================
   8. CARDS
   ===================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-sm);
    margin-bottom: var(--gap);
    flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }

/* stat tile — same class name admin_dashboard.php already uses */
.stats-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    transition: transform .2s, box-shadow .2s;
}
.stats-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.stats-card .card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    background: var(--primary-soft);
    color: var(--primary);
    margin-bottom: .35rem;
}
.stats-card .card-title {
    font-size: .82rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.stats-card .card-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stats-card .card-note { font-size: .82rem; color: var(--muted); }

/* colour accents for a tile that needs attention */
.stats-card.is-warning .card-icon { background: rgba(248,150,30,.14); color: var(--warning-ink); }
.stats-card.is-danger  .card-icon { background: rgba(247, 37,133,.12); color: var(--danger-ink); }
.stats-card.is-success .card-icon { background: rgba( 16,185,129,.12); color: var(--success-ink); }

.stats-cards,
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--gap);
}


/* =====================================================================
   9. BADGES
   ===================================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .22rem .7rem;
    border-radius: var(--radius-pill);
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.status-badge.active   { background: rgba( 16,185,129,.13); color: var(--success-ink); }
.status-badge.inactive { background: rgba(108,117,125,.15); color: var(--muted); }
.status-badge.warning  { background: rgba(248,150,30,.15);  color: var(--warning-ink); }
.status-badge.danger   { background: rgba(247, 37,133,.12); color: var(--danger-ink); }


/* =====================================================================
   10. TABLES

   Two mobile strategies:
     .table-wrap    wrap a table to get horizontal scrolling  (default)
     .table-stack   each row becomes a card on phones; needs
                    data-label="..." on every <td>
   ===================================================================== */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

thead th {
    text-align: left;
    padding: .8rem 1rem;
    background: var(--surface-alt);
    color: var(--muted);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: var(--surface-alt); }

.table-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--muted);
}

@media (max-width: 700px) {
    .table-stack thead { display: none; }
    .table-stack tbody tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: var(--gap-sm);
        padding: .35rem .25rem;
    }
    .table-stack tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: .5rem .85rem;
        border-bottom: 1px dashed var(--border);
        text-align: right;
    }
    .table-stack tbody tr td:last-child { border-bottom: none; }
    .table-stack tbody td::before {
        content: attr(data-label);
        font-size: .78rem;
        font-weight: 600;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: .03em;
        text-align: left;
        flex-shrink: 0;
    }
}


/* =====================================================================
   11. DARK MODE TOGGLE
   ===================================================================== */

.dark-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.dark-toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #cdd5e0;
    border-radius: 24px;
    cursor: pointer;
    transition: background .3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .3s;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

html.dark-mode .toggle-slider,
body.dark-mode .toggle-slider { background: #3a4060; }
html.dark-mode .toggle-slider::before,
body.dark-mode .toggle-slider::before { background: #e2e8f0; }


/* =====================================================================
   12. FOOTER
   ===================================================================== */

.site-footer {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    color: var(--muted);
    text-align: center;
    padding: 1.75rem 1rem;
    margin-top: 3.5rem;
    font-size: .88rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--primary); }


/* =====================================================================
   13. SMALL UTILITIES
   ===================================================================== */

.text-muted   { color: var(--muted); }
.text-center  { text-align: center; }
.text-danger  { color: var(--danger-ink); }
.text-success { color: var(--success-ink); }
.text-nowrap  { white-space: nowrap; }
.fw-600       { font-weight: 600; }
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.75rem; }
.mb-0  { margin-bottom: 0; }
.mb-2  { margin-bottom: 1rem; }
.hide  { display: none !important; }

/* readable only by screen readers */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}