/* =========================================================
   AssetFlow — Design System
   Palette:  #0B1B33 (deep navy, sidebar)   #F6F7FB (workspace bg)
             #0EA5A0 (teal accent, actions) #101828 (ink/text)
             Status: #16A34A avail · #2563EB assigned
                     #D97706 in-repair · #94A3B8 retired
   Type: 'Lexend' (headings) + 'Inter' (UI/body)
========================================================= */

:root {
  --navy: #0B1B33;
  --navy-soft: #142A4D;
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --ink: #101828;
  --ink-soft: #5B6472;
  --border: #E6E9F0;
  --accent: #0EA5A0;
  --accent-dark: #0B8A86;
  --accent-soft: #E4F7F6;

  --status-available: #16A34A;
  --status-available-bg: #E9F9EF;
  --status-assigned: #2563EB;
  --status-assigned-bg: #EAF1FF;
  --status-repair: #D97706;
  --status-repair-bg: #FEF3E2;
  --status-retired: #64748B;
  --status-retired-bg: #EEF1F5;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);

  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Lexend', 'Inter', sans-serif;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--navy);
  color: #C9D3E4;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  transition: transform 0.25s ease;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  font-family: 'Lexend', sans-serif;
  font-weight: 600;
  font-size: 17px;
  color: #fff;
}

.sidebar-brand .mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #0B8A86);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #06231F;
}

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6E7C97;
  padding: 16px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: #C9D3E4;
  margin-bottom: 2px;
}

.nav-link:hover { background: var(--navy-soft); color: #fff; }
.nav-link.active { background: var(--accent); color: #06231F; font-weight: 600; }
.nav-link .icon { width: 17px; text-align: center; opacity: 0.9; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar h1 { font-size: 18px; margin: 0; }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink); }

.back-arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.back-arrow-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }

.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* Full-width variant — opted into per-page via layouts/main.php (currently: Customers, License Expiry).
   Left as a variant rather than changing .content itself so every other module keeps its existing width. */
.content-full { max-width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------- Cards / KPIs ---------- */
.grid-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.kpi-card .label { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; margin-bottom: 6px; }
.kpi-card .value { font-family: 'Lexend', sans-serif; font-size: 26px; font-weight: 600; }
.kpi-card .sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-body { padding: 20px; }

/* ---------- Status system (signature element) ----------
   Every asset carries a colored left edge — table rows and
   cards alike — like a physical asset tag. */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }

.status-available { background: var(--status-available-bg); color: var(--status-available); }
.status-available::before { background: var(--status-available); }
.status-assigned { background: var(--status-assigned-bg); color: var(--status-assigned); }
.status-assigned::before { background: var(--status-assigned); }
.status-in_repair { background: var(--status-repair-bg); color: var(--status-repair); }
.status-in_repair::before { background: var(--status-repair); }
.status-retired { background: var(--status-retired-bg); color: var(--status-retired); }
.status-retired::before { background: var(--status-retired); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 10px 20px;
  background: #FAFBFD;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }

.asset-row { position: relative; }
.asset-row td:first-child { border-left: 3px solid transparent; }
.asset-row.st-available td:first-child { border-left-color: var(--status-available); }
.asset-row.st-assigned td:first-child { border-left-color: var(--status-assigned); }
.asset-row.st-in_repair td:first-child { border-left-color: var(--status-repair); }
.asset-row.st-retired td:first-child { border-left-color: var(--status-retired); }

.asset-tag-code {
  font-family: 'SFMono-Regular', Menlo, monospace;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: #F0F2F6;
  padding: 2px 6px;
  border-radius: 5px;
}

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }

input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Responsive view toggle: table on desktop, cards on mobile ---------- */
.desktop-only { display: block; }
.mobile-only { display: none; }

/* ---------- Record cards (Receivables/Payments/etc., mobile view) ----------
   Each entry is its own floating card with a colored left edge matching
   its status — same visual language as the asset status system — rather
   than a plain list row, so it reads well on a phone.
   NOTE: display is intentionally NOT set here — it's controlled entirely by
   .mobile-only / the (max-width: 820px) block below, so the toggle always
   wins regardless of rule order (a plain .record-card-list { display:flex }
   here would tie with .mobile-only on specificity and could show both
   the table and the cards at once on desktop). */
.record-card-list { flex-direction: column; gap: 12px; padding: 16px; }
.record-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.record-card.rc-paid          { border-left-color: var(--status-available); }
.record-card.rc-partial       { border-left-color: var(--status-repair); }
.record-card.rc-outstanding   { border-left-color: var(--status-assigned); }
.record-card.rc-overdue,
.record-card.rc-waived,
.record-card.rc-cancelled     { border-left-color: var(--status-retired); }

.record-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.record-card-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.record-card-sub { font-weight: 400; color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.record-card-amount { font-weight: 700; font-size: 17px; white-space: nowrap; font-family: 'Lexend', sans-serif; }
.record-card-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 12px; font-size: 12px; color: var(--ink-soft); }
.record-card-meta span {
  background: #F5F6F8;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.record-card-meta strong { color: var(--ink); font-weight: 600; }
.record-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

@media (max-width: 820px) {
  .desktop-only { display: none; }
  .mobile-only { display: block; }
  .record-card-list.mobile-only { display: flex; }
}

@media (max-width: 480px) {
  .record-card-amount { font-size: 15px; }
}
.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-soft); }
.empty-state .icon { font-size: 32px; margin-bottom: 12px; }

/* =========================================================
   Responsive: laptop -> tablet -> mobile
========================================================= */

/* Tablet */
@media (max-width: 1024px) {
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

/* Mobile + small tablet: collapse sidebar into a drawer */
@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .grid-kpi { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi-card { padding: 14px; }
  .kpi-card .value { font-size: 22px; }

  .sidebar-scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(11, 27, 51, 0.4);
    z-index: 39;
  }
  .sidebar-scrim.open { display: block; }
}

@media (max-width: 480px) {
  .grid-kpi { grid-template-columns: 1fr; }
  .panel-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .data-table th, .data-table td { padding: 10px 12px; }
}
