@import url("../../../assets/css/style.css");

/* ==========================================================================
   Admin dashboard — reuses the public site's colour/type tokens and adds
   the app-shell layout (sidebar, topbar, tables, forms) on top.
   ========================================================================== */

body.admin-body { background: var(--paper-2); }

.admin-shell { display: flex; min-height: 100vh; }

/* ----------------------------- sidebar ----------------------------- */
.admin-sidebar {
  width: 246px;
  flex: none;
  background: var(--charcoal);
  color: var(--steel-light);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--charcoal-line);
  color: #fff;
}
.admin-sidebar__brand img { width: 34px; height: 34px; object-fit: contain; }
.admin-sidebar__brand span { font-family: var(--font-head); font-size: 16px; font-weight: 700; line-height: 1.2; }
.admin-sidebar__brand small { display: block; font-family: var(--font-body); font-size: 10.5px; color: var(--steel-light); font-weight: 400; }

.admin-nav { flex: 1; overflow-y: auto; padding: 14px 0; }
.admin-nav__group { margin-top: 4px; }
.admin-nav__group:first-child { margin-top: 0; }
.admin-nav__group-label { padding: 10px 20px 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--steel-light); opacity: .55; font-weight: 700; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--steel-light);
  border-left: 3px solid transparent;
}
.admin-nav a .icon { width: 18px; height: 18px; }
.admin-nav a:hover { color: #fff; background: var(--charcoal-2); }
.admin-nav a.is-active { color: #fff; background: var(--charcoal-2); border-left-color: var(--yellow); }
.admin-nav .count-chip {
  margin-left: auto;
  background: var(--rust);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
}

.admin-sidebar__foot { padding: 16px 20px; border-top: 1px solid var(--charcoal-line); font-size: 13px; }
.admin-sidebar__foot .who { color: #fff; font-weight: 700; }
.admin-sidebar__foot .role { color: var(--steel-light); font-size: 12px; margin-bottom: 10px; }
.admin-sidebar__foot a { color: var(--yellow); font-weight: 600; font-size: 13px; }

/* ----------------------------- main / topbar ----------------------------- */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar {
  background: var(--paper-3);
  border-bottom: 1px solid var(--paper-2);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.admin-topbar h1 { font-size: 22px; margin: 0; }
.admin-topbar .sub { color: var(--steel); font-size: 13.5px; margin-top: 2px; }
.admin-topbar__actions { display: flex; gap: 10px; align-items: center; }
.admin-menu-toggle { display: none; }

.admin-content { padding: 26px 28px 40px; max-width: 100%; flex: 1; }
.admin-footer {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px 16px;
  padding: 11px 28px;
  background: #fff; border-top: 1px solid var(--paper-2);
  font-size: 12.5px; color: var(--steel);
}
.admin-footer a { color: var(--charcoal); font-weight: 600; text-decoration: none; }
.admin-footer a:hover { text-decoration: underline; }
@media (max-width: 600px) { .admin-footer { padding: 10px 16px; justify-content: center; text-align: center; } }

/* ----------------------------- cards / stat grid ----------------------------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 30px; }
.stat-card { background: var(--paper-3); border: 1px solid var(--paper-2); border-left: 4px solid var(--yellow); padding: 18px 20px; }
.stat-card .num { font-family: var(--font-head); font-size: 30px; line-height: 1; margin-bottom: 6px; }
.stat-card .label { font-size: 13px; color: var(--steel); }
.stat-card--warn { border-left-color: var(--rust); }
.stat-card--warn .num { color: var(--rust); }

.panel { background: var(--paper-3); border: 1px solid var(--paper-2); padding: 22px 24px; margin-bottom: 24px; }
.panel h2 { font-size: 19px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; }

/* ----------------------------- tables ----------------------------- */
.table-wrap { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.admin-table th, table.admin-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--paper-2); white-space: nowrap; }
table.admin-table th { font-family: var(--font-body); font-weight: 700; color: var(--steel); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; background: var(--paper); }
table.admin-table tbody tr:hover { background: var(--paper); }
table.admin-table td.wrap { white-space: normal; max-width: 320px; }
.table-empty { padding: 40px 20px; text-align: center; color: var(--steel); }

/* ----------------------------- badges ----------------------------- */
.badge { display: inline-block; padding: 3px 10px; font-size: 12px; font-weight: 700; letter-spacing: .01em; }
.badge--pending { background: rgba(201,150,44,.18); color: var(--yellow-dark); }
.badge--info { background: rgba(31,90,140,.12); color: #1f5a8c; }
.badge--ok { background: rgba(63,122,76,.15); color: var(--green); }
.badge--warn { background: rgba(193,68,45,.12); color: var(--rust); }
.badge--bad { background: rgba(193,68,45,.16); color: var(--rust-dark); }
.badge--muted { background: var(--paper-2); color: var(--steel); }

/* ----------------------------- toolbar / filters ----------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 20px; }
.toolbar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"], .toolbar select {
  padding: 9px 12px;
  border: 1px solid var(--steel-light);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 14px;
}
.toolbar .spacer { flex: 1; }

/* ----------------------------- pagination ----------------------------- */
.pagination { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 7px 12px; border: 1px solid var(--paper-2); font-size: 13.5px; }
.pagination a:hover { border-color: var(--charcoal); }
.pagination .is-current { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }

/* ----------------------------- forms (admin) ----------------------------- */
.admin-form { max-width: 980px; }
.admin-form .form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 760px) { .admin-form .form-grid { grid-template-columns: 1fr; } }
.admin-form .field--full { grid-column: 1 / -1; }
.admin-form label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.admin-form input, .admin-form select, .admin-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--steel-light);
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 14.5px;
}
.admin-form input:focus, .admin-form select:focus, .admin-form textarea:focus { outline: none; border-bottom-color: var(--yellow); }
.admin-form textarea { min-height: 90px; resize: vertical; }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-danger { background: var(--rust); color: #fff; border-color: var(--rust); }
.btn-danger:hover { background: var(--rust-dark); border-color: var(--rust-dark); }

/* ----------------------------- detail / view layout ----------------------------- */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: flex-start; }
@media (max-width: 960px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { margin: 0; }
.kv .row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--paper-2); font-size: 14.5px; }
.kv .row dt { color: var(--steel); }
.kv .row dd { margin: 0; font-weight: 600; text-align: right; }

/* ----------------------------- quotation line items ----------------------------- */
.item-rows { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.item-rows th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--steel); padding: 6px 8px; }
.item-rows td { padding: 6px 8px; }

.part-search { position: relative; max-width: 480px; margin-bottom: 14px; }
.part-search input { width: 100%; }
.part-search-results {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 260px; overflow-y: auto; margin-top: 4px;
}
.part-search-result { padding: 8px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--line); }
.part-search-result:last-child { border-bottom: none; }
.part-search-result:hover { background: rgba(0,0,0,.04); }
.part-search-result span { font-size: 12.5px; color: var(--steel); }
.part-search-result--add { color: var(--green); font-weight: 600; }

/* ----------------------------- modal popup ----------------------------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(20,22,20,.55); align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.is-open { display: flex; }
.modal-box { background: #fff; border-radius: 10px; max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box h3 { margin: 0 0 4px; }
.modal-box .modal-sub { color: var(--steel); font-size: 13px; margin-bottom: 16px; }
.item-rows input { width: 100%; }
.item-rows .col-qty, .item-rows .col-rate, .item-rows .col-amount { width: 110px; }
.item-rows .col-remove { width: 40px; text-align: center; }
.totals-box { max-width: 340px; margin-left: auto; }
.totals-box .row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14.5px; border-bottom: 1px dashed var(--paper-2); }
.totals-box .row.grand { font-weight: 700; font-size: 17px; border-bottom: none; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 10px; }

/* ----------------------------- login screen ----------------------------- */
.admin-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--charcoal);
  padding: 24px;
}
.admin-auth__card { background: var(--paper-3); width: 100%; max-width: 380px; padding: 34px 32px; }
.admin-auth__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.admin-auth__brand img { width: 44px; height: 44px; }
.admin-auth__brand span { font-family: var(--font-head); font-size: 19px; font-weight: 700; }
.admin-auth h1 { font-size: 22px; margin-bottom: 6px; }
.admin-auth p.lede { color: var(--steel); font-size: 14px; margin-bottom: 24px; }
.admin-auth .field { margin-bottom: 18px; }

/* ----------------------------- printable quotation ----------------------------- */
@media print {
  .no-print { display: none !important; }
  .admin-shell, .admin-content { display: block; padding: 0; }
  body.admin-body { background: #fff; }
}

@media (max-width: 900px) {
  .admin-sidebar { position: fixed; left: -260px; z-index: 60; transition: left .2s ease; }
  .admin-sidebar.is-open { left: 0; }
  .admin-menu-toggle { display: inline-flex; }
}

/* ----------------------------- Phase 8: document columns, filters ----------------------------- */
.item-rows--doc { min-width: 860px; }
.item-rows--doc th, .item-rows--doc td { vertical-align: middle; }
.item-rows .col-sn, .doc-table .c-sn { width: 48px; text-align: center; }
#itemRows { counter-reset: sn; }
#itemRows td.col-sn::before { counter-increment: sn; content: counter(sn); font-weight: 600; color: var(--steel); }
.item-rows .col-hsn { width: 110px; }
.item-rows .col-per { width: 84px; }
.item-rows .col-disc { width: 92px; }
.item-rows--doc .col-qty, .item-rows--doc .col-rate { width: 100px; }
.item-rows--doc .col-amount { width: 120px; text-align: right; white-space: nowrap; }

.doc-table { width: 100%; border-collapse: collapse; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); font-size: 13.5px; }
.doc-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; color: var(--steel); padding: 7px 6px; border-bottom: 1px solid var(--ink); }
.doc-table td { padding: 7px 6px; border-bottom: 1px solid var(--paper-2); vertical-align: top; }
.doc-table .c-num { text-align: right; white-space: nowrap; }
.doc-table .c-per, .doc-table .c-hsn { white-space: nowrap; }
.doc-table th.c-num { text-align: right; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar label { font-size: 13px; color: var(--steel); display: flex; align-items: center; gap: 6px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--line); font-size: 13px; text-decoration: none; color: var(--ink); }
.tabs a.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.badge--converted { background: rgba(76,122,63,.15); color: #2e4d26; }

@media print {
  .doc-sheet { border: none !important; box-shadow: none !important; padding: 0 !important; }
  .doc-table { font-size: 12px; }
}

/* ======================================================================
   Phase 12 — professional dashboard + consistent card styling
   ====================================================================== */
:root {
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .05), 0 4px 14px rgba(16, 24, 20, .05);
  --shadow-md: 0 2px 4px rgba(16, 24, 20, .06), 0 10px 26px rgba(16, 24, 20, .09);
  --line: #e4dfd0;
}
body.admin-body { background: #f1efe7; }
.admin-topbar { box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(16, 24, 20, .04); }

/* every panel / card across the admin */
.panel { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.stat-card { border-radius: var(--radius); box-shadow: var(--shadow-sm); border-color: var(--line); }
.stat-card .num { font-family: var(--font-body); font-weight: 700; font-size: 28px; font-variant-numeric: tabular-nums; }
.badge { border-radius: 999px; padding: 3px 11px; }
table.admin-table th { background: #f7f5ef; }
table.admin-table .num, table.admin-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--steel); font-size: 13px; }

/* ---------- hero ---------- */
.dash-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 26px 30px; margin-bottom: 22px; border-radius: 16px; color: #fff;
  background: radial-gradient(circle at 92% 10%, rgba(201, 150, 44, .30), transparent 45%), linear-gradient(120deg, #0b3d31 0%, #0f5646 100%);
  box-shadow: var(--shadow-md);
}
.dash-hero__date { font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; opacity: .72; font-weight: 600; }
.dash-hero h2 { color: #fff; font-size: 27px; margin: 6px 0 4px; }
.dash-hero p { margin: 0; opacity: .88; font-size: 14.5px; }
.dash-hero p strong { color: #f2c75a; }
.dash-hero__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-hero__actions .btn svg { width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 18px; margin-bottom: 24px; }
.kpi {
  position: relative; display: block; padding: 20px 22px 18px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); color: inherit; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi__icon { position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; }
.kpi__icon svg { width: 20px; height: 20px; }
.kpi__icon--green { background: rgba(63, 122, 76, .13); color: var(--green); }
.kpi__icon--gold { background: rgba(201, 150, 44, .17); color: var(--yellow-dark); }
.kpi__icon--blue { background: rgba(31, 90, 140, .12); color: #1f5a8c; }
.kpi__icon--rust { background: rgba(193, 68, 45, .12); color: var(--rust); }
.kpi__label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--steel); padding-right: 50px; }
.kpi__value { font-size: 31px; font-weight: 700; line-height: 1.15; margin: 8px 0 6px; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi__delta { font-size: 12.5px; font-weight: 600; }
.kpi__delta--up { color: var(--green); }
.kpi__delta--down { color: var(--rust); }
.kpi__delta--flat { color: var(--steel); font-weight: 400; }
.kpi__sub { font-size: 12.5px; color: var(--steel); margin-top: 10px; padding-top: 10px; border-top: 1px solid #efece2; }

/* ---------- two-column rows ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 24px; margin-bottom: 24px; align-items: start; }
.dash-grid--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.dash-grid > .panel { margin-bottom: 0; }
@media (max-width: 1100px) { .dash-grid, .dash-grid--even { grid-template-columns: minmax(0, 1fr); } }

/* ---------- chart ---------- */
.dash-chart { width: 100%; height: auto; display: block; }
.dash-chart .grid { stroke: #ebe7da; stroke-width: 1; }
.dash-chart .axis { fill: var(--steel); font-size: 11px; font-family: var(--font-body); }
.dash-chart .bar-a { fill: var(--charcoal); }
.dash-chart .bar-b { fill: var(--yellow); }
.dash-chart rect:hover { opacity: .8; }
.chart-legend { display: flex; gap: 16px; align-items: center; font-size: 12.5px; color: var(--steel); flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-a { background: var(--charcoal); }
.dot-b { background: var(--yellow); }

/* ---------- fleet ---------- */
.fleet-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.fleet-top__num { font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.fleet-top__label { color: var(--steel); font-size: 13.5px; }
.fleet-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #ebe7da; margin-bottom: 18px; }
.fleet-bar span { display: block; height: 100%; }
.seg-ok { background: var(--green); }
.seg-rent { background: #1f5a8c; }
.seg-maint { background: var(--yellow); }
.seg-bad { background: var(--rust); }
.seg-empty { background: #ebe7da; }
.fleet-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.fleet-legend li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px dashed #ece8db; font-size: 14px; }
.fleet-legend li:last-child { border-bottom: 0; }
.fleet-legend li span { flex: 1; color: var(--steel); }
.fleet-legend li strong { font-variant-numeric: tabular-nums; }

/* ---------- needs attention ---------- */
.attn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.attn {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: inherit; text-decoration: none; transition: border-color .15s, background .15s, transform .15s;
}
.attn:hover { transform: translateY(-1px); border-color: var(--charcoal); }
.attn__icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: #f1efe7; color: var(--steel); flex-shrink: 0; }
.attn__icon svg { width: 18px; height: 18px; }
.attn__text { flex: 1; min-width: 0; }
.attn__label { font-size: 13.5px; font-weight: 600; line-height: 1.25; display: block; }
.attn__count { min-width: 34px; height: 30px; padding: 0 10px; border-radius: 999px; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: #f1efe7; color: var(--steel); font-variant-numeric: tabular-nums; }
.attn--zero { opacity: .62; }
.attn--zero:hover { opacity: 1; }
.attn--warn { background: rgba(201, 150, 44, .08); border-color: rgba(201, 150, 44, .40); }
.attn--warn .attn__icon { background: rgba(201, 150, 44, .20); color: var(--yellow-dark); }
.attn--warn .attn__count { background: var(--yellow); color: #fff; }
.attn--info { background: rgba(31, 90, 140, .05); border-color: rgba(31, 90, 140, .28); }
.attn--info .attn__icon { background: rgba(31, 90, 140, .14); color: #1f5a8c; }
.attn--info .attn__count { background: #1f5a8c; color: #fff; }
.attn--bad { background: rgba(193, 68, 45, .07); border-color: rgba(193, 68, 45, .40); }
.attn--bad .attn__icon { background: rgba(193, 68, 45, .16); color: var(--rust); }
.attn--bad .attn__count { background: var(--rust); color: #fff; }

/* ---------- activity feed ---------- */
.feed-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed #ece8db; }
.feed-row:last-of-type { border-bottom: 0; }
.new-pill { margin-left: 6px; display: inline-block; padding: 1px 8px; border-radius: 999px; background: rgba(193, 68, 45, .12); color: var(--rust-dark); font-weight: 700; font-size: 10.5px; letter-spacing: .04em; }
.panel-head .muted { font-size: 13px; }
