/* ==========================================================
   Echo One ERP — Admin Dashboard CSS
   Path: /assets/css/admin-dashboard.css
   Scope: /dashboard/admin.php only
========================================================== */

:root {
    --admin-bg: #f3f7fc;
    --admin-surface: #ffffff;
    --admin-soft: #f8fbff;
    --admin-text: #10233f;
    --admin-muted: #71839e;
    --admin-border: #dbe7f3;
    --admin-primary: #2563eb;
    --admin-sky: #0ea5e9;
    --admin-green: #10b981;
    --admin-red: #ef4444;
    --admin-orange: #f59e0b;
    --admin-purple: #8b5cf6;
    --admin-radius-xl: 24px;
    --admin-radius-lg: 18px;
    --admin-shadow: 0 14px 36px rgba(15, 23, 42, .08);
    --admin-shadow-hover: 0 20px 46px rgba(15, 23, 42, .12);
}

/* ===============================
   Base Isolation
================================ */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body:has(.dash-shell) {
    margin: 0 !important;
    padding-top: 0 !important;
    background:
        radial-gradient(circle at 8% 12%, rgba(37, 99, 235, .10), transparent 28%),
        radial-gradient(circle at 86% 18%, rgba(14, 165, 233, .10), transparent 26%),
        linear-gradient(135deg, #f8fbff 0%, #eef6ff 48%, #f7fbff 100%) !important;
    color: var(--admin-text);
    font-family: Cairo, Tahoma, Arial, sans-serif;
}

.dash-shell,
.dash-shell * {
    box-sizing: border-box;
}

.dash-shell {
    width: 100%;
    min-height: 100vh;
    padding: 18px 18px 34px;
    overflow-x: hidden;
    position: relative;
    isolation: isolate;
}

.dash-wrap {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 16px;
}

/* ===============================
   Background Orbs
================================ */

.dash-bg-orb {
    position: fixed;
    z-index: -1;
    width: 300px;
    height: 300px;
    border-radius: 999px;
    filter: blur(34px);
    opacity: .25;
    pointer-events: none;
}

.orb-one {
    top: 90px;
    right: 8%;
    background: rgba(37, 99, 235, .18);
}

.orb-two {
    bottom: 80px;
    left: 6%;
    background: rgba(16, 185, 129, .14);
}

.orb-three {
    top: 45%;
    left: 38%;
    background: rgba(236, 72, 153, .10);
}

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

.section-surface,
.kpi,
.chart-card,
.table-card {
    position: relative;
    background: rgba(255, 255, 255, .86);
    border: 1px solid rgba(148, 163, 184, .22);
    box-shadow: var(--admin-shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.section-surface::before,
.chart-card::before,
.table-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255, 255, 255, .75), rgba(255, 255, 255, 0) 42%);
}

.muted,
.chart-sub,
.kpi-sub,
.td-muted,
.mini-note {
    color: var(--admin-muted) !important;
}

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

.dash-top {
    width: 100%;
    border-radius: var(--admin-radius-xl);
    padding: 20px 24px;
    min-height: 130px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background:
        linear-gradient(135deg, rgba(239, 246, 255, .96), rgba(255, 255, 255, .88)),
        radial-gradient(circle at 10% 0%, rgba(37, 99, 235, .14), transparent 35%);
}

.dash-title h1 {
    margin: 0;
    font-size: clamp(24px, 2vw, 34px);
    line-height: 1.3;
    font-weight: 950;
    color: #0f2748;
}

.dash-title h1::after {
    content: "";
    display: block;
    width: 82px;
    height: 4px;
    margin-top: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--admin-primary), var(--admin-sky), var(--admin-green));
}

.dash-title p {
    margin: 10px 0 0;
    font-size: 13px;
}

/* ===============================
   Filters
================================ */

.dash-filters {
    display: grid;
    gap: 12px;
    justify-items: end;
}

.chips,
.wh-tabs,
.custom-range {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.chip,
.wh-tab,
.dash-shell .btn {
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid rgba(37, 99, 235, .14);
    border-radius: 999px;
    background: rgba(255, 255, 255, .85);
    color: #284462;
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    transition: .2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.chip:hover,
.wh-tab:hover,
.dash-shell .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(37, 99, 235, .12);
}

.chip.active,
.wh-tab.active,
.dash-shell .btn:not(.ghost) {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--admin-primary), var(--admin-sky));
    box-shadow: 0 12px 24px rgba(37, 99, 235, .20);
}

.dash-shell .btn.ghost {
    color: var(--admin-primary);
    background: rgba(239, 246, 255, .88);
}

.custom-range {
    padding: 9px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .72);
    border: 1px solid var(--admin-border);
}

.custom-range label {
    display: grid;
    gap: 5px;
    color: var(--admin-muted);
    font-size: 12px;
    font-weight: 900;
}

.custom-range input {
    min-height: 38px;
    max-width: 150px;
    border: 1px solid var(--admin-border);
    border-radius: 14px;
    padding: 0 12px;
    color: var(--admin-text);
    background: rgba(255, 255, 255, .96);
    outline: none;
}

/* ===============================
   Warehouse Tabs
================================ */

.wh-tabs {
    width: 100%;
    min-height: 78px;
    border-radius: var(--admin-radius-xl);
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(240, 249, 255, .94), rgba(255, 255, 255, .82));
}

.wh-scroll {
    display: flex;
    align-items: center;
    gap: 9px;
    overflow-x: auto;
    padding-block: 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.wh-scroll>* {
    flex: 0 0 auto;
}

/* ===============================
   Charts
================================ */

.charts-grid {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr);
    gap: 14px;
}

.chart-card {
    border-radius: var(--admin-radius-xl);
    padding: 16px;
    min-height: 315px;
    overflow: hidden;
}

.chart-card:nth-child(1) {
    background:
        linear-gradient(135deg, rgba(239, 246, 255, .90), rgba(255, 255, 255, .88)),
        radial-gradient(circle at 0 0, rgba(37, 99, 235, .11), transparent 38%);
}

.chart-card:nth-child(2) {
    background:
        linear-gradient(135deg, rgba(240, 253, 250, .90), rgba(255, 255, 255, .88)),
        radial-gradient(circle at 100% 0, rgba(16, 185, 129, .12), transparent 36%);
}

.chart-head,
.table-head {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.chart-title {
    color: #10233f;
    font-weight: 950;
    font-size: 16px;
}

.chart-sub,
.mini-note {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 800;
}

.chart-body {
    position: relative;
    z-index: 1;
    min-height: 225px;
    padding: 10px;
    border-radius: 18px;
    background:
        linear-gradient(rgba(148, 163, 184, .09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, .09) 1px, transparent 1px),
        rgba(255, 255, 255, .66);
    background-size: 22px 22px;
    border: 1px solid rgba(148, 163, 184, .18);
}

.chart-body.donut {
    display: grid;
    place-items: center;
}

.chart-body canvas,
.chart-card canvas {
    max-width: 100% !important;
}

.chart-legend {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ===============================
   KPI Cards
================================ */

.cards-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
    gap: 13px;
}

.kpi {
    position: relative;
    overflow: hidden;
    min-height: 122px;
    padding: 15px;
    border-radius: var(--admin-radius-lg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(255, 255, 255, .97), rgba(246, 250, 255, .97)) !important;
    border: 1px solid rgba(209, 223, 241, .95) !important;
    box-shadow:
        0 10px 24px rgba(15, 23, 42, .05),
        0 2px 8px rgba(59, 130, 246, .05),
        inset 0 1px 0 rgba(255, 255, 255, .85) !important;
    transition: .22s ease;
}

.kpi::before {
    content: "";
    position: absolute;
    top: 0;
    right: 15px;
    left: 15px;
    height: 4px;
    border-radius: 0 0 12px 12px;
    background: linear-gradient(90deg, #60a5fa, #38bdf8);
}

.kpi::after {
    content: "";
    position: absolute;
    width: 145px;
    height: 145px;
    left: -42px;
    bottom: -60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, .12), transparent 72%);
    pointer-events: none;
}

.kpi:hover {
    transform: translateY(-4px);
    box-shadow: var(--admin-shadow-hover);
    border-color: rgba(147, 197, 253, .95) !important;
}

.kpi-head {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kpi-ic {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 17px;
    background: rgba(239, 246, 255, .95);
    border: 1px solid rgba(147, 197, 253, .45);
}

.kpi-title {
    position: relative;
    z-index: 1;
    color: #5b6f88 !important;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.35;
}

.kpi-sub {
    margin-top: 3px;
    font-size: 11.5px;
    font-weight: 800;
}

.kpi-val,
.kpi-val.small {
    position: relative;
    z-index: 1;
    margin-top: 10px;
    color: #12263f !important;
    font-size: clamp(19px, 1.35vw, 26px);
    font-weight: 950;
    line-height: 1.15;
    letter-spacing: -.4px;
    word-break: break-word;
}

.kpi-foot {
    position: relative;
    z-index: 1;
    margin-top: 8px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .78);
    color: #334155;
    font-size: 11px;
    font-weight: 900;
    border: 1px solid rgba(148, 163, 184, .20);
}

.pill.subtle {
    background: rgba(248, 250, 252, .82);
    color: #64748b;
}

/* KPI Accent Colors */
.cards-grid .kpi:nth-child(1) {
    background: linear-gradient(180deg, #fff, #fff7ed) !important;
}

.cards-grid .kpi:nth-child(1)::before {
    background: linear-gradient(90deg, #fb923c, #f59e0b);
}

.cards-grid .kpi:nth-child(2) {
    background: linear-gradient(180deg, #fff, #fef2f2) !important;
}

.cards-grid .kpi:nth-child(2)::before {
    background: linear-gradient(90deg, #f87171, #fb7185);
}

.cards-grid .kpi:nth-child(3) {
    background: linear-gradient(180deg, #fff, #eff6ff) !important;
}

.cards-grid .kpi:nth-child(3)::before {
    background: linear-gradient(90deg, #60a5fa, #3b82f6);
}

.cards-grid .kpi:nth-child(4) {
    background: linear-gradient(180deg, #fff, #ecfeff) !important;
}

.cards-grid .kpi:nth-child(4)::before {
    background: linear-gradient(90deg, #22d3ee, #06b6d4);
}

.cards-grid .kpi:nth-child(5) {
    background: linear-gradient(180deg, #fff, #f5f3ff) !important;
}

.cards-grid .kpi:nth-child(5)::before {
    background: linear-gradient(90deg, #a78bfa, #8b5cf6);
}

.cards-grid .kpi:nth-child(6) {
    background: linear-gradient(180deg, #fff, #ecfdf5) !important;
}

.cards-grid .kpi:nth-child(6)::before {
    background: linear-gradient(90deg, #34d399, #10b981);
}

.cards-grid .kpi:nth-child(7) {
    background: linear-gradient(180deg, #fff, #f8fafc) !important;
}

.cards-grid .kpi:nth-child(7)::before {
    background: linear-gradient(90deg, #94a3b8, #64748b);
}

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

.payment-section,
.warehouses-section {
    width: 100%;
    border-radius: var(--admin-radius-xl);
    padding: 16px;
}

.payment-section {
    background:
        linear-gradient(135deg, rgba(255, 247, 237, .86), rgba(255, 255, 255, .88)),
        radial-gradient(circle at 100% 0%, rgba(245, 158, 11, .10), transparent 34%);
}

.payment-section .cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px;
}

.payment-section .kpi {
    min-height: 96px;
    padding: 12px;
}

.payment-section .kpi .kpi-val,
.payment-section .kpi .kpi-val.small {
    font-size: clamp(16px, 1.05vw, 21px);
}

/* ===============================
   Tables
================================ */

.table-card {
    width: 100%;
    border-radius: var(--admin-radius-xl);
    padding: 16px;
    overflow: hidden;
}

.table-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar {
    height: 9px;
}

.table-wrap::-webkit-scrollbar-track {
    background: #eef4fb;
    border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
    background: #8ab8ef;
    border-radius: 999px;
}

.dash-table {
    width: 100%;
    min-width: 760px;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.dash-table th {
    padding: 10px 12px;
    color: #64748b;
    font-size: 11px;
    text-align: right;
    font-weight: 950;
    background: rgba(248, 250, 252, .86);
    border-block: 1px solid rgba(148, 163, 184, .16);
    white-space: nowrap;
}

.dash-table th:first-child {
    border-radius: 0 14px 14px 0;
}

.dash-table th:last-child {
    border-radius: 14px 0 0 14px;
}

.dash-table td {
    padding: 11px 12px;
    background: rgba(255, 255, 255, .78);
    border-block: 1px solid rgba(148, 163, 184, .14);
    color: #1e293b;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.dash-table td:first-child {
    border-right: 1px solid rgba(148, 163, 184, .14);
    border-radius: 0 16px 16px 0;
}

.dash-table td:last-child {
    border-left: 1px solid rgba(148, 163, 184, .14);
    border-radius: 16px 0 0 16px;
}

.dash-table tbody tr {
    transition: .18s ease;
}

.dash-table tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(15, 23, 42, .07);
}

/* ===============================
   Responsive
================================ */

@media (min-width: 1500px) {
    .dash-shell {
        padding-inline: 22px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    }

    .payment-section .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    }
}

@media (max-width: 1366px) {
    .dash-shell {
        padding: 16px 16px 30px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }

    .kpi {
        min-height: 118px;
        padding: 13px;
    }

    .charts-grid {
        grid-template-columns: minmax(0, 1.35fr) minmax(260px, .85fr);
    }
}

@media (max-width: 1180px) {
    .dash-top {
        flex-direction: column;
        align-items: stretch;
        min-height: auto;
    }

    .dash-filters {
        width: 100%;
        justify-items: stretch;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .dash-shell {
        padding: 12px 10px 26px;
    }

    .dash-top,
    .payment-section,
    .warehouses-section,
    .chart-card,
    .table-card {
        border-radius: 16px;
    }

    .dash-top {
        padding: 14px;
    }

    .chips {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        gap: 7px;
    }

    .chip {
        width: 100%;
        text-align: center;
    }

    .custom-range {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .custom-range input,
    .custom-range label {
        width: 100%;
        max-width: none;
    }

    .custom-range .btn,
    .custom-range button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .cards-grid,
    .payment-section .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .dash-shell {
        padding: 8px 7px 22px;
    }

    .dash-wrap {
        gap: 10px;
    }

    .dash-title h1 {
        font-size: clamp(19px, 6vw, 25px);
    }

    .dash-title h1::after {
        width: 58px;
        height: 3px;
    }

    .chips {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .custom-range,
    .cards-grid,
    .payment-section .cards-grid,
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-head,
    .table-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 9px;
    }

    .chart-card {
        min-height: 265px;
        padding: 12px;
    }

    .chart-body {
        min-height: 190px;
        padding: 8px;
        border-radius: 14px;
    }

    .chart-legend {
        justify-content: flex-start;
    }

    .kpi {
        min-height: 104px;
        padding: 13px;
    }

    .kpi-ic {
        width: 35px;
        height: 35px;
        min-width: 35px;
        border-radius: 12px;
        font-size: 16px;
    }

    .kpi-title {
        font-size: 12.5px;
    }

    .kpi-val,
    .kpi-val.small {
        font-size: 22px;
    }

    .table-card {
        padding: 12px;
    }

    .dash-table {
        min-width: 640px;
    }

    .dash-bg-orb,
    .orb-three {
        display: none;
    }
}

@media (max-width: 390px) {
    .dash-shell {
        padding-inline: 5px;
    }

    .chips {
        grid-template-columns: 1fr;
    }

    .dash-table {
        min-width: 600px;
    }
}