/* ============================================================
   FleetOps — Design System
   Light theme, green accent #0F6E56
   RTL/LTR bilingual support
   ============================================================ */

/* ── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #F7F7F5;
  color: #1A1A18;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }

/* ── CSS VARIABLES ────────────────────────────────────────── */
:root {
  --green:          #0F6E56;
  --green-dark:     #0A5040;
  --green-light:    #E1F5EE;
  --green-mid:      #5DCAA5;
  --gold:           #B8860B;
  --gold-bg:        #FDF8EC;

  --bg-primary:     #FFFFFF;
  --bg-secondary:   #F7F7F5;
  --bg-tertiary:    #EFEFEC;
  --border:         rgba(0,0,0,0.10);
  --border-strong:  rgba(0,0,0,0.18);

  --text-primary:   #1A1A18;
  --text-secondary: #5A5A56;
  --text-muted:     #8A8A84;

  --red:            #C53030;
  --red-bg:         #FEF2F2;
  --amber:          #B45309;
  --amber-bg:       #FFFBEB;
  --blue:           #1D4ED8;
  --blue-bg:        #EFF6FF;

  --sidebar-w:      240px;
  --topbar-h:       58px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.10);
  --transition:     0.15s ease;
}

/* ── LAYOUT ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--green);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-icon svg { width: 18px; height: 18px; fill: white; }
.sidebar-logo-text { min-width: 0; }
.sidebar-logo-text .app-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-logo-text .app-sub {
  font-size: 11px; color: var(--text-muted);
}
.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-section {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 14px 20px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px 8px 20px;
  font-size: 13.5px; color: var(--text-secondary);
  cursor: pointer; border-radius: 6px;
  margin: 1px 8px;
  transition: background var(--transition), color var(--transition);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.nav-item.active {
  background: var(--green-light);
  color: var(--green);
  font-weight: 500;
}
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px; font-weight: 600;
  border-radius: 20px;
  padding: 1px 6px;
  min-width: 18px; text-align: center;
}
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}

/* ── MAIN AREA ────────────────────────────────────────────── */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 500; flex: 1; }
.topbar-title .breadcrumb { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.lang-toggle {
  display: flex; gap: 2px;
  background: var(--bg-secondary);
  border-radius: 6px; padding: 2px;
}
.lang-toggle button {
  padding: 4px 10px; font-size: 12px; border: none;
  border-radius: 4px; cursor: pointer; background: transparent;
  color: var(--text-muted); transition: all var(--transition);
}
.lang-toggle button.active {
  background: white; color: var(--text-primary);
  box-shadow: var(--shadow-sm); font-weight: 500;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 6px;
  font-size: 13px; cursor: pointer;
  transition: background var(--transition);
}
.user-chip:hover { background: var(--bg-secondary); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--green-light);
  color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}

/* ── PAGE CONTENT ─────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.page-header h1 { font-size: 20px; font-weight: 600; }
.page-header .page-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-primary); color: var(--text-primary);
  transition: all var(--transition); white-space: nowrap;
}
.btn:hover { background: var(--bg-secondary); }
.btn-primary {
  background: var(--green); color: white;
  border-color: transparent;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { background: var(--red); color: white; border-color: transparent; }
.btn-danger:hover { background: #9B2626; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 7px; }
.btn svg { width: 15px; height: 15px; }

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── METRICS GRID ─────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.metric-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 600; line-height: 1; }
.metric-sub { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.metric-value.green  { color: var(--green); }
.metric-value.red    { color: var(--red); }
.metric-value.amber  { color: var(--amber); }

/* ── TABLE ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 9px 12px; text-align: left;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:hover { background: var(--bg-secondary); }
tbody td { padding: 10px 12px; color: var(--text-primary); }
tbody tr:last-child { border-bottom: none; }
.td-right { text-align: right; }
.td-center { text-align: center; }

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500;
  white-space: nowrap;
}
.badge-paid    { background: #DCFCE7; color: #166534; }
.badge-partial { background: #FEF3C7; color: #92400E; }
.badge-unpaid  { background: #FEE2E2; color: #991B1B; }
.badge-active  { background: var(--green-light); color: var(--green); }
.badge-parked  { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-expired { background: #FEE2E2; color: #991B1B; }
.badge-expiring{ background: #FEF3C7; color: #92400E; }
.badge-valid   { background: #DCFCE7; color: #166534; }
.badge-admin   { background: #EDE9FE; color: #5B21B6; }
.badge-manager { background: #DBEAFE; color: #1E40AF; }
.badge-accountant { background: #F0FDF4; color: #166534; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
}
.form-control {
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color var(--transition);
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15,110,86,0.12);
}
.form-control.error { border-color: var(--red); }
.form-hint { font-size: 11.5px; color: var(--text-muted); }
.form-error { font-size: 11.5px; color: var(--red); }

/* ── ALERTS ───────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius);
  font-size: 13.5px; margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── EXPIRY DOTS ──────────────────────────────────────────── */
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-red    { background: var(--red); }
.dot-amber  { background: var(--amber); }
.dot-green  { background: var(--green); }
.dot-gray   { background: var(--text-muted); }

/* ── FILTER BAR ───────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap; margin-bottom: 16px;
}
.filter-bar .form-control { width: auto; min-width: 140px; }
.filter-bar .form-control-sm { padding: 6px 9px; font-size: 13px; }

/* ── PAGINATION ───────────────────────────────────────────── */
.pagination {
  display: flex; gap: 4px; align-items: center;
  justify-content: flex-end; margin-top: 16px;
}
.page-btn {
  padding: 5px 10px; border: 1px solid var(--border-strong);
  border-radius: 6px; font-size: 13px; cursor: pointer;
  background: var(--bg-primary); color: var(--text-secondary);
  transition: all var(--transition);
}
.page-btn:hover { background: var(--bg-secondary); }
.page-btn.active { background: var(--green); color: white; border-color: transparent; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; cursor: pointer; border: none;
  background: transparent; color: var(--text-muted);
  transition: background var(--transition);
  font-size: 18px;
}
.modal-close:hover { background: var(--bg-secondary); }
.modal-body { padding: 20px 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
}

/* ── TABS ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; margin-bottom: 16px; }
.tab {
  padding: 6px 14px; font-size: 13.5px; border-radius: 6px;
  cursor: pointer; color: var(--text-muted);
  border: none; background: transparent;
  transition: all var(--transition);
}
.tab:hover { background: var(--bg-secondary); color: var(--text-primary); }
.tab.active {
  background: var(--green-light);
  color: var(--green); font-weight: 500;
}

/* ── TERM STATUS ROWS ─────────────────────────────────────── */
.term-table th, .term-table td { padding: 9px 10px; }
.car-change-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; background: #FEF3C7; color: #92400E;
  padding: 1px 6px; border-radius: 4px; margin-left: 5px;
}

/* ── DRIVER CHIP ──────────────────────────────────────────── */
.driver-chip { display: flex; align-items: center; gap: 8px; }
.driver-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-light); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; opacity: 0.3; margin-bottom: 12px; }
.empty-state h3 { font-size: 15px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; }

/* ── RTL SUPPORT ──────────────────────────────────────────── */
[dir="rtl"] .sidebar { left: auto; right: 0; border-left: 1px solid var(--border); border-right: none; }
[dir="rtl"] .main-area { margin-left: 0; margin-right: var(--sidebar-w); }
[dir="rtl"] .nav-badge { margin-left: 0; margin-right: auto; }
[dir="rtl"] .topbar-title { text-align: right; }
[dir="rtl"] thead th, [dir="rtl"] tbody td { text-align: right; }
[dir="rtl"] .page-header { flex-direction: row-reverse; }
[dir="rtl"] .filter-bar { flex-direction: row-reverse; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  [dir="rtl"] .main-area { margin-right: 0; }
}

/* ── UTILITIES ────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-amber   { color: var(--amber); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.font-mono    { font-family: 'Courier New', monospace; }
.fw-500       { font-weight: 500; }
.fw-600       { font-weight: 600; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-16        { margin-bottom: 16px; }
.mb-24        { margin-bottom: 24px; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.grid-2       { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3       { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.w-full       { width: 100%; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only      { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
