:root {
    --maroon: #8b1a1a;
    --maroon-dark: #6b1414;
    --gold: #c9a227;
    --ivory: #fdf8f0;
    --ink: #2b2320;
    --muted: #7a6f66;
    --border: #e6ddd0;
    --success: #2e7d32;
    --error: #c62828;
    --warn: #b8860b;
    --info: #1d6fd8;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    font-family:
        -apple-system,
        Segoe UI,
        Roboto,
        Arial,
        sans-serif;
    color: var(--ink);
    background: #f5f1ea;
}
a {
    color: var(--maroon);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.admin-login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--maroon), var(--maroon-dark));
}
.admin-login-card {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    width: 340px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.admin-login-card h1 {
    margin: 0 0 4px;
    color: var(--maroon);
    font-size: 22px;
}
.admin-login-card .muted {
    color: var(--muted);
    margin: 0 0 20px;
    font-size: 14px;
}
.admin-login-card label {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
}
.admin-login-card input {
    width: 100%;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.admin-shell {
    display: flex;
    min-height: 100vh;
}
.admin-sidebar {
    width: 220px;
    background: #23180f;
    color: #efe6d8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.admin-brand {
    padding: 20px 18px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.admin-brand span {
    color: var(--gold);
    font-weight: 400;
}
.admin-sidebar nav {
    flex: 1;
    padding: 10px 0;
}
.admin-sidebar nav a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 18px;
    color: #d9cdbb;
    font-size: 14px;
}
.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    text-decoration: none;
    border-left: 3px solid var(--gold);
}
.admin-sidebar nav a .badge {
    background: var(--gold);
    color: #23180f;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
}
.admin-sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}
.admin-sidebar-footer a {
    color: #d9cdbb;
}

.admin-main {
    flex: 1;
    min-width: 0;
}
.admin-topbar {
    background: #fff;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.admin-topbar h1 {
    margin: 0;
    font-size: 20px;
}
.admin-content {
    padding: 24px 28px;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success {
    background: #e8f5e9;
    color: var(--success);
}
.alert-error {
    background: #fdecea;
    color: var(--error);
}
.alert-info {
    background: #eef3fb;
    color: #2955a3;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    color: inherit;
    text-decoration: none;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}
a.stat-card:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}
.stat-card.highlight {
    border-color: var(--gold);
    background: #fffaf0;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--maroon);
}
.stat-label {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

.panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 24px;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.panel-header h2 {
    margin: 0;
    font-size: 16px;
}
.panel-body {
    padding: 20px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.admin-table th,
.admin-table td {
    padding: 10px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table th {
    background: #faf7f2;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.admin-table tr:hover td {
    background: #fbf8f2;
}
.admin-table img.thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.media-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.media-strip a {
    display: block;
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.media-strip img,
.media-strip video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
}
.media-strip .media-video-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}
.media-strip .media-video--link {
    background: #23180f;
}
.video-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 8px;
}
.video-tile {
    width: 220px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #faf7f2;
}
.video-tile video,
.video-tile img {
    width: 100%;
    height: 124px;
    object-fit: cover;
    display: block;
    background: #000;
}
.video-embed-generic {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 124px;
    background: #23180f;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    padding: 0 10px;
    text-align: center;
}
.video-tile-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    font-size: 12px;
}
.video-tile-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Uploaded-video preview and the YouTube thumbnail open the shared media
 * viewer (data-media-open) instead of playing inline at 124px / leaving the
 * page - cursor cue matches .image-tile img's zoom-in. */
[data-media-open] {
    cursor: zoom-in;
}

/* ---- Shared media viewer modal (admin/includes/footer.php) - full-size
 * image / uploaded-video / YouTube-embed lightbox opened from a product's
 * Images or Videos tab. One instance per admin page, reused by any tile
 * that carries data-media-open. ---- */
.media-viewer {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}
.media-viewer[hidden] {
    display: none;
}
.media-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 10, 6, 0.85);
}
.media-viewer-close {
    position: absolute;
    top: 18px;
    right: 24px;
    background: none;
    border: 0;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    z-index: 1;
}
.media-viewer-body {
    position: relative;
    max-width: min(90vw, 1100px);
    max-height: 88vh;
    display: flex;
}
.media-viewer-body img {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 6px;
}
.media-viewer-body video {
    max-width: 100%;
    max-height: 88vh;
    border-radius: 6px;
    background: #000;
}
.media-viewer-body iframe {
    width: min(90vw, 1100px);
    height: min(62vw, 620px);
    border: 0;
    border-radius: 6px;
    background: #000;
}

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}
.pill-new {
    background: #eef3fb;
    color: #2955a3;
}
.pill-read {
    background: #f3f0ea;
    color: var(--muted);
}
.pill-responded {
    background: #e8f5e9;
    color: var(--success);
}
.pill-waiting_customer {
    background: #fff8e1;
    color: var(--warn);
}
.pill-customer_purchased {
    background: #e6f4ea;
    color: var(--success);
}
.pill-closed {
    background: #f0e8e8;
    color: #7a4141;
}
.pill-in_stock {
    background: #e8f5e9;
    color: var(--success);
}
.pill-out_of_stock {
    background: #fdecea;
    color: var(--error);
}
.pill-made_to_order {
    background: #fff8e1;
    color: var(--warn);
}

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover {
    background: #f5f1ea;
    text-decoration: none;
}
.btn-primary {
    background: var(--maroon);
    border-color: var(--maroon);
    color: #fff;
}
.btn-primary:hover {
    background: var(--maroon-dark);
}
.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}
.btn-block {
    width: 100%;
    text-align: center;
}
.btn-danger {
    color: var(--error);
    border-color: #f3c7c2;
}

form .form-row {
    margin-bottom: 16px;
}
form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}
form input[type="text"],
form input[type="number"],
form input[type="email"],
form input[type="password"],
form input[type="date"],
form input[type="url"],
form select,
form textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
form textarea {
    min-height: 100px;
    resize: vertical;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.checkbox-row input {
    width: auto;
}
.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.tab-btn {
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab-btn.active {
    color: var(--maroon);
    border-bottom-color: var(--maroon);
    font-weight: 600;
}
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.image-tile {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #faf7f2;
}
.image-tile img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}
.image-tile .image-actions {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: #fff;
}
.image-tile.is-primary {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold);
}
.image-tile .primary-tag {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--gold);
    color: #23180f;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
}
.btn-set-primary {
    flex: 1;
    background: var(--info);
    border-color: var(--info);
    color: #fff;
}
.btn-set-primary:hover {
    background: #1a5fba;
    border-color: #1a5fba;
}
.btn-set-primary:active {
    background: #144a92;
    border-color: #144a92;
}
.btn-delete-image {
    flex: 1;
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}
.btn-delete-image:hover {
    background: #a82121;
    border-color: #a82121;
}
.btn-delete-image:active {
    background: #8c1b1b;
    border-color: #8c1b1b;
}

/* Shown/hidden toggle buttons (admin/home-sections.php, admin/legal-pages.php) */
.btn-toggle-on {
    border-color: #b7dcb9;
    background: #eaf6eb;
    color: var(--success);
}
.btn-toggle-on:hover {
    background: var(--success);
    color: #fff;
}
.btn-toggle-off {
    border-color: var(--border);
    background: #f1ede4;
    color: var(--muted);
}
.btn-toggle-off:hover {
    background: #d8d0c2;
    color: var(--ink);
}

.repeatable-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
.repeatable-row input,
.repeatable-row select {
    flex: 1;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chip-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}
.chip-checkbox input {
    width: auto;
}

.muted {
    color: var(--muted);
}
.quick-links {
    display: flex;
    gap: 10px;
}
.filters-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filters-bar input,
.filters-bar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.list-perpage { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.list-perpage select { width: auto; }

/* Sortable column headers */
.admin-table th .sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.admin-table th .sort-link:hover { color: var(--maroon); }
.admin-table th .sort-link.is-active { color: var(--maroon); }

/* List footer: "Showing x-y of N" + pager + go-to-page */
.list-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 14px 20px; }
.list-info { font-size: 13px; color: var(--muted); }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; }
.pagination a,
.pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.pagination .current { background: var(--maroon); color: #fff; border-color: var(--maroon); }
.pagination .gap { border-color: transparent; padding-left: 4px; padding-right: 4px; }
.pagination .is-disabled { color: #b9b0a6; background: #f6f2ec; cursor: not-allowed; }
.pagination a:hover { background: #f3ece1; text-decoration: none; }
.list-goto { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.list-goto input[type=number] { width: 70px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; }

.autocomplete-box {
    position: relative;
}
.autocomplete-results {
    position: absolute;
    z-index: 10;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}
.autocomplete-results div {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
}
.autocomplete-results div:hover {
    background: #faf7f2;
}
.picked-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}
.picked-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.picked-list li input[type="number"] {
    width: 70px;
}

/* Shown on every admin page when APP_ENV !== 'production' (T-005) */
.env-banner {
    background: var(--error);
    color: #fff;
    padding: 10px 16px;
    font-size: 14px;
    text-align: center;
}
.env-banner a {
    color: #8fd0ff;
    text-decoration: underline;
    font-weight: 600;
}
.env-banner a:hover {
    color: #c4e6ff;
}
.env-banner code {
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 5px;
    border-radius: 3px;
}

/* Sidebar dividers + logout (a POST form, styled to match the nav links) */
.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    margin: 8px 18px;
}
.admin-sidebar nav .logout-form {
    margin: 0;
}
.admin-sidebar nav .logout-link {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: none;
    border: 0;
    border-left: 3px solid transparent;
    padding: 11px 18px 11px 15px;
    font: inherit;
    font-size: 14px;
    color: #d9cdbb;
    text-align: left;
    cursor: pointer;
}
.admin-sidebar nav .logout-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-left-color: var(--gold);
}

/* Show/hide password eye (assets/js/admin.js) */
.pw-wrap {
    position: relative;
    display: block;
}
.pw-wrap input {
    padding-right: 42px !important;
}
.pw-toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    padding: 0;
    color: var(--muted);
    cursor: pointer;
}
.pw-toggle:hover,
.pw-toggle:focus-visible {
    color: var(--maroon);
}
.admin-login-card .pw-wrap {
    margin-top: 6px;
}
.admin-login-card .pw-wrap input {
    margin-top: 0;
}

/* Single-column form (My Account: current -> new -> confirm, top to bottom) */
.form-stack {
    display: flex;
    flex-direction: column;
    max-width: 420px;
}

/* Image alt-text field under each product image (auto-saves on change) */
.image-tile .image-alt { width: 100%; margin: 8px 0 2px; padding: 6px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; }
.image-tile .alt-status { display: block; min-height: 16px; margin-bottom: 4px; font-size: 11px; }
.image-tile .alt-status.is-ok { color: var(--success); }
.image-tile .alt-status.is-error { color: var(--error); }
