/* ===== AutoCare UI =====
   Fonts and icons are bundled in wwwroot/lib so the app works without internet. */

@font-face { font-family: "Cairo"; font-weight: 400; font-display: swap; src: url("../lib/cairo/cairo-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE80-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 400; font-display: swap; src: url("../lib/cairo/cairo-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 600; font-display: swap; src: url("../lib/cairo/cairo-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE80-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 600; font-display: swap; src: url("../lib/cairo/cairo-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 700; font-display: swap; src: url("../lib/cairo/cairo-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE80-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 700; font-display: swap; src: url("../lib/cairo/cairo-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ac-primary: #dc2626;
  --ac-primary-dark: #b91c1c;
  --ac-accent: #f59e0b;
  --ac-ink: #0f172a;
  --ac-muted: #64748b;
  --ac-line: #e2e8f0;
  --ac-bg: #f1f5f9;
  --ac-card: #ffffff;
  --ac-side: #0f172a;
  --ac-side-text: #cbd5e1;
  --ac-radius: 14px;
  --ac-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .04);

  --bs-font-sans-serif: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-body-bg: var(--ac-bg);
  --bs-body-color: var(--ac-ink);
  --bs-primary: #dc2626;
  --bs-primary-rgb: 220, 38, 38;
  --bs-link-color: #dc2626;
  --bs-link-color-rgb: 220, 38, 38;
  --bs-link-hover-color: #b91c1c;
  --bs-border-color: var(--ac-line);
  --bs-border-radius: .65rem;
  --bs-secondary-color: var(--ac-muted);
}

html { font-size: 15px; }
@media (min-width: 992px) { html { font-size: 16px; } }

body { background: var(--ac-bg); color: var(--ac-ink); -webkit-font-smoothing: antialiased; }
.text-muted { color: var(--ac-muted) !important; }
h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: 0; }
h2 { font-size: 1.45rem; }
h5 { font-size: 1.05rem; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
a.btn:hover, .side-link:hover, .quick-tile:hover, .dropdown-item:hover, .nav-link:hover { text-decoration: none; }

/* ----- Buttons ----- */
.btn { border-radius: .65rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { border-radius: .55rem; padding: .25rem .6rem; }
.btn-lg { border-radius: .8rem; }
.btn-link { font-weight: 600; }
.btn-primary { --bs-btn-bg: #dc2626; --bs-btn-border-color: #dc2626; --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c; --bs-btn-active-bg: #991b1b; --bs-btn-active-border-color: #991b1b; --bs-btn-disabled-bg: #dc2626; --bs-btn-disabled-border-color: #dc2626; --bs-btn-focus-shadow-rgb: 220, 38, 38; }
.btn-outline-primary { --bs-btn-color: #dc2626; --bs-btn-border-color: #fecaca; --bs-btn-hover-bg: #dc2626; --bs-btn-hover-border-color: #dc2626; --bs-btn-active-bg: #b91c1c; --bs-btn-active-border-color: #b91c1c; }
.btn-outline-secondary { --bs-btn-color: #475569; --bs-btn-border-color: #cbd5e1; --bs-btn-hover-bg: #475569; --bs-btn-hover-border-color: #475569; }
.btn-outline-danger { --bs-btn-border-color: #fecaca; }
.btn-outline-success { --bs-btn-border-color: #bbf7d0; }
.btn-outline-warning { --bs-btn-border-color: #fde68a; }
.btn-outline-info { --bs-btn-border-color: #a5f3fc; }
.btn-outline-dark { --bs-btn-border-color: #cbd5e1; }
.btn .bi { font-size: 1.05em; line-height: 1; }

/* ----- Forms ----- */
.form-control, .form-select { border-radius: .65rem; border-color: #cbd5e1; padding: .5rem .8rem; background-color: #fff; }
.form-control:focus, .form-select:focus { border-color: #f87171; box-shadow: 0 0 0 .22rem rgba(220, 38, 38, .15); }
.form-control-sm, .form-select-sm { border-radius: .55rem; padding: .25rem .6rem; }
.form-label { font-weight: 600; color: #334155; margin-bottom: .3rem; }
.form-text { color: var(--ac-muted); }
.form-check-input:checked { background-color: var(--ac-primary); border-color: var(--ac-primary); }
.form-check-input { cursor: pointer; }
.form-check-label { cursor: pointer; }
.input-group-text { background: #f8fafc; border-color: #cbd5e1; color: var(--ac-muted); }
input[type=date], input[type=datetime-local], input[type=number] { font-variant-numeric: tabular-nums; }

/* ----- Cards ----- */
.card { border: 1px solid var(--ac-line); border-radius: var(--ac-radius); box-shadow: var(--ac-shadow); background: var(--ac-card); }
.card-header { background: #f8fafc; border-bottom: 1px solid var(--ac-line); font-weight: 700; border-radius: var(--ac-radius) var(--ac-radius) 0 0 !important; }
.card-footer { background: #f8fafc; border-top: 1px solid var(--ac-line); border-radius: 0 0 var(--ac-radius) var(--ac-radius) !important; }
main .border.rounded, main .border.rounded-2 { background: #fff; border-color: var(--ac-line) !important; border-radius: 12px !important; box-shadow: var(--ac-shadow); }

/* ----- Tables ----- */
.table-card { background: #fff; border: 1px solid var(--ac-line); border-radius: var(--ac-radius); box-shadow: var(--ac-shadow); margin-bottom: 1rem; }
.table-card > .table { margin-bottom: 0; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: #f8fafc; --bs-table-striped-bg: #f8fafc; border-color: var(--ac-line); }
.table > :not(caption) > * > * { padding: .65rem .85rem; }
.table > thead > tr > th { background: #f8fafc; color: #475569; font-weight: 700; font-size: .88rem; white-space: nowrap; border-bottom-width: 1px; }
.table-bordered > :not(caption) > * { border-width: 0 0 1px 0; }
.table-bordered > :not(caption) > * > * { border-width: 0; }
.table tbody tr:last-child > * { border-bottom-width: 0; }
.table-hover > tbody > tr:hover > *, .table-card .table > tbody > tr:hover > * { background-color: #f8fafc; }
.table-sm > :not(caption) > * > * { padding: .4rem .6rem; }
.table caption { color: var(--ac-ink); padding: .5rem .85rem; }
tfoot th, tfoot td { background: #f8fafc; }

/* ----- Badges / alerts ----- */
.badge { font-weight: 600; border-radius: 999px; padding: .38em .7em; }
.alert { border: 0; border-radius: 12px; display: flex; align-items: flex-start; gap: .6rem; }
.alert .bi { font-size: 1.15rem; margin-top: .1rem; }
.alert-success { background: #dcfce7; color: #14532d; }
.alert-danger { background: #fee2e2; color: #7f1d1d; }
.alert-warning { background: #fef3c7; color: #78350f; }
.alert-info { background: #fee2e2; color: #7f1d1d; }
.alert-secondary { background: #e2e8f0; color: #334155; }
.validation-summary-errors ul, .text-danger ul { margin: 0; padding-inline-start: 1.1rem; }
.field-validation-error, span.text-danger { font-size: .88rem; }
.list-group-item-action { border-color: var(--ac-line); }

/* ----- App shell ----- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 262px; flex: 0 0 262px; background: var(--ac-side); color: var(--ac-side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040; }
.side-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.2rem; color: #fff; font-weight: 800; font-size: 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.side-brand:hover { color: #fff; text-decoration: none; }
.side-brand .logo { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #ef4444, #dc2626); display: grid; place-items: center; font-size: 1.35rem; color: #fff; box-shadow: 0 6px 16px rgba(220, 38, 38, .35); }
.side-nav { padding: .8rem .75rem 1.5rem; flex: 1; }
.side-section { font-size: .74rem; font-weight: 700; letter-spacing: .04em; color: #64748b; padding: 1rem .8rem .35rem; }
.side-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .85rem; margin: 2px 0; border-radius: 10px; color: var(--ac-side-text); font-weight: 600; font-size: .96rem; position: relative; }
.side-link .bi { font-size: 1.15rem; width: 1.3rem; text-align: center; opacity: .9; }
.side-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-link.active { background: rgba(220, 38, 38, .28); color: #fff; }
.side-link.active::before { content: ""; position: absolute; inset-inline-start: -.75rem; top: 20%; bottom: 20%; width: 4px; border-radius: 4px; background: var(--ac-accent); }
.side-link.primary { background: var(--ac-primary); color: #fff; margin: .4rem 0 .2rem; }
.side-link.primary:hover { background: var(--ac-primary-dark); }
.side-link .badge { margin-inline-start: auto; }
.side-foot { padding: .9rem 1.2rem; font-size: .78rem; color: #64748b; border-top: 1px solid rgba(255, 255, 255, .08); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1030; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--ac-line); height: 62px; display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; }
.topbar .page-name { font-weight: 700; color: var(--ac-ink); }
.topbar .spacer { flex: 1; }
.menu-btn { border: 0; background: #f1f5f9; width: 40px; height: 40px; border-radius: 10px; font-size: 1.3rem; display: none; }
.user-chip { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--ac-line); background: #fff; border-radius: 999px; padding: .25rem .8rem .25rem .3rem; font-weight: 600; color: var(--ac-ink); }
.user-chip:hover { background: #f8fafc; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #dc2626, #7f1d1d); color: #fff; display: grid; place-items: center; font-weight: 700; }
.user-chip small { display: block; color: var(--ac-muted); font-weight: 600; line-height: 1; font-size: .72rem; }
.branch-pill { display: flex; align-items: center; gap: .5rem; background: #fef2f2; color: #991b1b; border-radius: 999px; padding: .25rem .8rem; font-weight: 700; }
.branch-pill img { height: 24px; width: auto; border-radius: 4px; }
.branch-pill select { border: 0; background-color: transparent; font-weight: 700; color: #991b1b; padding: .1rem 1.6rem .1rem .2rem; box-shadow: none; cursor: pointer; }
.dropdown-menu { border-radius: 12px; border-color: var(--ac-line); box-shadow: 0 10px 30px rgba(15, 23, 42, .12); padding: .4rem; }
.dropdown-item { border-radius: 8px; display: flex; align-items: center; gap: .6rem; font-weight: 600; padding: .5rem .8rem; }

.app-content { padding: 1.4rem 1.4rem 2rem; flex: 1; }
.powered-by { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 1.1rem 1.4rem 1.4rem; }
.powered-by-line { flex: 1; max-width: 120px; height: 1px; background: linear-gradient(to right, transparent, var(--ac-line)); }
.powered-by-line:last-child { background: linear-gradient(to left, transparent, var(--ac-line)); }
.powered-by-text { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ac-muted); }
.powered-by-badge { font-size: .8rem; font-weight: 800; letter-spacing: .08em; color: #fff; background: linear-gradient(135deg, var(--ac-primary), var(--ac-primary-dark)); padding: 3px 12px; border-radius: 999px; box-shadow: 0 2px 6px rgba(220, 38, 38, .28); }
.app-footer { padding: 1rem 1.4rem; color: var(--ac-muted); font-size: .85rem; border-top: 1px solid var(--ac-line); }
.page-icon { color: var(--ac-primary); margin-inline-end: .5rem; }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; transform: translateX(100%); transition: transform .25s ease; width: 280px; box-shadow: none; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 1035; }
  .menu-btn { display: grid; place-items: center; }
  .app-content { padding: 1rem .9rem 2rem; }
  .topbar { padding: 0 .8rem; }
  .user-chip .who { display: none; }
  .user-chip { padding: .25rem; }
  .branch-pill select { max-width: 130px; }
  h2 { font-size: 1.25rem; }
}

/* ----- Home / dashboard ----- */
.hero { background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 55%, #ef4444 100%); color: #fff; border-radius: 18px; padding: 1.5rem 1.6rem; position: relative; overflow: hidden; box-shadow: 0 10px 30px rgba(220, 38, 38, .25); }
.hero::after { content: "\F7E0"; font-family: "bootstrap-icons"; position: absolute; inset-inline-end: -10px; bottom: -34px; font-size: 11rem; color: rgba(255, 255, 255, .08); line-height: 1; }
.hero h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
.hero .meta { opacity: .9; display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; font-weight: 600; }
.hero .meta i { margin-inline-end: .35rem; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; }
.quick-tile { background: #fff; border: 1px solid var(--ac-line); border-radius: 16px; padding: 1.1rem .8rem; text-align: center; color: var(--ac-ink); font-weight: 700; box-shadow: var(--ac-shadow); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; display: block; }
.quick-tile:hover { transform: translateY(-3px); border-color: #fecaca; box-shadow: 0 10px 24px rgba(220, 38, 38, .14); color: var(--ac-ink); }
.quick-tile .ico { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto .6rem; display: grid; place-items: center; font-size: 1.6rem; }
.quick-tile.main { background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff; border-color: transparent; }
.quick-tile.main:hover { color: #fff; }
.quick-tile.main .ico { background: rgba(255, 255, 255, .2); color: #fff; }
.tone-blue { background: #fee2e2; color: #b91c1c; }
.tone-green { background: #dcfce7; color: #15803d; }
.tone-amber { background: #fef3c7; color: #b45309; }
.tone-red { background: #fee2e2; color: #b91c1c; }
.tone-violet { background: #ede9fe; color: #6d28d9; }
.tone-teal { background: #ccfbf1; color: #0f766e; }
.tone-slate { background: #e2e8f0; color: #334155; }
.stat-card { background: #fff; border: 1px solid var(--ac-line); border-radius: 16px; padding: 1rem 1.1rem; box-shadow: var(--ac-shadow); display: flex; gap: .9rem; align-items: center; height: 100%; }
.stat-card .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.45rem; flex: 0 0 48px; }
.stat-card .label { color: var(--ac-muted); font-size: .85rem; font-weight: 600; }
.stat-card .value { font-size: 1.35rem; font-weight: 800; line-height: 1.2; }
.stat-card .sub { color: var(--ac-muted); font-size: .8rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 1.6rem 0 .8rem; }
.section-title h5 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.list-rows .row-item { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; border-bottom: 1px solid var(--ac-line); }
.list-rows .row-item:last-child { border-bottom: 0; }
.list-rows .time { min-width: 62px; font-weight: 800; color: var(--ac-primary); font-variant-numeric: tabular-nums; }
.list-rows .grow { flex: 1; min-width: 0; }
.list-rows .grow .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-rows .grow .s { color: var(--ac-muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-state { text-align: center; color: var(--ac-muted); padding: 1.6rem 1rem; }
.empty-state .bi { font-size: 2rem; display: block; margin-bottom: .3rem; opacity: .6; }
.bars { display: flex; align-items: flex-end; gap: .6rem; height: 170px; padding: 1rem 1rem .4rem; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar { width: 100%; max-width: 46px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #ef4444, #dc2626); min-height: 3px; }
.bars .bar.today { background: linear-gradient(180deg, #f59e0b, #f97316); }
.bars .bar-val { font-size: .72rem; color: var(--ac-muted); font-weight: 700; margin-bottom: 3px; white-space: nowrap; }
.bars .bar-lbl { font-size: .75rem; color: var(--ac-muted); margin-top: 6px; font-weight: 600; }

/* ----- Login ----- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: radial-gradient(1200px 500px at 80% -10%, rgba(220, 38, 38, .25), transparent), linear-gradient(160deg, #0f172a, #1e293b 60%, #0f172a); }
.auth-box { width: 100%; max-width: 410px; }
.auth-brand { text-align: center; color: #fff; margin-bottom: 1.2rem; }
.auth-brand .logo { width: 68px; height: 68px; border-radius: 20px; background: linear-gradient(135deg, #ef4444, #dc2626); display: grid; place-items: center; font-size: 2.1rem; margin: 0 auto .7rem; box-shadow: 0 10px 28px rgba(220, 38, 38, .4); }
.auth-brand h1 { font-size: 1.7rem; margin: 0; font-weight: 800; }
.auth-brand p { color: #94a3b8; margin: .2rem 0 0; }
.auth-card { background: #fff; border-radius: 20px; padding: 1.6rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.auth-card .form-control { padding: .65rem .9rem; }

/* ----- Misc ----- */
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(180deg, transparent, var(--ac-bg) 30%); padding: .8rem 0; }
::selection { background: #fecaca; }
.collapse > td { background: #fff7ed; }

@media print {
  .no-print, .sidebar, .topbar, .app-footer, .sidebar-backdrop, header, footer { display: none !important; }
  body { background: #fff; }
  .app-content { padding: 0; }
  .card, .table-card, .stat-card { box-shadow: none; }
}
