:root {
    --bp-sidebar-width: 260px;
    --bp-accent: #38bdf8;
    --bp-accent-soft: rgba(56, 189, 248, 0.18);
    --bp-surface: #eef1f7;
    --bp-surface-2: #e4e9f2;
    --bp-ink: #0f172a;
    --bp-ink-muted: #64748b;
    --bp-radius: 0.875rem;
    --bp-radius-sm: 0.5rem;
    --bp-radius-lg: 1.125rem;
    --bp-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --bp-shadow-md: 0 4px 20px rgba(15, 23, 42, 0.07);
    --bp-shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.12);
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-link-color: #1d4ed8;
    --bs-border-radius: 0.75rem;
    --bs-border-radius-lg: 1rem;
    --bs-border-radius-sm: 0.5rem;
    --bs-body-color: #1e293b;
    --bs-body-bg: var(--bp-surface);
    /*
     * Dubai (npm distribution via jsDelivr). Overrides Bootstrap sans stack portal-wide.
     */
    --bs-font-sans-serif:
        'Dubai', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@font-face {
    font-family: 'Dubai';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src:
        url('https://cdn.jsdelivr.net/npm/dubai-font@1.1.1/dubai-font/fonts/Dubai-Light.woff2')
            format('woff2'),
        url('https://cdn.jsdelivr.net/npm/dubai-font@1.1.1/dubai-font/fonts/Dubai-Light.woff')
            format('woff');
}

@font-face {
    font-family: 'Dubai';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src:
        url('https://cdn.jsdelivr.net/npm/dubai-font@1.1.1/dubai-font/fonts/Dubai-Regular.woff2')
            format('woff2'),
        url('https://cdn.jsdelivr.net/npm/dubai-font@1.1.1/dubai-font/fonts/Dubai-Regular.woff')
            format('woff');
}

@font-face {
    font-family: 'Dubai';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src:
        url('https://cdn.jsdelivr.net/npm/dubai-font@1.1.1/dubai-font/fonts/Dubai-Medium.woff2')
            format('woff2'),
        url('https://cdn.jsdelivr.net/npm/dubai-font@1.1.1/dubai-font/fonts/Dubai-Medium.woff')
            format('woff');
}

@font-face {
    font-family: 'Dubai';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src:
        url('https://cdn.jsdelivr.net/npm/dubai-font@1.1.1/dubai-font/fonts/Dubai-Bold.woff2')
            format('woff2'),
        url('https://cdn.jsdelivr.net/npm/dubai-font@1.1.1/dubai-font/fonts/Dubai-Bold.woff')
            format('woff');
}

html,
body {
    min-height: 100%;
    font-family: var(--bs-body-font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.admin-body {
    background: var(--bp-surface);
    color: var(--bs-body-color);
}

.admin-body .wrapper {
    min-height: 100vh;
    width: 100%;
}

.admin-body .main-content {
    min-width: 0;
    background:
        radial-gradient(ellipse 85% 50% at 50% -5%, rgba(37, 99, 235, 0.07), transparent 52%),
        linear-gradient(180deg, var(--bp-surface) 0%, #f6f7fb 42%, var(--bp-surface) 100%);
    display: flex;
    flex-direction: column;
}

.bp-main {
    flex: 1;
    width: 100%;
    min-width: 0;
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
}

/* —— Sidebar —— */
.sidebar {
    width: var(--bp-sidebar-width);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.bp-sidebar {
    background: linear-gradient(168deg, #1a365d 0%, #0f172a 48%, #0a0f18 100%);
    color: rgba(255, 255, 255, 0.92);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.18);
}

.bp-sidebar .sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    letter-spacing: 0.02em;
}

.bp-sidebar-title {
    font-size: 1.05rem;
}

.bp-sidebar-logo {
    color: var(--bp-accent);
    vertical-align: -0.1em;
}

.bp-sidebar-close {
    color: rgba(255, 255, 255, 0.55) !important;
    font-size: 1.125rem;
    text-decoration: none;
}

.bp-sidebar-close:hover,
.bp-sidebar-close:focus-visible {
    color: #fff !important;
}

.bp-sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.58);
    font-weight: 500;
    padding: 0.65rem 0.95rem;
    border-radius: var(--bp-radius-sm);
    margin-bottom: 0.35rem;
    transition:
        color 0.18s ease,
        background 0.18s ease,
        transform 0.14s ease;
}

.bp-sidebar-nav .nav-link .nav-icon {
    opacity: 0.82;
}

.bp-sidebar-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.bp-sidebar-nav .nav-link.active {
    color: #fff;
    background: linear-gradient(
        90deg,
        rgba(56, 189, 248, 0.18) 0%,
        rgba(255, 255, 255, 0.1) 100%
    );
    box-shadow:
        inset 3px 0 0 var(--bp-accent),
        inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* —— Top bar —— */
.bp-topbar {
    background: rgba(255, 255, 255, 0.78) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
    padding-top: 0.65rem !important;
    padding-bottom: 0.65rem !important;
}

.bp-topbar-title {
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--bp-ink-muted) !important;
}

.bp-icon-btn {
    border-radius: var(--bp-radius-sm);
}

.bp-user-btn {
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 999px !important;
    font-weight: 500;
}

.bp-user-btn:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.22);
}

.bp-user-btn:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

.bp-user-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(56, 189, 248, 0.25));
    color: #1e40af;
    font-size: 0.9rem;
}

.bp-dropdown {
    padding: 0.35rem;
    border-radius: var(--bp-radius);
    box-shadow: var(--bp-shadow-lg);
}

.bp-dropdown .dropdown-item {
    padding: 0.45rem 0.85rem;
    border-radius: var(--bp-radius-sm);
}

.bp-dropdown .dropdown-item:hover {
    background: rgba(37, 99, 235, 0.08);
}

/* —— Footer —— */
.bp-footer {
    background: transparent !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
    color: var(--bp-ink-muted);
}

/* —— Cards & page chrome —— */
.admin-body .dashboard-header h1 {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--bp-ink);
}

.admin-body .card {
    border: none;
    border-radius: var(--bp-radius);
    box-shadow: var(--bp-shadow-md);
    background: rgba(255, 255, 255, 0.92);
    /* Allow wide tables inside .table-responsive to show horizontal scrollbars */
    overflow-x: visible;
    overflow-y: visible;
}

.admin-body .card.border-0 {
    border: none;
}

.admin-body .card.shadow-sm {
    box-shadow: var(--bp-shadow-md);
}

.admin-body .card-stat {
    position: relative;
    transition:
        transform 0.22s ease,
        box-shadow 0.22s ease;
}

.admin-body .card-stat::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    opacity: 0.9;
    border-radius: var(--bp-radius) var(--bp-radius) 0 0;
}

.admin-body .card-stat--sales::before {
    background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.admin-body .card-stat--orders::before {
    background: linear-gradient(90deg, #059669, #34d399);
}

.admin-body .card-stat--received::before {
    background: linear-gradient(90deg, #0891b2, #22d3ee);
}

.admin-body .card-stat--balance::before {
    background: linear-gradient(90deg, #d97706, #fbbf24);
}

.admin-body .card-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--bp-shadow-lg);
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.25rem;
}

.admin-body .card-body {
    min-width: 0;
}

.admin-body .table-responsive {
    border-radius: calc(var(--bp-radius) - 2px);
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.admin-body .table {
    vertical-align: middle;
}

.admin-body .table-sales thead th {
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    color: var(--bp-ink-muted);
    white-space: nowrap;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.admin-body .table-sales tbody tr {
    transition: background-color 0.12s ease;
}

.admin-body .table-sales tbody tr:last-child td {
    border-bottom: 0;
}

.admin-body .table-sales {
    --bs-table-hover-bg: rgba(37, 99, 235, 0.045);
    margin-bottom: 0;
}

.admin-body .table-sales .btn-group .btn {
    padding: 0.22rem 0.48rem;
    border-radius: var(--bp-radius-sm);
}

.admin-body .modal-content {
    border: none;
    border-radius: var(--bp-radius-lg);
    box-shadow: var(--bp-shadow-lg);
}

.admin-body .modal-header {
    border-bottom-color: rgba(15, 23, 42, 0.08);
    padding-top: 1.1rem;
    padding-bottom: 1rem;
}

.admin-body .form-control:focus,
.admin-body .form-select:focus {
    border-color: rgba(37, 99, 235, 0.45);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.12);
}

.admin-body .btn-primary {
    font-weight: 600;
}

.admin-body .btn-primary:focus-visible {
    box-shadow:
        0 0 0 0.2rem rgba(37, 99, 235, 0.35),
        0 2px 6px rgba(37, 99, 235, 0.2);
}

.admin-body .pagination .page-link {
    border-radius: var(--bp-radius-sm);
    border-color: rgba(15, 23, 42, 0.1);
    color: var(--bs-primary);
    font-weight: 500;
}

.admin-body .pagination .page-item.active .page-link {
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

#bpToastContainer .toast {
    border: none;
    border-radius: var(--bp-radius);
    box-shadow: var(--bp-shadow-lg);
}

/* Sidebar mobile drawer */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1045;
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 16px 0 48px rgba(0, 0, 0, 0.35);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1040;
    }

    body.sidebar-open .sidebar-overlay {
        display: block !important;
    }
}

/* —— Login —— */
.login-page {
    background:
        radial-gradient(ellipse 100% 80% at 50% -15%, rgba(37, 99, 235, 0.16), transparent 55%),
        linear-gradient(165deg, #e8edf5 0%, #eef2f9 42%, #f8fafc 100%);
    min-height: 100vh;
}

.login-page .letter-tight {
    letter-spacing: -0.02em;
}

.bp-login-shell {
    color: var(--bp-ink-muted);
}

.bp-login-brand-logo {
    max-width: 9rem;
    width: min(41vw, 9rem);
    height: auto;
    border-radius: 0.25rem;
    box-shadow:
        var(--bp-shadow-md),
        0 0 0 4px rgba(255, 255, 255, 0.9);
}

.bp-login-card {
    border-radius: var(--bp-radius-lg) !important;
    box-shadow:
        0 24px 56px rgba(15, 23, 42, 0.12),
        0 0 0 1px rgba(255, 255, 255, 0.7) inset;
    background: rgba(255, 255, 255, 0.96);
}

.bp-input {
    border-radius: var(--bp-radius-sm);
    padding: 0.6rem 0.95rem;
    border-color: rgba(15, 23, 42, 0.12);
}

.bp-btn-submit {
    border-radius: var(--bp-radius-sm);
    box-shadow:
        0 4px 14px rgba(37, 99, 235, 0.32),
        0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.bp-btn-submit:hover {
    box-shadow:
        0 6px 18px rgba(37, 99, 235, 0.38),
        0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.bp-login-footnote {
    color: var(--bp-ink-muted);
    opacity: 0.92;
}

.login-page .alert-danger {
    border: none;
    border-radius: var(--bp-radius-sm);
    background: rgba(220, 53, 69, 0.1);
    color: #b02a37;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sortable-header .bi {
    font-size: 0.85rem;
    opacity: 0.65;
}

/* Form helper text */
.form-hint {
    font-size: 0.8125rem;
}

address.pre-line {
    white-space: pre-line;
}

/* Dashboard Chart.js canvases */
.dash-chart-host {
    position: relative;
    height: 280px;
    width: 100%;
    max-width: 100%;
}
