/* Sales & Inventory System – theme follows the design: charcoal background, teal tiles & table headers */
@font-face { font-family: 'Cairo'; src: url('../vendor/fonts/Cairo.ttf') format('truetype'); font-weight: 200 1000; font-display: swap; }

:root {
  --charcoal: #34373b;
  --charcoal-2: #45494e;
  --charcoal-3: #5a5f65;
  --teal: #5b93a6;
  --teal-dark: #457c8f;
  --teal-deep: #2f6375;
  --teal-light: #dce9ee;
  --row: #e3e8eb;
  --row-alt: #f1f4f5;
  --olive: #56693f;
  --olive-dark: #44552f;
  --paper: #ffffff;
  --ink: #1f2427;
  --muted: #6b747a;
  --danger: #b5413b;
  --warning: #c98a1b;
  --success: #3f8a5a;
  --radius: 6px;
  --font: 'Segoe UI', 'Cairo', Tahoma, Arial, sans-serif;
}

html[dir="rtl"] { --font: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif; }

body.app {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--charcoal);
  background-image:
    radial-gradient(ellipse 900px 600px at 105% -10%, rgba(255,255,255,.06) 0 60%, transparent 60.5%),
    radial-gradient(ellipse 1100px 800px at -15% 110%, rgba(255,255,255,.05) 0 55%, transparent 55.5%),
    linear-gradient(160deg, #3d4044 0%, #2d3034 100%);
  background-attachment: fixed;
  min-height: 100vh;
  font-size: .925rem;
}

/* ---------- Banner (company name & logo) ---------- */
.banner {
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.25rem;
  background: linear-gradient(90deg, var(--teal-deep), var(--teal));
  color: #fff;
  border-bottom: 3px solid rgba(0,0,0,.15);
  position: sticky; top: 0; z-index: 1030;
}
.banner .logo { height: 52px; width: 52px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.banner .logo-placeholder { height: 52px; width: 52px; border-radius: 8px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 1.6rem; }
.banner .company { line-height: 1.15; min-width: 0; }
.banner .company .name { font-weight: 700; font-size: 1.15rem; letter-spacing: .3px; }
.banner .company .name-ar { font-family: 'Cairo', sans-serif; font-weight: 700; opacity: .95; }
.banner .company .meta { font-size: .75rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner .system-title { margin-inline-start: auto; text-align: end; font-weight: 600; letter-spacing: 1.5px; font-size: .8rem; opacity: .9; }
.banner .btn-banner { color: #fff; border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.08); }
.banner .btn-banner:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: calc(100vh - 72px); }
.sidebar {
  width: 248px; flex-shrink: 0;
  background: rgba(20,22,25,.35);
  border-inline-end: 1px solid rgba(255,255,255,.06);
  padding: .75rem .5rem 2rem;
}
.sidebar .nav-link {
  color: #d9e2e6; border-radius: var(--radius); padding: .45rem .7rem; font-size: .86rem;
  display: flex; align-items: center; gap: .6rem; margin-bottom: 2px;
}
.sidebar .nav-link i { font-size: 1.05rem; color: #9fc3cf; width: 1.2rem; text-align: center; }
.sidebar .nav-link:hover { background: rgba(91,147,166,.25); color: #fff; }
.sidebar .nav-link.active { background: var(--teal); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.sidebar .nav-link.active i { color: #fff; }
.content { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 3rem; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; inset-block: 72px 0; inset-inline-start: 0; z-index: 1040; background: var(--charcoal); transform: translateX(-100%); transition: transform .2s; overflow-y: auto; }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.show { transform: none !important; }
  .content { padding: 1rem .75rem 3rem; }
  .banner .system-title, .banner .company .meta { display: none; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; color: #fff; }
.page-head h1 { font-size: 1.6rem; font-weight: 300; margin: 0; letter-spacing: .3px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb-lite { color: #aeb9bf; font-size: .8rem; }

/* ---------- Cards & forms: “teal header + striped rows” like the design ---------- */
.panel { background: var(--paper); border-radius: var(--radius); box-shadow: 0 4px 18px rgba(0,0,0,.25); margin-bottom: 1.25rem; overflow: hidden; }
.panel-head { background: var(--teal); color: #fff; padding: .55rem 1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.panel-head .actions { margin-inline-start: auto; display: flex; gap: .35rem; }
.panel-body { padding: 1rem; }
.panel-note { background: var(--row-alt); border-top: 1px solid var(--row); padding: .55rem 1rem; font-size: .8rem; color: var(--muted); }

.form-label { font-size: .8rem; font-weight: 600; color: #3c464c; margin-bottom: .2rem; }
.form-control, .form-select { border-radius: 4px; border-color: #c5d0d5; font-size: .9rem; }
.form-control:focus, .form-select:focus { border-color: var(--teal); box-shadow: 0 0 0 .2rem rgba(91,147,166,.25); }
.ar-input { font-family: 'Cairo', sans-serif; direction: rtl; }

/* striped form list (design: label rows on alternating grey) */
.field-rows .row-item { background: var(--row); padding: .5rem .8rem; border-bottom: 1px solid #fff; }
.field-rows .row-item:nth-child(even) { background: var(--row-alt); }

/* Buttons */
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-teal:hover, .btn-teal:focus { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.btn-olive { background: var(--olive); border-color: var(--olive); color: #fff; }
.btn-olive:hover { background: var(--olive-dark); border-color: var(--olive-dark); color: #fff; }
.btn-outline-teal { border-color: var(--teal); color: var(--teal-dark); }
.btn-outline-teal:hover { background: var(--teal); color: #fff; }

/* Tables */
.table-app { margin: 0; font-size: .87rem; }
.table-app thead th { background: var(--teal); color: #fff; font-weight: 600; border-color: rgba(255,255,255,.25); white-space: nowrap; vertical-align: middle; }
.table-app tbody tr:nth-child(odd) td { background: var(--row); }
.table-app tbody tr:nth-child(even) td { background: var(--row-alt); }
.table-app tbody tr:hover td { background: var(--teal-light); }
.table-app td { vertical-align: middle; border-color: #fff; }
.table-app tfoot td, .table-app tfoot th { background: #d2dde2; font-weight: 700; }
.table-app .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ar { font-family: 'Cairo', sans-serif; direction: rtl; unicode-bidi: isolate; }
.small-muted { font-size: .78rem; color: var(--muted); }

/* Status badges */
.badge-status { font-weight: 600; padding: .35em .6em; border-radius: 4px; font-size: .75rem; text-transform: capitalize; }
.st-pending { background: #f3e2b9; color: #7a5208; }
.st-approved, .st-processing { background: #cfe3ea; color: #1f5566; }
.st-completed, .st-paid { background: #cde8d6; color: #1f5d36; }
.st-partial { background: #f7dcc0; color: #8a4b0c; }
.st-unpaid, .st-rejected, .st-cancelled { background: #f2d0ce; color: #8b2520; }

/* ---------- Dashboard tiles (the design grid) ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .65rem; }
@media (max-width: 1199.98px) { .tile-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 767.98px)  { .tile-grid { grid-template-columns: repeat(2, 1fr); } }
.tile {
  background: var(--teal); color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.35);
  min-height: 92px; padding: .65rem; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .3rem;
  box-shadow: 0 3px 8px rgba(0,0,0,.35); transition: transform .12s, background .12s; font-size: .9rem; line-height: 1.2;
}
.tile i { font-size: 1.5rem; opacity: .9; }
.tile:hover { background: var(--teal-dark); color: #fff; transform: translateY(-2px); }
.tile-company { background: var(--teal); border: 1px solid rgba(255,255,255,.35); color: #fff; padding: .75rem 1rem; text-align: center; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.tile-company img { max-height: 56px; background: #fff; border-radius: 6px; padding: 3px; }

.kpi { background: var(--paper); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: 0 3px 12px rgba(0,0,0,.2); height: 100%; border-inline-start: 5px solid var(--teal); }
.kpi .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 1.25rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi.warn { border-color: var(--warning); } .kpi.danger { border-color: var(--danger); } .kpi.good { border-color: var(--success); }

/* Chart */
.chart-box svg { width: 100%; height: 240px; display: block; }
.chart-legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); }
.chart-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; background: var(--c); }

/* Lookup dropdown */
.lookup-wrap { position: relative; }
.lookup-list { position: absolute; z-index: 1050; inset-inline: 0; top: 100%; background: #fff; border: 1px solid #c5d0d5; border-radius: 0 0 6px 6px; max-height: 320px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,.18); display: none; }
.lookup-list.show { display: block; }
.lookup-item { padding: .45rem .7rem; cursor: pointer; border-bottom: 1px solid #eef1f3; display: flex; justify-content: space-between; gap: .5rem; }
.lookup-item:hover, .lookup-item.active { background: var(--teal-light); }
.lookup-item .ar { color: #345; }

/* Document line table */
.doc-lines input, .doc-lines select { min-width: 70px; }
.doc-lines .name-cell { min-width: 220px; }
.totals-box { background: var(--row-alt); border-radius: var(--radius); padding: .75rem 1rem; }
.totals-box .t-row { display: flex; justify-content: space-between; padding: .25rem 0; border-bottom: 1px dashed #cfd8dc; }
.totals-box .t-row.grand { font-size: 1.15rem; font-weight: 700; border-bottom: 0; color: var(--teal-deep); }
.line-warning { font-size: .72rem; color: var(--danger); }

/* Login */
.login-card { max-width: 420px; margin: 8vh auto; }

/* Print helpers */
@media print {
  .no-print, .banner, .sidebar, .page-head .actions { display: none !important; }
  body.app { background: #fff !important; }
  .content { padding: 0 !important; }
  .panel { box-shadow: none; }
}
.alert { border-radius: var(--radius); }
.pagination { margin: .75rem 1rem; }
.page-link { color: var(--teal-dark); } .active > .page-link { background: var(--teal); border-color: var(--teal); }

/* ---------- refinements ---------- */
div.ar { text-align: left; } html[dir="rtl"] div.ar { text-align: right; }
html[dir="rtl"] .num, html[dir="rtl"] td.text-nowrap, html[dir="rtl"] .kpi .value, html[dir="rtl"] .small-muted { unicode-bidi: plaintext; }
.chart-legend-body { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); padding: .5rem 1rem 0; }
.chart-legend-body span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; background: var(--c); }

/* Phone: item lines become cards so salesmen can work on a mobile */
@media (max-width: 767.98px) {
  .doc-table thead { display: none; }
  .doc-table, .doc-table tbody { display: block; }
  .doc-lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .35rem .5rem; padding: .6rem; border-bottom: 2px solid #fff; }
  .doc-lines tr td { display: block; padding: 0 !important; border: 0; background: transparent !important; }
  .doc-lines tr { background: var(--row); }
  .doc-lines td.name-cell { grid-column: 1 / -1; min-width: 0; }
  .doc-lines td[data-label]::before { content: attr(data-label); display: block; font-size: .7rem; color: var(--muted); font-weight: 600; }
  .doc-lines td.num { text-align: start; }
  .doc-lines td:last-child { text-align: end; align-self: end; }
  .doc-table tr.empty-row { display: block; }
}

@media (max-width: 575.98px) {
  .banner { padding: .5rem .6rem; gap: .5rem; }
  .banner .company .name-ar { display: none; }
  .banner .company .name { font-size: .95rem; }
  .banner .logo, .banner .logo-placeholder { height: 40px; width: 40px; }
  .page-head h1 { font-size: 1.3rem; }
}
