/* ==========================================================================
   Four Seasons Tailor — application styles (RTL, light/dark)
   ========================================================================== */

@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-arabic-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root,
[data-bs-theme="light"] {
    --ink-900: #121a2e;
    --ink-800: #18233d;
    --ink-700: #22304f;
    --ink-500: #3d4c6e;
    --brass-500: #b38a3e;
    --brass-400: #c9a560;
    --brass-100: #f6eedd;
    --paper: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --line: #e3e6ec;
    --text: #1b2333;
    --text-muted: #667085;
    --ok: #1f8a5b;
    --warn: #b7791f;
    --danger: #c0392b;
    --row-remain: #fff9db;
    --row-handed: #e3f6e9;
    --row-returned: #fde8e6;

    --bs-body-font-family: "Plex Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
    --bs-body-font-size: 0.9rem;
    --bs-body-bg: var(--paper);
    --bs-body-color: var(--text);
    --bs-border-color: var(--line);
    --bs-primary: #22304f;
    --bs-primary-rgb: 34, 48, 79;
    --bs-link-color: #2b4c8c;
    --bs-link-color-rgb: 43, 76, 140;
    --bs-border-radius: .5rem;
    --sidebar-w: 268px;
}

[data-bs-theme="dark"] {
    --paper: #0e1320;
    --surface: #161d2d;
    --surface-2: #1b2336;
    --line: #2a3349;
    --text: #e5e9f1;
    --text-muted: #9aa4b8;
    --ink-900: #090d17;
    --ink-800: #0c1220;
    --brass-100: #3a301b;
    --row-remain: #3b3518;
    --row-handed: #183626;
    --row-returned: #3d1f1c;
    --bs-body-bg: var(--paper);
    --bs-body-color: var(--text);
    --bs-border-color: var(--line);
    --bs-primary: #5b7fc7;
    --bs-primary-rgb: 91, 127, 199;
    --bs-link-color: #8fb0ef;
    --bs-link-color-rgb: 143, 176, 239;
}

html, body { min-height: 100%; }
body { background: var(--paper); color: var(--text); font-feature-settings: "tnum" 1; }
.btn-primary { --bs-btn-bg: var(--ink-700); --bs-btn-border-color: var(--ink-700); --bs-btn-hover-bg: var(--ink-800); --bs-btn-hover-border-color: var(--ink-800); --bs-btn-active-bg: var(--ink-900); }
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #3d5a96; --bs-btn-border-color: #3d5a96; --bs-btn-hover-bg: #4a69aa; --bs-btn-hover-border-color: #4a69aa; }
.btn-brass { --bs-btn-color: #1b1406; --bs-btn-bg: var(--brass-400); --bs-btn-border-color: var(--brass-400); --bs-btn-hover-bg: var(--brass-500); --bs-btn-hover-border-color: var(--brass-500); --bs-btn-hover-color: #fff; }
.btn-icon { width: 2rem; height: 2rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.text-muted, .form-text { color: var(--text-muted) !important; }
:focus-visible { outline: 2px solid var(--brass-500); outline-offset: 2px; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--ink-800), var(--ink-900));
    color: #d9deea; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
    border-inline-start: 1px solid rgba(255,255,255,.04);
    z-index: 1030;
}
.sidebar-brand { display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark { width: 2.2rem; height: 2.2rem; border-radius: .6rem; display: grid; place-items: center; background: var(--brass-400); color: var(--ink-900); }
.brand-logo { max-height: 2.4rem; max-width: 3.4rem; border-radius: .35rem; background: #fff; padding: 2px; }
.brand-text { font-weight: 600; line-height: 1.3; font-size: .95rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .6rem .5rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-leaf { display: block; color: #c4cbdb; text-decoration: none; padding: .42rem .9rem; border-radius: .45rem; font-size: .86rem; position: relative; }
.nav-leaf:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-leaf.active { background: rgba(201,165,96,.16); color: #fff; font-weight: 600; }
.nav-leaf.active::before { content: ""; position: absolute; inset-inline-start: 0; top: .35rem; bottom: .35rem; width: 3px; border-radius: 3px; background: var(--brass-400); }
.nav-leaf.top, .nav-group-toggle { display: flex; align-items: center; gap: .65rem; padding: .55rem .8rem; font-size: .9rem; }
.nav-leaf.top i, .nav-group-toggle > i:first-child { width: 1.1rem; text-align: center; color: var(--brass-400); }
.nav-group-toggle { width: 100%; background: none; border: 0; color: #e6e9f2; border-radius: .45rem; text-align: start; }
.nav-group-toggle:hover { background: rgba(255,255,255,.06); }
.nav-group-toggle .caret { margin-inline-start: auto; font-size: .7rem; opacity: .6; transition: transform .2s; }
.nav-group.open .caret { transform: rotate(180deg); }
.nav-children { display: none; padding: .15rem .9rem .35rem 0; margin-inline-start: 1.1rem; border-inline-start: 1px dashed rgba(255,255,255,.12); }
.nav-group.open .nav-children { display: block; }
.sidebar-foot { padding: .75rem 1.1rem; border-top: 1px solid rgba(255,255,255,.07); font-size: .85rem; }
.theme-switch { display: flex; align-items: center; gap: .5rem; cursor: pointer; color: #c4cbdb; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
    padding: .6rem 1.25rem; background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.header-branch { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.branch-chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 2rem; padding: .3rem .85rem; display: inline-flex; gap: .45rem; align-items: center; font-weight: 600; font-size: .85rem; }
.branch-chip i:first-child { color: var(--brass-500); }
.header-date { color: var(--text-muted); font-size: .82rem; }
.header-actions { margin-inline-start: auto; display: flex; gap: .5rem; align-items: center; }
.user-btn { border: 1px solid var(--line); }
.app-content { padding: 1.25rem; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-title { font-size: 1.25rem; font-weight: 700; margin: 0; }

/* Wide forms (e.g. the tailoring-order form) start with the side menu collapsed on desktop; the header button shows it over the page */
@media (min-width: 992px) {
    body.sidebar-collapsed-lg .app-sidebar { position: fixed; inset-inline-start: 0; transform: translateX(100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    body.sidebar-collapsed-lg.sidebar-peek .app-sidebar { transform: none; }
}
@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; inset-inline-start: 0; transform: translateX(100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .app-sidebar.show { transform: none; }
    .app-content { padding: .9rem; }
}

/* ---------- cards / panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: .75rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; padding: .75rem 1rem; }
.section-title { font-size: .95rem; font-weight: 700; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.section-title::before { content: ""; width: 4px; height: 1rem; border-radius: 2px; background: var(--brass-400); }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .form-group { min-width: 150px; }

/* ---------- forms ---------- */
.form-label { font-weight: 500; font-size: .84rem; margin-bottom: .3rem; color: var(--text); }
.form-label .req { color: var(--danger); }
.form-control, .form-select { background-color: var(--surface); border-color: var(--line); font-size: .88rem; }
.form-control[readonly], .form-control:disabled, .form-select:disabled { background-color: var(--surface-2); }
.is-invalid ~ .invalid-feedback { display: block; }
.input-group-text { background: var(--surface-2); border-color: var(--line); }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--line); }
.money { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.sar::after { content: " ر.س"; font-size: .8em; color: var(--text-muted); }

/* ---------- tables ---------- */
.table { --bs-table-bg: var(--surface); --bs-table-color: var(--text); --bs-table-border-color: var(--line); --bs-table-hover-bg: var(--surface-2); font-size: .86rem; margin-bottom: 0; }
.table thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; color: var(--text-muted); font-size: .8rem; }
.table td, .table th { vertical-align: middle; }
table.dataTable tbody tr.row-remain > * { background-color: var(--row-remain) !important; }
table.dataTable tbody tr.row-handed > * { background-color: var(--row-handed) !important; }
table.dataTable tbody tr.row-returned > * { background-color: var(--row-returned) !important; }
div.dt-container .dt-search input { margin-inline-start: .5rem; }
div.dt-container .dt-paging .page-link { padding: .25rem .6rem; }
.dt-actions { white-space: nowrap; display: flex; gap: .25rem; justify-content: center; }
.dt-actions .btn { --bs-btn-padding-y: .2rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .8rem; }
.lines-table input.form-control, .lines-table select.form-select { min-width: 70px; padding: .25rem .4rem; font-size: .84rem; }

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: .75rem; padding: 1rem 1.1rem; position: relative; overflow: hidden; }
.kpi .kpi-label { color: var(--text-muted); font-size: .8rem; margin-bottom: .35rem; }
.kpi .kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.kpi .kpi-sub { color: var(--text-muted); font-size: .78rem; margin-top: .35rem; }
.kpi .kpi-icon { position: absolute; inset-inline-end: 1rem; top: 1rem; color: var(--brass-500); opacity: .85; font-size: 1.2rem; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
.quick-link { display: flex; gap: .75rem; align-items: flex-start; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); color: var(--text); text-decoration: none; }
.quick-link:hover { border-color: var(--brass-400); background: var(--brass-100); }
.quick-link i { color: var(--brass-500); margin-top: .2rem; }
.quick-link small { display: block; color: var(--text-muted); }

/* ---------- badges / states ---------- */
.badge-state { padding: .3em .6em; border-radius: 1rem; font-weight: 600; font-size: .75rem; border: 1px solid transparent; }
.state-1 { background: #e8f0fe; color: #1c4e9c; }
.state-2 { background: #fdecec; color: #a12b22; }
.state-3 { background: #e5f6ec; color: #17734a; }
.state-4 { background: #eceff3; color: #3b4659; }
.state-5 { background: #fff4e0; color: #8a5a07; }
.state-6, .state-7 { background: #f1e9fb; color: #5b2a91; }
[data-bs-theme="dark"] .badge-state { filter: brightness(.85) saturate(1.2); }
.zatca-ok { color: var(--ok); }
.zatca-wait { color: var(--warn); }
.zatca-fail { color: var(--danger); }

/* ---------- login ---------- */
.blank-body { min-height: 100vh; display: grid; place-items: center; background:
    radial-gradient(1200px 600px at 85% -10%, rgba(201,165,96,.22), transparent 60%),
    linear-gradient(160deg, var(--ink-800), var(--ink-900)); padding: 1rem; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 1rem; padding: 2rem 1.75rem; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-card .logo { display: grid; place-items: center; margin-bottom: 1rem; }
.login-card .logo img { max-height: 70px; }
.login-card h1 { font-size: 1.15rem; text-align: center; margin-bottom: 1.25rem; font-weight: 700; }

/* ---------- misc ---------- */
.select2-container--bootstrap-5 .select2-selection { min-height: calc(1.5em + .75rem + 2px); border-color: var(--line); background-color: var(--surface); }
.select2-container--bootstrap-5 .select2-dropdown { background-color: var(--surface); border-color: var(--line); }
/* select2 text follows the theme (dark mode would otherwise show dark text on a dark surface) */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered,
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered,
.select2-container--bootstrap-5 .select2-search__field,
.select2-container--bootstrap-5 .select2-dropdown .select2-results__option { color: var(--text); }
.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field { background-color: var(--surface-2); border-color: var(--line); }
.select2-container--bootstrap-5 .select2-selection__placeholder { color: var(--text-muted); }
[data-bs-theme=dark] .select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted { color: var(--text); background-color: var(--surface-2); }
.flatpickr-calendar { font-family: inherit; }
.toast-container { z-index: 2000; }
.empty-state { text-align: center; color: var(--text-muted); padding: 2.5rem 1rem; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px); padding: .75rem; border-top: 1px solid var(--line); z-index: 5; border-radius: 0 0 .75rem .75rem; }
.loading-overlay { position: fixed; inset: 0; background: rgba(10, 14, 25, .35); display: none; place-items: center; z-index: 3000; }
.loading-overlay.show { display: grid; }
.spinner { width: 3rem; height: 3rem; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); border-top-color: var(--brass-400); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- customer rating page ---------- */
.rate-card .rate-input { display: flex; flex-direction: row-reverse; justify-content: center; gap: .35rem; border: 0; padding: 0; }
.rate-card .rate-input input { position: absolute; opacity: 0; pointer-events: none; }
.rate-card .rate-input label { font-size: 2.2rem; color: var(--bs-secondary-bg, #d9dce3); cursor: pointer; transition: color .12s ease, transform .12s ease; }
.rate-card .rate-input input:checked ~ label,
.rate-card .rate-input label:hover,
.rate-card .rate-input label:hover ~ label { color: #f4b400; }
.rate-card .rate-input input:focus-visible + label { outline: 2px solid var(--bs-primary); outline-offset: 3px; border-radius: .25rem; }
.rate-card .rate-stars-static { font-size: 2rem; color: #f4b400; }
