/* ==========================================================================
   GREEN LOGISTIC - ADMIN PANEL STYLES
   --------------------------------------------------------------------------
   Loaded after style.css (colours, buttons, form fields, badges, toasts).
   This file only styles the admin pages.

   Approach: MOBILE FIRST.
   - Phones:   sidebar is a slide-in drawer, tables become stacked cards.
   - 768px+:   tables show as normal tables.
   - 1024px+:  sidebar is always visible on the left.

   Table of contents
     1.  Page basics
     2.  Layout shell (sidebar + main area)
     3.  Sidebar
     4.  Top bar
     5.  Page heading and panels
     6.  Dashboard stat cards
     7.  Tables (and their phone "card" version)
     8.  Toolbar and search
     9.  Forms inside admin
     10. Pricing preview
     11. Empty states
     12. Alerts
     13. Login page
   ========================================================================== */


/* ==========================================================================
   1. PAGE BASICS
   ========================================================================== */
body.admin {
    background: var(--paper);
}

/* Inline text link */
.link {
    color: var(--green-700);
    font-weight: 600;
}
.link:hover {
    text-decoration: underline;
}

/* Small square icon button (menu / close) */
.icon-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--ink);
}
.icon-btn .icon {
    width: 22px;
    height: 22px;
}


/* ==========================================================================
   2. LAYOUT SHELL
   ========================================================================== */
.admin-shell {
    min-height: 100vh;
}

.admin-main {
    min-width: 0;                /* lets wide tables scroll instead of stretching the page */
}

.admin-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem var(--gutter) 3rem;
}

@media (min-width: 1024px) {
    .admin-shell {
        display: grid;
        grid-template-columns: 264px 1fr;
    }
    .admin-content {
        padding: 2rem 2.5rem 4rem;
    }
}


/* ==========================================================================
   3. SIDEBAR
   Phones: hidden off-screen, slides in when admin.js adds .is-sidebar-open
   to the shell. Desktop: always visible and fixed.
   ========================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    width: min(290px, 86vw);
    display: flex;
    flex-direction: column;
    padding: 1rem 0.9rem;
    background: var(--green-950);
    color: #c9ddd1;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    overflow-y: auto;
}

.is-sidebar-open .sidebar {
    transform: translateX(0);
}

.sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.5rem 1.25rem;
}

/* Close button only matters on phones */
.sidebar__close {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar__nav {
    display: grid;
    gap: 4px;
    align-content: start;
    flex: 1;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 46px;                       /* big enough for thumbs */
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    color: #c9ddd1;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.sidebar__link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}
/* Current page */
.sidebar__link.is-active {
    background: var(--green-600);
    color: #fff;
}

.sidebar__foot {
    display: grid;
    gap: 4px;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* Dark overlay behind the open drawer (phones) */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(6, 36, 26, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.is-sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 1024px) {
    /* Desktop: sidebar is part of the layout, no drawer behaviour */
    .sidebar {
        transform: none;
        transition: none;
        width: auto;
        padding: 1.25rem 1rem;
        /* sticky keeps it in view while the page scrolls */
        position: sticky;
        top: 0;
        height: 100vh;
    }
    .sidebar__close,
    .sidebar-backdrop {
        display: none;
    }
}


/* ==========================================================================
   4. TOP BAR
   ========================================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 62px;
    padding: 0 var(--gutter);
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar__title {
    margin-right: auto;
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
}

@media (max-width: 479px) {
    /* On very small phones show just the icon for "View site" */
    .topbar__link-text {
        display: none;
    }
}

@media (min-width: 1024px) {
    .topbar {
        padding: 0 2.5rem;
    }
    .topbar__menu {
        display: none;
    }
}


/* ==========================================================================
   5. PAGE HEADING AND PANELS
   ========================================================================== */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-head__title {
    font-size: clamp(1.625rem, 5vw, 2.25rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.page-head__sub {
    margin-top: 0.35rem;
    color: var(--muted);
}

.panel {
    margin-bottom: 1.25rem;
    padding: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.panel--tint {
    background: var(--green-50);
    border-color: var(--green-100);
}

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

.panel__title {
    margin-bottom: 1rem;
    font-size: 1.1875rem;
    font-weight: 700;
}
.panel__head .panel__title {
    margin-bottom: 0;
}

.panel__link {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--green-700);
}
.panel__link:hover {
    text-decoration: underline;
}

.panel__text {
    margin: -0.5rem 0 1.25rem;
    color: var(--muted);
    font-size: 0.9375rem;
}

/* Two panels side by side on larger screens */
.grid-2 {
    display: grid;
    gap: 1.25rem;
    align-items: start;
}
.grid-2 > .panel {
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .panel {
        padding: 1.5rem;
    }
    .grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}


/* ==========================================================================
   6. DASHBOARD STAT CARDS
   ========================================================================== */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);      /* 2 per row on phones */
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat {
    display: grid;
    gap: 0.15rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s var(--ease), border-color 0.18s var(--ease);
}
.stat:hover {
    border-color: var(--green-400);
    transform: translateY(-2px);
}

.stat__icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--green-50);
    color: var(--green-600);
}

.stat__value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
}

.stat__label {
    font-size: 0.875rem;
    color: var(--muted);
}

/* "Pending" turns amber when there is something waiting for review */
.stat--alert {
    background: var(--warn-bg);
    border-color: #f0d79a;
}
.stat--alert .stat__icon {
    background: #fff;
    color: var(--warn-text);
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
    .stats {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1100px) {
    .stats {
        grid-template-columns: repeat(5, 1fr);
    }
}


/* ==========================================================================
   7. TABLES
   Phones: every row becomes a stacked "card". Each cell shows its column
   name using the data-label attribute set in the template.
   768px+: a normal table.
   ========================================================================== */
.table-wrap {
    overflow-x: auto;
}

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

/* ----- Phone layout (default) ----- */
.data-table thead {
    /* Hidden visually but kept for screen readers */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.data-table,
.data-table tbody {
    display: block;
}

.data-table tr {
    display: block;
    margin-bottom: 0.85rem;
    padding: 0.4rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.data-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--paper);
    text-align: right;
}
.data-table td:last-child {
    border-bottom: 0;
}

/* Column name shown before each value */
.data-table td::before {
    content: attr(data-label);
    flex: none;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    text-align: left;
}

/* The main cell (name) is the card title: full width, no label */
.data-table td.cell-main {
    display: block;
    padding-top: 0.75rem;
    font-size: 1.0625rem;
    font-weight: 700;
    text-align: left;
}
.data-table td.cell-main::before {
    display: none;
}

/* Action buttons sit on their own row below the details */
.data-table td.cell-actions {
    display: block;
    padding-bottom: 0.75rem;
    text-align: left;
}
.data-table td.cell-actions::before {
    display: none;
}

/* Empty message row */
.data-table tr.empty-row {
    border: 0;
    padding: 0;
    background: none;
}
.data-table tr.empty-row td {
    display: block;
    border: 0;
    padding: 0;
}
.data-table tr.empty-row td::before {
    display: none;
}

/* Second line of text inside a cell (model, phone number, etc.) */
.cell-sub {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.2rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
}
.cell-sub.link {
    color: var(--green-700);
    font-weight: 600;
}
.cell-sub .icon {
    width: 0.95rem;
    height: 0.95rem;
}

/* Keeps a value and its second line together inside one table cell */
.cell-stack {
    display: block;
    min-width: 0;
}
@media (max-width: 767px) {
    /* Phone cards: values sit on the right, so align this text there too */
    .cell-stack {
        text-align: right;
    }
    .cell-stack .cell-sub {
        justify-content: flex-end;
    }
}

/* Row of buttons (Edit / Deactivate / Delete) */
.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.row-actions form {
    margin: 0;
}

/* Status dropdown + Save button side by side */
.status-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.status-form .field__control {
    flex: 1;
}

/* Smaller form control used inside tables */
.field__control--sm {
    min-height: 38px;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    font-size: 0.9375rem;
    border-radius: var(--radius-sm);
}

/* Expandable extra details */
.more {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}
.more summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--green-700);
}
.more dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.9rem;
    margin: 0.6rem 0 0;
    padding: 0.75rem;
    background: var(--paper);
    border-radius: var(--radius-sm);
    font-weight: 400;
}
.more dt {
    color: var(--muted);
}
.more dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* ----- Table layout (tablets and up) ----- */
@media (min-width: 768px) {
    .data-table {
        display: table;
    }
    .data-table thead {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip: auto;
        display: table-header-group;
    }
    .data-table tbody {
        display: table-row-group;
    }
    .data-table tr {
        display: table-row;
        margin: 0;
        padding: 0;
        background: none;
        border: 0;
        border-radius: 0;
    }
    .data-table th,
    .data-table td {
        display: table-cell;
        padding: 0.9rem 0.75rem;
        text-align: left;
        vertical-align: top;
        border-bottom: 1px solid var(--line);
    }
    .data-table td:last-child {
        border-bottom: 1px solid var(--line);
    }
    .data-table td::before {
        display: none;
    }
    .data-table td.cell-main,
    .data-table td.cell-actions {
        display: table-cell;
        padding-top: 0.9rem;
        padding-bottom: 0.9rem;
        font-size: inherit;
    }
    .data-table td.cell-main {
        font-weight: 700;
    }
    .data-table tbody tr:hover td {
        background: var(--paper);
    }
    .data-table tr.empty-row:hover td {
        background: none;
    }

    .data-table th {
        font-size: 0.8125rem;
        font-weight: 700;
        color: var(--muted);
        text-align: left;
        background: var(--paper);
        border-bottom: 1px solid var(--line);
    }
    .data-table th:first-child {
        border-top-left-radius: var(--radius-sm);
    }
    .data-table th:last-child {
        border-top-right-radius: var(--radius-sm);
    }

    .status-form {
        min-width: 210px;
    }
}


/* ==========================================================================
   8. TOOLBAR AND SEARCH
   ========================================================================== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search {
    position: relative;
    flex: 1 1 260px;
    display: block;
}
.search .icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.search__input {
    width: 100%;
    min-height: 46px;
    padding: 0.6rem 0.9rem 0.6rem 2.6rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    font-size: 1rem;
}
.search__input:focus {
    outline: none;
    background: #fff;
    border-color: var(--green-600);
    box-shadow: 0 0 0 4px rgba(31, 122, 77, 0.16);
}

.toolbar__count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
}

/* Shown by admin.js when a search finds nothing */
.no-match {
    padding: 1.5rem 0;
    text-align: center;
    color: var(--muted);
}


/* ==========================================================================
   9. FORMS INSIDE ADMIN
   ========================================================================== */
/* Three columns on desktop for the longer vehicle / area forms */
@media (min-width: 1024px) {
    .form-grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}


/* ==========================================================================
   10. PRICING PREVIEW
   ========================================================================== */
.preview-result {
    display: grid;
    gap: 0.25rem;
    padding: 1.25rem;
    background: #fff;
    border: 1px solid var(--green-200);
    border-radius: var(--radius-md);
    text-align: center;
}
.preview-result__label {
    font-size: 0.875rem;
    color: var(--muted);
}
.preview-result__value {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--green-700);
}


/* ==========================================================================
   11. EMPTY STATES
   ========================================================================== */
.empty-state {
    display: grid;
    justify-items: center;
    gap: 0.6rem;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
}
.empty-state .icon {
    width: 40px;
    height: 40px;
    padding: 9px;
    border-radius: 50%;
    background: var(--green-50);
    color: var(--green-600);
}
.empty-state p {
    max-width: 30ch;
    text-align: center;
}


/* ==========================================================================
   12. ALERTS (used on the login page)
   ========================================================================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    padding: 0.8rem 0.9rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    background: var(--green-50);
    color: var(--green-800);
}
.alert .icon {
    margin-top: 0.1rem;
}
.alert--error {
    background: var(--danger-bg);
    color: var(--danger-text);
}


/* ==========================================================================
   13. LOGIN PAGE
   Phones: just the form card on a green background.
   Desktop: brand panel on the left, form on the right.
   ========================================================================== */
.login {
    min-height: 100vh;
    display: grid;
}

/* Brand panel is hidden on phones */
.login__brand {
    display: none;
}

.login__panel {
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background:
        radial-gradient(70% 50% at 100% 0%, rgba(200, 242, 90, 0.18), transparent 70%),
        var(--green-900);
}

.login__card {
    width: 100%;
    max-width: 420px;
    padding: 1.75rem 1.5rem;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.login__logo {
    margin-bottom: 1.5rem;
}

.login__card h1 {
    font-size: 1.75rem;
    font-weight: 800;
}

.login__sub {
    margin: 0.4rem 0 1.5rem;
    color: var(--muted);
}

.login__back {
    display: block;
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--muted);
}
.login__back:hover {
    color: var(--green-700);
}

/* Password field with a show / hide button inside it */
.password-wrap {
    position: relative;
    display: block;
}
.password-wrap .field__control {
    padding-right: 3rem;
}
.password-wrap__toggle {
    position: absolute;
    top: 50%;
    right: 0.4rem;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--muted);
}
.password-wrap__toggle:hover {
    color: var(--green-700);
}

@media (min-width: 900px) {
    .login {
        grid-template-columns: 1.1fr 1fr;
    }

    .login__brand {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 3rem;
        color: #fff;
        background:
            radial-gradient(60% 50% at 20% 100%, rgba(42, 148, 97, 0.45), transparent 70%),
            var(--green-950);
    }
    .login__brand h2 {
        max-width: 14ch;
        font-size: 3rem;
        font-weight: 800;
        line-height: 1.05;
        letter-spacing: -0.03em;
    }
    .login__brand p {
        max-width: 34ch;
        margin-top: 1rem;
        font-size: 1.0625rem;
        color: #b6d3c3;
    }

    .login__panel {
        background: var(--paper);
    }
    .login__card {
        padding: 2.5rem;
        background: transparent;
        box-shadow: none;
    }
    /* The logo is already in the brand panel on desktop */
    .login__logo {
        display: none;
    }
}
