/* =========================================================
   QASRGO ERP Admin CSS
   Full layout + Framework Pack 01/02
   Path: admin/assets/css/erp.css
   ========================================================= */

:root {
    --primary: #6f4dbf;
    --primary-dark: #5436a3;
    --primary-soft: #f4efff;
    --dark: #1f2430;
    --muted: #667085;
    --line: #e5e7eb;
    --bg: #f6f7fb;
    --card: #ffffff;
    --radius: 18px;
    --shadow: 0 10px 28px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--dark);
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* Layout */
.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #25164d 0%, #351f73 45%, #4b2ca0 100%);
    color: #ffffff;
    padding: 22px 16px;
    box-shadow: 6px 0 24px rgba(15, 23, 42, .18);
}

.admin-sidebar a { color: inherit; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    text-decoration: none;
    margin-bottom: 22px;
    padding: 6px 8px;
    font-size: 19px;
    letter-spacing: .02em;
}

.brand:hover { color: #ffffff; }

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: var(--primary);
    font-weight: 900;
    font-size: 22px;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .18);
}

.admin-content {
    min-width: 0;
    padding: 24px;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    padding: 18px 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.admin-topbar h1 {
    font-size: 26px;
    line-height: 1.2;
    color: var(--dark);
}

.page-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
}

/* Navigation */
.admin-sidebar nav { padding-bottom: 20px; }

.nav-main-link,
.nav-submenu a,
.nav-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    font: inherit;
}

.nav-main-link {
    padding: 11px 12px;
    border-radius: 14px;
    margin-bottom: 8px;
    font-weight: 800;
    color: rgba(255,255,255,.88);
}

.nav-main-link:hover,
.nav-main-link.active {
    background: rgba(255,255,255,.13);
    color: #fff;
}

.nav-section { margin-top: 8px; }

.nav-section-toggle {
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font-weight: 800;
    opacity: .95;
}

.nav-section-toggle:hover { background: rgba(255,255,255,.08); }

.nav-section-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-icon {
    width: 22px;
    text-align: center;
    flex: 0 0 22px;
}

.nav-chevron {
    transition: transform .2s ease;
    opacity: .75;
    font-size: 12px;
}

.nav-section.open .nav-chevron { transform: rotate(90deg); }

.nav-submenu {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .22s ease;
}

.nav-section.open .nav-submenu { grid-template-rows: 1fr; }

.nav-submenu-inner {
    overflow: hidden;
    padding-left: 10px;
    margin-left: 14px;
    border-left: 1px solid rgba(255,255,255,.16);
}

.nav-submenu a {
    margin: 3px 0;
    padding: 8px 8px 8px 14px;
    border-radius: 10px;
    color: rgba(255,255,255,.82);
    font-weight: 700;
}

.nav-submenu a:hover,
.nav-submenu a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.nav-submenu a.active { font-weight: 900; }

.nav-bottom-space { height: 8px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 9px 14px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    line-height: 1.1;
}

.btn:hover {
    background: var(--primary-dark);
    color: #fff;
    text-decoration: none;
}

.btn-outline {
    background: #ffffff;
    color: var(--primary);
    border-color: #d8ccff;
}

.btn-outline:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.btn-sm {
    padding: 7px 10px;
    font-size: 13px;
}

/* Cards and stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-number {
    margin-top: 8px;
    font-size: 32px;
    line-height: 1.05;
    font-weight: 900;
    color: var(--dark);
}

.stat-card a {
    display: inline-block;
    margin-top: 10px;
    font-weight: 800;
    text-decoration: none;
}

.erp-framework-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15,23,42,.06);
}

/* Framework Pack 02 - Stat Cards */
.erp-stat-card {
    position: relative;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 10px 28px rgba(15,23,42,.06);
    min-height: 118px;
    overflow: hidden;
}

.erp-stat-card:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: #2563eb;
}

.erp-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: #eff6ff;
    flex: 0 0 42px;
}

.erp-stat-body { min-width: 0; flex: 1; }

.erp-stat-title {
    display: block;
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.erp-stat-number {
    margin-top: 6px;
    font-size: 30px;
    line-height: 1.05;
    font-weight: 900;
    color: #0f172a;
}

.erp-stat-subtitle {
    margin-top: 7px;
    color: #64748b;
    font-size: 13px;
}

.erp-stat-link {
    display: inline-block;
    margin-top: 9px;
    font-weight: 800;
    color: #2563eb;
    text-decoration: none;
}

.erp-stat-link:hover { text-decoration: underline; }

.erp-stat-blue:before { background:#2563eb; }
.erp-stat-blue .erp-stat-icon { background:#eff6ff; color:#1d4ed8; }
.erp-stat-green:before { background:#059669; }
.erp-stat-green .erp-stat-icon { background:#ecfdf5; color:#047857; }
.erp-stat-orange:before { background:#ea580c; }
.erp-stat-orange .erp-stat-icon { background:#fff7ed; color:#c2410c; }
.erp-stat-purple:before { background:#7c3aed; }
.erp-stat-purple .erp-stat-icon { background:#f5f3ff; color:#6d28d9; }
.erp-stat-red:before { background:#dc2626; }
.erp-stat-red .erp-stat-icon { background:#fef2f2; color:#b91c1c; }
.erp-stat-cyan:before { background:#0891b2; }
.erp-stat-cyan .erp-stat-icon { background:#ecfeff; color:#0e7490; }
.erp-stat-gray:before { background:#64748b; }
.erp-stat-gray .erp-stat-icon { background:#f8fafc; color:#475569; }

/* Sections and tables */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 18px 0 12px;
}

.section-head h2,
.section-head h3 {
    margin: 0;
    color: var(--dark);
}

.section-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.table-wrap {
    overflow: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table-scroll-top {
    overflow-x: auto;
    overflow-y: hidden;
    height: 18px;
    margin: 18px 0 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
}

.table-scroll-top + .table-wrap {
    margin-top: 0 !important;
}

.table-scroll-top-inner {
    height: 1px;
}

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

.table-wrap th,
.table-wrap td {
    padding: 13px 14px;
    border-bottom: 1px solid #eef0f4;
    text-align: left;
    vertical-align: middle;
}

.table-wrap th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover { background: #fbfaff; }

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 22px !important;
}

/* Status badges */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.status.pending,
.status.requested { background: #eff6ff; color: #1d4ed8; }

.status.assigned,
.status.processing { background: #fff7ed; color: #c2410c; }

.status.accepted { background: #f5f3ff; color: #6d28d9; }

.status.started,
.status.in-progress,
.status.in_progress { background: #ecfeff; color: #0e7490; }

.status.completed,
.status.delivered,
.status.active,
.status.otp_verified { background: #ecfdf5; color: #047857; }

.status.cancelled,
.status.returned,
.status.rejected,
.status.failed { background: #fef2f2; color: #b91c1c; }

.erp-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .02em;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
}

.erp-badge-blue { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }
.erp-badge-info { background:#ecfeff; color:#0e7490; border-color:#a5f3fc; }
.erp-badge-orange { background:#fff7ed; color:#c2410c; border-color:#fed7aa; }
.erp-badge-purple { background:#f5f3ff; color:#6d28d9; border-color:#ddd6fe; }
.erp-badge-cyan { background:#ecfeff; color:#0891b2; border-color:#a5f3fc; }
.erp-badge-green { background:#ecfdf5; color:#047857; border-color:#a7f3d0; }
.erp-badge-red { background:#fef2f2; color:#b91c1c; border-color:#fecaca; }
.erp-badge-dark { background:#f3f4f6; color:#111827; border-color:#d1d5db; }
.erp-badge-gray { background:#f9fafb; color:#4b5563; border-color:#e5e7eb; }

/* Flash messages */
.flash {
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 800;
    border: 1px solid transparent;
}

.flash-success { background:#ecfdf5; color:#047857; border-color:#a7f3d0; }
.flash-error,
.flash-danger { background:#fef2f2; color:#b91c1c; border-color:#fecaca; }
.flash-warning { background:#fff7ed; color:#c2410c; border-color:#fed7aa; }
.flash-info { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }

/* Forms */
input,
select,
textarea {
    max-width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(111, 77, 191, .14);
}

/* Responsive */
@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .admin-shell { grid-template-columns: 1fr; }

    .admin-sidebar {
        position: relative;
        height: auto;
        min-height: auto;
    }

    .admin-content { padding: 16px; }

    .admin-topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .stat-number,
    .erp-stat-number { font-size: 26px; }
}

.erp-toolbar{
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:18px;
    padding:18px;
    margin-bottom:18px;
    box-shadow:0 10px 28px rgba(15,23,42,.06);
}
.erp-toolbar-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:16px;
    margin-bottom:14px;
}
.erp-toolbar-head h2{
    margin:0;
}
.erp-toolbar-head p{
    margin:4px 0 0;
    color:#667085;
}
.erp-toolbar-actions{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}
.erp-toolbar-form{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}
.erp-toolbar-form input[type="search"]{
    min-width:260px;
    flex:1;
}
