/*
 * Sanctum-style shell for Kitchen POS admin and partner UIs.
 *
 * Mirrors the design layer used by Sanctum Tasks (public/assets/admin.css)
 * and Sanctum CRM (public/includes/layout.php) so the DSC product suite
 * shares one visual vocabulary: light app body, dark navbar, surfaces,
 * page headers, status pills, and structured tables.
 *
 * This file is opt-in. Pages activate it by adding the class
 *   `sanctum-shell` to <body>.
 * Without that class the existing dark-theme styles in style.css /
 * admin-bootstrap.css continue to apply unchanged. That lets us migrate
 * the product page-by-page.
 *
 * Token names mirror Tasks (`--st-*`) so future shared component CSS can
 * be lifted across products without renaming.
 */

/* ===== Tokens =================================================== */

body.sanctum-shell {
    --st-bg-app: #f4f6fa;
    --st-bg-surface: #ffffff;
    --st-bg-soft: #f8f9fc;
    --st-bg-elevated: #ffffff;

    --st-border-subtle: #e4e7ee;
    --st-border-strong: #cfd4de;

    --st-text-primary: #14161a;
    --st-text-secondary: #4a5260;
    --st-text-muted: #8a93a3;

    --st-accent: #2c5cff;
    --st-accent-soft: #e9efff;
    --st-accent-hover: #1f47cc;

    --st-shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.04);
    --st-shadow-md: 0 4px 12px rgba(20, 22, 26, 0.06);

    --st-radius: 10px;
    --st-radius-sm: 6px;

    --st-gap-section: 1.5rem;
    --st-gap-stack: 0.85rem;
    --st-pad-card-y: 0.78rem;
    --st-pad-card-x: 0.92rem;

    --st-status-todo: #4a5260;
    --st-status-todo-soft: #eef0f4;
    --st-status-doing: #b45309;
    --st-status-doing-soft: #fef4d6;
    --st-status-done: #15803d;
    --st-status-done-soft: #dcfce7;
    --st-status-blocked: #b91c1c;
    --st-status-blocked-soft: #fee2e2;

    --st-pri-low: #6b7280;
    --st-pri-low-soft: #eef0f3;
    --st-pri-normal: #2c5cff;
    --st-pri-normal-soft: #e9efff;
    --st-pri-high: #b45309;
    --st-pri-high-soft: #fef4d6;
    --st-pri-urgent: #b91c1c;
    --st-pri-urgent-soft: #fee2e2;
}

/* Force the light app surface even if Bootstrap's bg-light hasn't been set. */
body.sanctum-shell {
    background-color: var(--st-bg-app);
    color: var(--st-text-primary);
}

/* ===== Top navbar =============================================== */

body.sanctum-shell .admin-nav {
    box-shadow: var(--st-shadow-sm);
}
body.sanctum-shell .admin-nav .navbar-brand {
    letter-spacing: -0.01em;
}
body.sanctum-shell .admin-nav .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.25);
    font-weight: 500;
}
body.sanctum-shell .admin-nav .btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}
body.sanctum-shell .admin-nav .navbar-text {
    font-size: 0.85rem;
}
body.sanctum-shell .admin-shell {
    max-width: 1400px;
}

/* ===== Page header ============================================== */

body.sanctum-shell .page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.2rem;
}
body.sanctum-shell .page-header__title h1 {
    font-size: 1.5rem;
    line-height: 1.2;
    margin: 0;
    font-weight: 600;
    color: var(--st-text-primary);
    letter-spacing: -0.01em;
}
body.sanctum-shell .page-header__title .subtitle {
    color: var(--st-text-muted);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}
body.sanctum-shell .page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
body.sanctum-shell .page-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--st-text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.25rem 0;
    margin-bottom: 0.5rem;
}
body.sanctum-shell .page-back:hover {
    color: var(--st-text-primary);
}

/* ===== Section ================================================== */

body.sanctum-shell .section {
    margin-bottom: var(--st-gap-section);
}
body.sanctum-shell .section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--st-text-muted);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
body.sanctum-shell .section-title .count {
    background: var(--st-bg-soft);
    border: 1px solid var(--st-border-subtle);
    color: var(--st-text-secondary);
    border-radius: 999px;
    padding: 0 0.5rem;
    font-size: 0.7rem;
}
body.sanctum-shell .section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}
body.sanctum-shell .section-title-row .section-title {
    margin-bottom: 0;
}

/* ===== Surfaces ================================================= */

body.sanctum-shell .surface {
    background: var(--st-bg-surface);
    border: 1px solid var(--st-border-subtle);
    border-radius: var(--st-radius);
    box-shadow: var(--st-shadow-sm);
}
body.sanctum-shell .surface-pad {
    padding: 1.05rem 1.15rem;
}
body.sanctum-shell .surface-pad-sm {
    padding: 0.85rem 1rem;
}
body.sanctum-shell .surface + .surface {
    margin-top: var(--st-gap-stack);
}
body.sanctum-shell .surface__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--st-border-subtle);
}
body.sanctum-shell .surface__header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--st-text-primary);
}
body.sanctum-shell .surface__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ===== Status pill ============================================== */

body.sanctum-shell .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
    white-space: nowrap;
}
body.sanctum-shell .status-pill::before {
    content: "";
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}
body.sanctum-shell .status-pill--todo,
body.sanctum-shell .status-pill--default {
    color: var(--st-status-todo);
    background: var(--st-status-todo-soft);
    border-color: rgba(74, 82, 96, 0.18);
}
body.sanctum-shell .status-pill--doing,
body.sanctum-shell .status-pill--in_progress,
body.sanctum-shell .status-pill--inprogress {
    color: var(--st-status-doing);
    background: var(--st-status-doing-soft);
    border-color: rgba(180, 83, 9, 0.18);
}
body.sanctum-shell .status-pill--done,
body.sanctum-shell .status-pill--complete,
body.sanctum-shell .status-pill--completed {
    color: var(--st-status-done);
    background: var(--st-status-done-soft);
    border-color: rgba(21, 128, 61, 0.18);
}
body.sanctum-shell .status-pill--blocked {
    color: var(--st-status-blocked);
    background: var(--st-status-blocked-soft);
    border-color: rgba(185, 28, 28, 0.18);
}

/* ===== Priority chip ============================================ */

body.sanctum-shell .priority-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--st-radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
}
body.sanctum-shell .priority-chip i {
    font-size: 0.7rem;
}
body.sanctum-shell .priority-chip--low {
    color: var(--st-pri-low);
    background: var(--st-pri-low-soft);
}
body.sanctum-shell .priority-chip--normal {
    color: var(--st-pri-normal);
    background: var(--st-pri-normal-soft);
}
body.sanctum-shell .priority-chip--high {
    color: var(--st-pri-high);
    background: var(--st-pri-high-soft);
}
body.sanctum-shell .priority-chip--urgent {
    color: var(--st-pri-urgent);
    background: var(--st-pri-urgent-soft);
}

/* ===== Tag / meta chips ========================================= */

body.sanctum-shell .tag-chip {
    display: inline-flex;
    padding: 0.1rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--st-bg-soft);
    border: 1px solid var(--st-border-subtle);
    color: var(--st-text-secondary);
    border-radius: var(--st-radius-sm);
}
body.sanctum-shell .tag-chip + .tag-chip {
    margin-left: 0.25rem;
}
body.sanctum-shell .meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    background: var(--st-bg-soft);
    border: 1px solid var(--st-border-subtle);
    color: var(--st-text-secondary);
    border-radius: 999px;
    font-size: 0.78rem;
    line-height: 1.4;
}
body.sanctum-shell .meta-chip i {
    font-size: 0.78rem;
    opacity: 0.85;
}
body.sanctum-shell .meta-chip--link {
    color: var(--st-accent);
    text-decoration: none;
}
body.sanctum-shell .meta-chip--link:hover {
    color: var(--st-accent-hover);
    border-color: var(--st-accent);
    background: var(--st-accent-soft);
}
body.sanctum-shell .meta-chip--warn {
    color: #92400e;
    background: #fef3c7;
    border-color: #fcd34d;
}

/* ===== Filter bar =============================================== */

body.sanctum-shell .filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: stretch;
    padding: 0.55rem;
    background: var(--st-bg-surface);
    border: 1px solid var(--st-border-subtle);
    border-radius: var(--st-radius);
    box-shadow: var(--st-shadow-sm);
    margin-bottom: var(--st-gap-stack);
}
body.sanctum-shell .filter-bar .form-control,
body.sanctum-shell .filter-bar .form-select {
    border-radius: var(--st-radius-sm);
    border-color: var(--st-border-subtle);
    background: var(--st-bg-soft);
}
body.sanctum-shell .filter-bar .form-control:focus,
body.sanctum-shell .filter-bar .form-select:focus {
    background: var(--st-bg-surface);
    border-color: var(--st-accent);
    box-shadow: 0 0 0 3px var(--st-accent-soft);
}
body.sanctum-shell .filter-bar__search {
    flex: 2 1 280px;
    min-width: 200px;
}
body.sanctum-shell .filter-bar__field {
    flex: 1 1 140px;
    min-width: 130px;
}
body.sanctum-shell .filter-bar__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== Tables (Tasks-style) ===================================== */

body.sanctum-shell .task-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}
body.sanctum-shell .task-table thead th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--st-text-muted);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--st-border-subtle);
    background: var(--st-bg-soft);
    font-weight: 600;
}
body.sanctum-shell .task-table thead th:first-child {
    border-top-left-radius: var(--st-radius);
}
body.sanctum-shell .task-table thead th:last-child {
    border-top-right-radius: var(--st-radius);
    text-align: right;
}
body.sanctum-shell .task-table tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--st-border-subtle);
    vertical-align: middle;
    background: var(--st-bg-surface);
}
body.sanctum-shell .task-table tbody tr:last-child td {
    border-bottom: 0;
}
body.sanctum-shell .task-table tbody tr:hover td {
    background: var(--st-bg-soft);
}
body.sanctum-shell .task-table .task-actions {
    text-align: right;
    white-space: nowrap;
}

/* ===== Glyph tile (icon halo for surface tiles) ================ */

body.sanctum-shell .glyph-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--st-accent-soft);
    color: var(--st-accent);
    border-radius: var(--st-radius-sm);
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1.05rem;
    flex-shrink: 0;
    line-height: 1;
}
body.sanctum-shell .glyph-tile--sm { width: 1.65rem; height: 1.65rem; font-size: 0.85rem; }
body.sanctum-shell .glyph-tile--lg { width: 3rem; height: 3rem; font-size: 1.5rem; }
body.sanctum-shell .glyph-tile--circle { border-radius: 50%; }
body.sanctum-shell .glyph-tile--accent  { background: var(--st-accent-soft);        color: var(--st-accent); }
body.sanctum-shell .glyph-tile--success { background: var(--st-status-done-soft);   color: var(--st-status-done); }
body.sanctum-shell .glyph-tile--warn    { background: var(--st-status-doing-soft);  color: var(--st-status-doing); }
body.sanctum-shell .glyph-tile--danger  { background: var(--st-status-blocked-soft);color: var(--st-status-blocked); }
body.sanctum-shell .glyph-tile--muted   { background: var(--st-status-todo-soft);   color: var(--st-status-todo); }

/* ===== Stat tile body ========================================== */

body.sanctum-shell .stat-tile { display: flex; align-items: center; gap: 0.85rem; }
body.sanctum-shell .stat-tile__value {
    font-size: 1.5rem;
    line-height: 1.1;
    font-weight: 600;
    color: var(--st-text-primary);
    margin: 0;
}
body.sanctum-shell .stat-tile__label {
    color: var(--st-text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.15rem;
}
body.sanctum-shell a.stat-tile,
body.sanctum-shell .stat-tile a {
    color: inherit;
    text-decoration: none;
}
body.sanctum-shell a.stat-tile:hover .stat-tile__value,
body.sanctum-shell .stat-tile a:hover .stat-tile__value {
    color: var(--st-accent);
}

/* ===== Table responsive wrapper ================================ */

body.sanctum-shell .surface .task-table { margin-bottom: 0; }
body.sanctum-shell .surface > .table-responsive { margin-bottom: 0; }
body.sanctum-shell .surface > .table-responsive > .task-table thead th:first-child,
body.sanctum-shell .surface > .table-responsive > .task-table thead th:last-child {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* ===== Helpers ================================================== */

body.sanctum-shell .fine-print {
    color: var(--st-text-muted);
    font-size: 0.78rem;
}
body.sanctum-shell .empty-hint {
    color: var(--st-text-muted);
    font-size: 0.85rem;
    padding: 0.65rem 0;
    border: 1px dashed var(--st-border-subtle);
    border-radius: var(--st-radius-sm);
    text-align: center;
}

/* ===== Legacy token compat shim =================================
 * style.css declares dark-theme tokens (--bg, --bg-card, --text, etc.)
 * at :root for the legacy product look. Pages that opt in to the
 * Sanctum shell remap those tokens to light-theme values so existing
 * markup using `var(--bg-card)`, `var(--text)`, etc., remains readable
 * during the page-by-page migration without needing to be touched.
 */

body.sanctum-shell {
    --bg: var(--st-bg-app);
    --bg-card: var(--st-bg-surface);
    --text: var(--st-text-primary);
    --text-muted: var(--st-text-muted);
    --border: var(--st-border-subtle);
    --primary: var(--st-accent);
    --primary-dark: var(--st-accent-hover);
}

body.sanctum-shell .info-box {
    background: var(--st-bg-surface);
    border: 1px solid var(--st-border-subtle);
    border-radius: var(--st-radius);
    box-shadow: var(--st-shadow-sm);
    color: var(--st-text-primary);
}
body.sanctum-shell .info-box .text-muted {
    color: var(--st-text-muted) !important;
}

body.sanctum-shell input[type="text"],
body.sanctum-shell input[type="password"],
body.sanctum-shell input[type="email"],
body.sanctum-shell input[type="number"],
body.sanctum-shell input[type="date"],
body.sanctum-shell input[type="search"],
body.sanctum-shell textarea,
body.sanctum-shell select {
    background: var(--st-bg-surface);
    border-color: var(--st-border-subtle);
    color: var(--st-text-primary);
}
body.sanctum-shell input[type="text"]:focus,
body.sanctum-shell input[type="password"]:focus,
body.sanctum-shell input[type="email"]:focus,
body.sanctum-shell input[type="number"]:focus,
body.sanctum-shell input[type="date"]:focus,
body.sanctum-shell input[type="search"]:focus,
body.sanctum-shell textarea:focus,
body.sanctum-shell select:focus {
    border-color: var(--st-accent);
    box-shadow: 0 0 0 3px var(--st-accent-soft);
    outline: none;
}

body.sanctum-shell table {
    color: var(--st-text-primary);
}
body.sanctum-shell th,
body.sanctum-shell td {
    border-bottom-color: var(--st-border-subtle);
}
body.sanctum-shell th {
    color: var(--st-text-muted);
}

/* The legacy in-page nav row at the top of every admin page is now
 * superseded by the Tasks-style navbar. Hide it on shell pages so we
 * don't render two nav rows during the transition.
 */
body.sanctum-shell .main-content > .flex.admin-nav {
    display: none;
}

/* ===== Top navbar — location picker (dark variant) =============== */

body.sanctum-shell .navbar.admin-nav .admin-location-picker {
    align-items: center;
}
body.sanctum-shell .navbar.admin-nav .admin-location-picker label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.78rem;
    margin: 0 0.35rem 0 0;
}
body.sanctum-shell .navbar.admin-nav .admin-location-picker .form-select {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}
body.sanctum-shell .navbar.admin-nav .admin-location-picker .form-select:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
    box-shadow: none;
}
body.sanctum-shell .navbar.admin-nav .admin-location-picker .form-select option {
    color: var(--st-text-primary);
}

/* ===== Mobile tweaks ============================================ */

body.sanctum-shell .auth-brand-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.85rem;
    background: var(--st-accent, #2563eb);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: var(--st-shadow-sm);
}

/* ===== Auth pages (unified login + partner magic-link error) === */

body.sanctum-shell.auth-app .auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}
body.sanctum-shell.auth-app .auth-card {
    width: 100%;
    max-width: 24rem;
    background: var(--st-bg-surface);
    border: 1px solid var(--st-border-subtle);
    border-radius: var(--st-radius);
    box-shadow: var(--st-shadow-md, 0 10px 30px rgba(2, 6, 23, 0.08));
    padding: 2rem 1.75rem;
}
body.sanctum-shell.auth-app .auth-card__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
    margin-bottom: 1.25rem;
}
body.sanctum-shell.auth-app .auth-card__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--st-text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}
body.sanctum-shell.auth-app .auth-card__subtitle {
    color: var(--st-text-muted);
    font-size: 0.85rem;
    margin: 0;
}
body.sanctum-shell.auth-app .auth-form .form-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--st-text-muted);
    margin-bottom: 0.35rem;
}
body.sanctum-shell.auth-app .auth-form .form-control {
    width: 100%;
    max-width: none;
    border-color: var(--st-border-subtle);
    background: var(--st-bg-soft);
}
body.sanctum-shell.auth-app .auth-form .form-control:focus {
    background: var(--st-bg-surface);
    border-color: var(--st-accent);
    box-shadow: 0 0 0 3px var(--st-accent-soft);
}
body.sanctum-shell.auth-app .auth-form__submit .btn-primary {
    background-color: var(--st-accent);
    border-color: var(--st-accent);
    font-weight: 600;
}
body.sanctum-shell.auth-app .auth-form__submit .btn-primary:hover,
body.sanctum-shell.auth-app .auth-form__submit .btn-primary:focus {
    background-color: var(--st-accent-hover);
    border-color: var(--st-accent-hover);
}
body.sanctum-shell.auth-app .auth-form__submit {
    margin-top: 0.25rem;
}
body.sanctum-shell.auth-app .auth-form__submit .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 6.5rem;
}
body.sanctum-shell.auth-app .auth-card__help {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--st-border-subtle);
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--st-text-muted);
    text-align: center;
}
body.sanctum-shell.auth-app .auth-card__help a {
    color: var(--st-accent);
    font-weight: 500;
    text-decoration: none;
}
body.sanctum-shell.auth-app .auth-card__help a:hover,
body.sanctum-shell.auth-app .auth-card__help a:focus {
    color: var(--st-accent-hover);
    text-decoration: underline;
}
body.sanctum-shell.auth-app .auth-card--centered {
    text-align: center;
}
body.sanctum-shell.auth-app .auth-card--centered .alert {
    text-align: left;
}

@media (max-width: 767.98px) {
    body.sanctum-shell .page-header {
        align-items: flex-start;
    }
    body.sanctum-shell .filter-bar {
        padding: 0.5rem;
    }
    body.sanctum-shell .filter-bar__field,
    body.sanctum-shell .filter-bar__search,
    body.sanctum-shell .filter-bar__actions {
        flex: 1 1 100%;
    }
    body.sanctum-shell .filter-bar__actions .btn {
        flex: 1 1 0;
    }
    body.sanctum-shell .task-table {
        font-size: 0.85rem;
    }
}
