:root {
    --belk-blue: #003087;
    --belk-red: #c8102e;
    --belk-red-dark: #a00d25;
    --belk-gray: #f5f5f5;
    --belk-dark: #333;
    --belk-border: #ddd;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: #333;
}

h1 { margin-top: 0; }

/* Admin shell layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.admin-sidebar-shell {
    flex-shrink: 0;
    width: 240px;
}

.admin-menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1100;
    background: var(--belk-red);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}

.admin-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    cursor: pointer;
    padding: 0;
}

.admin-sidebar {
    width: 240px;
    min-height: 100vh;
    background: #003087;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.admin-brand {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.admin-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.admin-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 2rem;
    background: var(--belk-red);
    border-bottom: 1px solid var(--belk-red-dark);
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
}

.admin-topnav-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.01em;
}

.admin-topnav-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.admin-topnav-settings {
    position: relative;
}

.admin-topnav-settings-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1001;
    background: transparent;
    border: none;
    cursor: default;
    padding: 0;
}

.admin-topnav-settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.admin-topnav-settings-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: #fff;
}

.admin-topnav-settings-btn svg {
    width: 1.35rem;
    height: 1.35rem;
    fill: currentColor;
}

.admin-topnav-settings-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 1002;
    min-width: 240px;
    background: #fff;
    border: 1px solid var(--belk-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}

.admin-topnav-settings-profile {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.9rem 1rem;
    background: var(--belk-gray);
    border-bottom: 1px solid var(--belk-border);
}

.admin-topnav-settings-label {
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-topnav-settings-email {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--belk-dark);
    word-break: break-word;
}

.admin-topnav-settings-role {
    font-size: 0.78rem;
    color: var(--belk-blue);
    font-weight: 600;
}

.admin-topnav-settings-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: #fff;
    color: var(--belk-dark);
    text-align: left;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-top: 1px solid var(--belk-border);
}

.admin-topnav-settings-item:hover {
    background: var(--belk-gray);
    color: var(--belk-blue);
}

.admin-topnav-settings-logout {
    color: var(--belk-red);
}

.admin-topnav-settings-logout:hover {
    color: var(--belk-red-dark);
}

.admin-sidebar nav a {
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    text-decoration: none;
}

.admin-sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.admin-main {
    flex: 1;
    min-width: 0;
    padding: 2rem;
    background: #f5f5f5;
}

.btn-primary {
    background: #003087;
    color: #fff;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-primary:hover { background: #002060; }
.btn-primary:disabled { opacity: 0.6; }

.btn-secondary {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
}

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-weight: 600; font-size: 0.9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { margin-top: 1rem; }

.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.admin-form {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.admin-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 1rem;
}

.admin-modal {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.admin-modal-wide {
    max-width: 820px;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.admin-modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #003087;
}

.admin-modal-close {
    border: none;
    background: transparent;
    font-size: 1.75rem;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0 0.25rem;
}

.admin-modal-close:hover {
    color: #003087;
}

.admin-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.admin-modal-body .login-error {
    margin-bottom: 1rem;
}

.admin-modal-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.admin-table {
    width: 100%;
    background: #fff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.admin-table th, .admin-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.admin-table th { background: #f9f9f9; font-weight: 600; }

.table-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.btn-table-action {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.media-type-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--belk-gray, #f0f0f0);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    color: #555;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-icon svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.btn-icon-edit:hover {
    color: #003087;
    border-color: #003087;
    background: #f0f4fa;
}

.btn-icon-delete:hover {
    color: #b00020;
    border-color: #f5c2c7;
    background: #fff5f5;
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.dashboard-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s;
}

.dashboard-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.dashboard-card h3 { margin: 0 0 0.5rem; color: #003087; }

.sales-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.sales-kpi-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sales-kpi-label {
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sales-kpi-value {
    font-size: 1.75rem;
    color: #003087;
    line-height: 1.2;
}

.sales-kpi-meta {
    font-size: 0.85rem;
    color: #888;
}

.sales-kpi-change {
    font-size: 0.85rem;
    font-weight: 600;
}

.sales-kpi-change.positive { color: #2e7d32; }
.sales-kpi-change.negative { color: #c8102e; }

.sales-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 1.5rem;
}

.sales-chart-panel {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sales-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.sales-chart-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: #003087;
}

.sales-chart-subtitle {
    font-size: 0.85rem;
    color: #888;
}

.sales-chart-canvas-wrap {
    position: relative;
    height: 320px;
}

.sales-pie-canvas-wrap {
    height: 300px;
}

.sales-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
    color: #888;
    font-size: 0.95rem;
    text-align: center;
    padding: 1rem;
}

.sales-trend-tabs {
    display: flex;
    gap: 0.35rem;
}

.sales-trend-tab {
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.sales-trend-tab.active {
    background: #003087;
    border-color: #003087;
    color: #fff;
}

.activity-subtext {
    color: #666;
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #003087, #001a4d);
}

.login-card {
    background: #fff;
    padding: 2.5rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-card h1 { color: #003087; margin: 0; }
.login-subtitle { color: #666; margin-bottom: 1.5rem; }
.login-error { background: #fee; color: #c00; padding: 0.75rem; border-radius: 4px; margin-bottom: 1rem; }
.login-hint { font-size: 0.8rem; color: #999; margin-top: 1.5rem; text-align: center; }

.variant-row {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.variant-actions { display: flex; align-items: flex-end; }

.list-price {
    text-decoration: line-through;
    color: #999;
    margin-left: 0.5rem;
    font-size: 0.9rem;
}

.page-description { color: #666; margin-bottom: 1.5rem; }

.image-upload { display: flex; flex-direction: column; gap: 0.75rem; align-items: flex-start; }
.product-image-preview {
    max-width: 220px;
    max-height: 280px;
    object-fit: cover;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.home-video-preview {
    max-width: 100%;
    width: 360px;
    max-height: 200px;
    object-fit: contain;
    background: #000;
}
.product-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #eee;
}
.upload-status { margin: 0; font-size: 0.85rem; color: #666; }

.variant-image-upload { margin-top: 0.5rem; }

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.table-search {
    flex: 1;
    min-width: 260px;
    max-width: 480px;
}

.table-result-count {
    margin-left: auto;
    font-size: 0.9rem;
    color: #666;
}

.admin-table th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.admin-table th.sortable:hover { background: #eef2f8; }

.admin-table tr.filter-row th {
    background: #fff;
    padding-top: 0.35rem;
    padding-bottom: 0.75rem;
    vertical-align: top;
}

.column-filter {
    width: 100%;
    min-width: 80px;
    padding: 0.35rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 400;
}

.empty-table {
    text-align: center;
    color: #666;
    padding: 2rem 1rem !important;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 0.9rem;
    color: #666;
}

.pagination-size {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: #666;
}

.page-size-select {
    width: auto;
    min-width: 70px;
}

.login-success {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.order-meta { color: #666; font-size: 0.85rem; }
.order-expand-btn {
    background: none;
    border: none;
    padding: 0;
    font-weight: 600;
    cursor: pointer;
    color: var(--admin-blue, #003087);
}
.order-status {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}
.order-status-confirmed { background: #e3f2fd; color: #1565c0; }
.order-status-ready { background: #fff3e0; color: #ef6c00; }
.order-status-completed { background: #e8f5e9; color: #2e7d32; }
.order-status-cancelled { background: #fce4ec; color: #c62828; }
.order-details-row td { background: #fafafa; }
.order-line-items {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.order-line-items th,
.order-line-items td {
    border: 1px solid #e5e5e5;
    padding: 0.5rem 0.75rem;
    text-align: left;
}
.order-line-items th { background: #f3f3f3; }

/* Data grid */
.admin-data-grid { margin-bottom: 1rem; }
.grid-controls { display: flex; justify-content: flex-end; margin-bottom: 0.75rem; }
.column-picker { position: relative; }
.column-picker-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 20;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 0.75rem 1rem;
    min-width: 200px;
}
.column-picker-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}
.column-reset-btn { width: 100%; margin-top: 0.5rem; }
.grid-scroll { overflow-x: auto; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.admin-data-grid-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: #fff;
}
.admin-data-grid-table th,
.admin-data-grid-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    overflow: hidden;
}
.grid-th {
    position: relative;
    background: #f9f9f9;
    font-weight: 600;
    user-select: none;
}
.grid-th.sortable .grid-th-label { cursor: pointer; }
.grid-th-inner {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 1.5rem;
    padding-right: 0.5rem;
}
.grid-th-label {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
    text-align: left;
}
.grid-th-label.active { color: #003087; }
.grid-th-label:disabled { cursor: default; opacity: 0.85; }
.grid-col-collapse {
    background: #eef2f8;
    border: 1px solid #d5deea;
    border-radius: 3px;
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1.2rem;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.grid-th-collapsed-label { font-weight: 700; color: #003087; }
.grid-col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
}
.grid-col-resizer:hover { background: rgba(0, 48, 135, 0.15); }
body.grid-col-resizing { cursor: col-resize; user-select: none; }
.grid-filter-row th {
    background: #fff;
    padding-top: 0.35rem;
    padding-bottom: 0.75rem;
}
.grid-data-row:hover { background: #fafbfd; }
.admin-data-grid-table td.collapsed,
.admin-data-grid-table th.collapsed {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}
.admin-data-grid-table td.collapsed .grid-cell-text,
.admin-data-grid-table td.collapsed .order-expand-btn,
.admin-data-grid-table td.collapsed .order-status,
.admin-data-grid-table td.collapsed button {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: inline-block;
}
.sort-indicator { margin-left: 0.25rem; font-size: 0.75rem; }

.cms-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.cms-tabs button {
    flex: 1;
    max-width: 160px;
    padding: 0.65rem 1rem;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 600;
}
.cms-tabs button.active {
    background: #003087;
    color: #fff;
    border-color: #003087;
}
.role-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}
.role-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}
.role-badge {
    display: inline-block;
    background: #eef2f8;
    color: #003087;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.35rem;
    margin-bottom: 0.25rem;
}

.html-editor-wrapper {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.html-editor-host {
    min-height: 220px;
}

.html-editor-wrapper .ql-toolbar {
    border: none;
    border-bottom: 1px solid #ddd;
    background: #fafafa;
}

.html-editor-wrapper .ql-container {
    border: none;
    font-size: 0.95rem;
}

.html-editor-wrapper .ql-editor {
    min-height: 180px;
}

@media (max-width: 900px) {
    .admin-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .admin-modal,
    .admin-modal-wide {
        max-width: none;
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
    }

    .admin-menu-toggle {
        display: block;
    }

    .admin-sidebar-shell {
        width: 0;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        overflow-y: auto;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-topnav {
        padding: 0.75rem 1rem 0.75rem 3.75rem;
        flex-wrap: wrap;
    }

    .admin-topnav-brand {
        display: none;
    }

    .admin-topnav-actions {
        justify-content: flex-end;
    }

    .admin-topnav-settings-menu {
        right: 0;
        left: auto;
        min-width: min(280px, calc(100vw - 2rem));
    }

    .admin-main {
        padding: 1rem;
        width: 100%;
    }

    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .page-toolbar h1 { font-size: 1.35rem; }
    .form-row { grid-template-columns: 1fr; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .table-search { max-width: none; }
    .table-result-count { margin-left: 0; }
    .table-pagination { justify-content: center; }
    .admin-table { font-size: 0.9rem; }
    .admin-table th, .admin-table td { padding: 0.6rem 0.75rem; }
    .btn-secondary { margin-left: 0; margin-top: 0.5rem; }
    .form-actions { display: flex; flex-direction: column; align-items: stretch; }
    .form-actions .btn-secondary { margin-top: 0.5rem; }
    .cms-tabs button { max-width: none; }
    .login-card { margin: 1rem; padding: 1.5rem; }
}
