/* Admin shell and component layer. Loads after admin-style.css; markup lives in includes/head.php + includes/sidebar.php */
:root {
    --brand: #b51d29;
    --brand-dark: #8a1420;
    --brand-soft: #fbeeef;
    --gold: #f6af04;
    --ink: #1f2430;
    --muted: #667085;
    --line: #e9e4dd;
    --surface: #ffffff;
    --page: #f8f5f1;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(31, 36, 48, .05), 0 4px 16px rgba(31, 36, 48, .05);
    --head-h: 60px;
    --side-w: 248px;
    --side-w-min: 72px;
}

html { overflow-x: clip; scroll-padding-top: calc(var(--head-h) + 16px); }
body {
    background: var(--page) !important;
    color: var(--ink);
    font-size: 15px;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
}
body, * { font-family: "Inter", "Noto Sans Devanagari", system-ui, sans-serif; }
.fa { font-family: FontAwesome !important; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- Header ---- */
.admin-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1100;
    height: var(--head-h); padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--surface); border-bottom: 1px solid var(--line);
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); text-decoration: none; }
.header-logo { width: 32px; height: 32px; border-radius: 50%; }
.panel-title { font-weight: 700; font-size: 16px; color: var(--ink); white-space: nowrap; }
.menu-btn, .profile-btn {
    width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 0; border-radius: 10px; color: var(--ink); font-size: 20px; cursor: pointer;
}
.profile-btn { font-size: 26px; color: var(--muted); }
.menu-btn:hover, .profile-btn:hover { background: var(--brand-soft); color: var(--brand); }
.header-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; white-space: nowrap; }
.header-link:hover { background: var(--brand-soft); color: var(--brand); }
.profile-menu { position: relative; }
.profile-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0; width: 160px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.profile-dropdown.show { display: block; }
.profile-dropdown a { display: flex; align-items: center; gap: 8px; padding: 12px 14px; color: var(--ink); font-size: 14px; text-decoration: none; }
.profile-dropdown a:hover { background: var(--brand-soft); color: var(--brand); }

/* ---- Sidebar ---- */
.admin-sidebar {
    position: fixed; top: var(--head-h); left: 0; bottom: 0; z-index: 1050;
    width: var(--side-w); padding: 10px 10px 24px; overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface); border-right: 1px solid var(--line);
    transition: width .2s ease, transform .2s ease;
}
.admin-sidebar .menu { list-style: none; margin: 0; padding: 0; }
.admin-sidebar .menu li { list-style: none; }
.admin-sidebar .menu a {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 9px 12px; margin-bottom: 2px;
    border-radius: 10px; color: var(--ink); font-size: 14.5px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.admin-sidebar .menu a:hover { background: var(--page); }
.admin-sidebar .menu a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.admin-sidebar .icon { width: 20px; flex: none; text-align: center; font-size: 16px; color: var(--muted); }
.admin-sidebar a:hover .icon, .admin-sidebar a.active .icon { color: var(--brand); }
.admin-sidebar .section { padding: 16px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.admin-sidebar .sub { display: none; list-style: none; margin: 0 0 4px; padding: 0 0 0 32px; }
.admin-sidebar .has-sub.open .sub { display: block; }
.admin-sidebar .sub a { font-size: 14px; font-weight: 400; color: var(--muted); }
.admin-sidebar .arrow { margin-left: auto; color: var(--muted); transition: transform .15s ease; }
.admin-sidebar .has-sub.open .arrow { transform: rotate(90deg); }
.admin-sidebar .logout { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.admin-sidebar .logout a, .admin-sidebar .logout .icon { color: var(--brand); }

.admin-sidebar.collapsed { width: var(--side-w-min); }
.admin-sidebar.collapsed .text, .admin-sidebar.collapsed .arrow,
.admin-sidebar.collapsed .section, .admin-sidebar.collapsed .sub { display: none; }
.admin-sidebar.collapsed .menu a { justify-content: center; padding-inline: 0; }

.sidebar-backdrop { display: none; }

/* ---- Page layout (overrides the old float columns) ---- */
.main, .main > .row, .main > .incon, .main > .incon > .row { display: block; width: auto; margin: 0; padding: 0; }
.pan-lhs { width: 0; float: none; }
.pan-rhs {
    float: none; width: auto; max-width: 1400px;
    margin-left: var(--side-w); padding: calc(var(--head-h) + 24px) 28px 40px;
    transition: margin-left .2s ease;
}
.sidebar-collapsed .pan-rhs { margin-left: var(--side-w-min); }
.main-head { margin: 0 0 16px; padding: 0; }
.main-head > [class*="col-"] { padding: 0; }
.pan-rhs h1 { font-size: clamp(22px, 3vw, 28px); font-weight: 700; color: var(--ink); }
.pan-rhs h3 { font-size: 18px; font-weight: 600; color: var(--ink); margin: 0 0 14px; }
.pan-rhs > .col-md-6:first-child { width: auto; max-width: none; padding: 0; }

/* ---- Components ---- */
.box-com, .form-inp, .table-wrap, .card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.form-inp { padding: 20px; margin-bottom: 24px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 24px; }
.table-wrap table { margin: 0; }
.table { color: var(--ink); font-size: 14px; }
.table th { background: #fbf9f6; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.table th, .table td { padding: 12px 14px; vertical-align: middle; border-color: var(--line); }

label, .lb { font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 6px; }
.form-control, .form-select {
    min-height: 44px; padding: 9px 12px; font-size: 15px; color: var(--ink);
    background-color: var(--surface); border: 1px solid #d8d2c9; border-radius: 10px;
}
textarea.form-control { min-height: 110px; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(181, 29, 41, .14); outline: 0; }

.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background: var(--brand-dark) !important; border-color: var(--brand-dark) !important; color: #fff; }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.alert { border-radius: 10px; font-size: 14px; }
.modal-content { border: 0; border-radius: var(--radius); }
.page-link { color: var(--brand); }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Cards inside cards: keep one border, drop the inner one */
.box-com .table-wrap, .box-com .form-inp, .form-inp .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.box-com { padding: 20px; }
.box-com > .form-inp { padding: 0; margin: 0; }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-accent-bg: #fbf9f6; }

.pan-rhs .box-com { width: auto; max-width: 100%; min-width: 0; }

/* Filter rows */
.pan-rhs form.row { row-gap: 12px; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; padding: 18px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--ink); text-decoration: none;
}
.stat-card:hover { border-color: var(--brand); color: var(--ink); }
.stat-card .fa { grid-column: 2; grid-row: 1 / span 2; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-size: 20px; }
.stat-value { grid-column: 1; font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { grid-column: 1; font-size: 13px; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.quick-link {
    display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    color: var(--ink); font-size: 14px; font-weight: 500; text-decoration: none;
}
.quick-link .fa { width: 20px; text-align: center; color: var(--brand); }
.quick-link:hover { border-color: var(--brand); color: var(--brand); }

/* ---- Login ---- */
.login-error { display: none; margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); font-size: 14px; }
.login-error.show { display: block; }
.login .btn-primary { width: 100%; }
.login .inn { max-width: 440px; margin-inline: auto; border-radius: 16px; box-shadow: var(--shadow); }
.login .rhs { width: 100%; }
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 48px; }
.pw-toggle { position: absolute; top: 0; right: 0; width: 44px; height: 44px; background: none; border: 0; color: var(--muted); cursor: pointer; }

/* ---- Tablet and below: sidebar becomes a drawer ---- */
@media (max-width: 991.98px) {
    .admin-sidebar { width: min(280px, 84vw); transform: translateX(-100%); box-shadow: none; }
    .sidebar-open .admin-sidebar { transform: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
    .sidebar-open { overflow: hidden; }
    .sidebar-backdrop { position: fixed; inset: var(--head-h) 0 0; z-index: 1040; background: rgba(20, 16, 12, .45); }
    .sidebar-open .sidebar-backdrop { display: block; }
    .pan-rhs, .sidebar-collapsed .pan-rhs { margin-left: 0; padding: calc(var(--head-h) + 16px) 16px 32px; }
}

/* ---- Phones: table rows become labelled cards ---- */
@media (max-width: 700px) {
    input, select, textarea { font-size: 16px !important; }
    .header-link span { display: none; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat-value { font-size: 24px; }
    .form-inp { padding: 16px; }
    .pan-rhs form .btn:not(.btn-sm) { width: 100%; }

    .table-wrap:has(.table-cards), .box-com:has(.table-cards) { padding: 0; }
    .box-com:has(.table-cards) { background: none; border: 0; box-shadow: none; }
    .table-wrap:has(.table-cards) { overflow: visible; background: none; border: 0; box-shadow: none; }
    table.table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards thead { display: none; }
    .table-cards tr { margin-bottom: 12px; padding: 4px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
    .table-cards tr > td {
        display: flex; justify-content: space-between; align-items: center; gap: 16px;
        padding: 10px 0; text-align: right; overflow-wrap: anywhere;
        background: none !important; box-shadow: none !important;
        border: 0; border-bottom: 1px solid var(--line);
    }
    .table-cards tr > td:last-child { border-bottom: 0; }
    .table-cards td::before { content: attr(data-label); flex: none; max-width: 45%; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; }
    .table-cards td:not([data-label])::before { display: none; }
    .table-cards td img { max-width: 96px; height: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .admin-sidebar, .pan-rhs, .arrow { transition: none !important; }
}
