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

:root {
    --primary: #d97706;
    --primary-hover: #b45309;
    --primary-light: #fef3c7;
    --accent: #059669;
    --dark-bg: #1c1917;
    --dark-surface: #1e293b;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --bg-page: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ===================================================================
   Sidebar shell
   =================================================================== */
:root { --sidebar-w: 250px; }

.admin-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    background: var(--dark-bg);
    color: #fff;
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 60;
}
.admin-burger {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.08);
    border: none; border-radius: 8px; color: #fff; cursor: pointer;
}
.admin-topbar-title { font-weight: 800; font-size: 16px; }
.admin-topbar-title b { color: var(--primary); }

.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--dark-bg);
    color: #d6d3d1;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
    overflow-y: auto;
}
.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    font-size: 17px;
    font-weight: 800;
    color: #fff;
}
.admin-sidebar-brand img { max-height: 30px; width: auto; }
.admin-sidebar-brand b { color: var(--primary); }

.admin-nav-list { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: #a8a29e;
    transition: all 0.15s ease;
}
.admin-nav-item svg { flex-shrink: 0; }
.admin-nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav-item.active { background: var(--primary); color: #fff; }

.admin-nav-group { border-radius: 9px; }
.admin-nav-group summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: #a8a29e;
    cursor: pointer;
    list-style: none;
    transition: all 0.15s ease;
}
.admin-nav-group summary::-webkit-details-marker { display: none; }
.admin-nav-group summary:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav-caret { margin-left: auto; opacity: 0.6; transition: transform 0.2s ease; }
.admin-nav-group[open] .admin-nav-caret { transform: rotate(180deg); }
.admin-nav-sub {
    display: block;
    padding: 9px 12px 9px 42px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: #a8a29e;
    transition: all 0.15s ease;
}
.admin-nav-sub:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav-sub.active { color: var(--primary); background: rgba(217,119,6,0.14); }

.admin-sidebar-foot {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.admin-sidebar-user {
    padding: 6px 12px 10px;
    font-size: 12px;
    color: #78716c;
    word-break: break-all;
}

.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 45;
}

.admin-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    padding: 32px 40px;
}

/* Legacy alias kept so un-migrated markup still lays out sensibly */
.admin-container { width: 100%; }

@media (max-width: 980px) {
    .admin-topbar { display: flex; }
    .admin-main { margin-left: 0; padding: 20px 16px; }
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 0 40px rgba(0,0,0,0.4);
    }
    body.admin-nav-open .admin-sidebar { transform: translateX(0); }
    body.admin-nav-open .admin-sidebar-overlay { display: block; }
    body.admin-nav-open { overflow: hidden; }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-info h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-info p {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
}

.card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 28px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

/* Modern Data Table */
.data-table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-cat {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-brand {
    background: #f1f5f9;
    color: #475569;
}
.btn-text-toggle {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}
.btn-text-toggle:hover {
    background: var(--primary-light);
    color: var(--primary-hover);
}
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn-edit {
    background: #fef3c7;
    color: #d97706;
    border-color: #c7d2fe;
}
.btn-edit:hover {
    background: #d97706;
    color: #ffffff;
}
.btn-disable {
    background: #fffbeb;
    color: #d97706;
    border-color: #fde68a;
}
.btn-disable:hover {
    background: #d97706;
    color: #ffffff;
}
.btn-enable {
    background: #ecfdf5;
    color: #059669;
    border-color: #a7f3d0;
}
.btn-enable:hover {
    background: #059669;
    color: #ffffff;
}
.btn-delete {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}
.btn-delete:hover {
    background: #dc2626;
    color: #ffffff;
}
.badge-status-active {
    background: #ecfdf5;
    color: #059669;
}
.badge-status-disabled {
    background: #f1f5f9;
    color: #64748b;
    text-decoration: line-through;
}
.alert-banner {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
}
.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Admin sign-in page */
.admin-auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.admin-auth-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 32px;
    width: 100%;
    max-width: 400px;
}
.admin-auth-card h1 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 4px;
}
.admin-auth-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Order status pills (shared visual language with storefront) */
.order-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.order-status-pending    { background: #fef9c3; color: #854d0e; }
.order-status-processing { background: #dbeafe; color: #1e40af; }
.order-status-shipped    { background: #e0e7ff; color: #3730a3; }
.order-status-completed  { background: #dcfce7; color: #166534; }
.order-status-cancelled  { background: #fee2e2; color: #991b1b; }
/* ===================================================================
   Mobile / small-screen refinements
   =================================================================== */
@media (max-width: 820px) {
    .card { padding: 18px; }
}

@media (max-width: 720px) {
    /* Collapse the inline multi-column form/detail grids in the admin pages */
    .admin-main [style*="grid-template-columns"],
    .admin-container [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    .data-table { min-width: 620px; }
    .card-header { flex-wrap: wrap; gap: 6px; }
}

@media (max-width: 480px) {
    .admin-auth-card { padding: 24px; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* ===================================================================
   Shared admin form / list helpers used by the new pages
   =================================================================== */
.admin-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}
.admin-page-head h1 { font-size: 24px; font-weight: 800; }
.admin-page-head p { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .toggle-label { font-weight: 700; font-size: 14px; }
.toggle-row .toggle-sub { font-size: 12px; color: var(--text-muted); }

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.pill-on  { background: #ecfdf5; color: #059669; }
.pill-off { background: #f1f5f9; color: #64748b; }
.pill-role { background: var(--primary-light); color: var(--primary); }

.brand-logo-cell {
    width: 120px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.brand-logo-cell img { max-width: 104px; max-height: 40px; object-fit: contain; }
.self-row td { background: #fffbeb; }

/* Toggle switch used on Email / Settings pages */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.switch input {
    appearance: none;
    -webkit-appearance: none;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}
.switch input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:checked + span { color: var(--primary); }

hr { color: var(--border); }

/* Payment receipt viewer on the admin order page */
.receipt-box {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
    padding: 14px;
    margin-bottom: 16px;
}
.receipt-box-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.receipt-link {
    display: inline-block;
    max-width: 100%;
}
.receipt-img {
    display: block;
    width: auto;
    height: auto;
    max-width: min(480px, 100%);
    max-height: 460px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: zoom-in;
}
.receipt-file {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 700;
    color: var(--primary);
}
