/* ─── Reset & Vars ────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #FFC107;
  --primary-dark: #FFB300;
  --dark: #111827;
  --dark-2: #1f2937;
  --dark-3: #374151;
  --gray: #6b7280;
  --gray-light: #f3f4f6;
  --gray-200: #e5e7eb;
  --white: #ffffff;
  --red: #ef4444;
  --green: #22c55e;
  --blue: #3b82f6;
  --orange: #f97316;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --sidebar-w: 260px;
  --topbar-h: 64px;
}
body { font-family: 'Inter', sans-serif; background: var(--gray-light); color: var(--dark); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 10px 14px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  outline: none; transition: border .2s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { font-weight: 600; font-size: 13px; color: var(--gray); text-transform: uppercase; letter-spacing: .5px; }
td { font-size: 14px; }
tbody tr:hover { background: rgba(255,193,7,0.04); }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; transition: all .2s;
}
.btn--primary { background: var(--primary); color: var(--dark); }
.btn--primary:hover { background: var(--primary-dark); }
.btn--danger { background: var(--red); color: var(--white); }
.btn--danger:hover { opacity: .9; }
.btn--success { background: var(--green); color: var(--white); }
.btn--success:hover { opacity: .9; }
.btn--outline { border: 1px solid var(--gray-200); color: var(--dark); background: var(--white); }
.btn--outline:hover { border-color: var(--primary); }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--full { width: 100%; justify-content: center; }
.btn--icon { padding: 8px; border-radius: 8px; }

/* ─── Login ───────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 100%);
}
.login-card {
  background: var(--white); padding: 40px; border-radius: 20px;
  width: 400px; max-width: 90vw; box-shadow: var(--shadow-lg);
}
.login-logo { font-size: 28px; font-weight: 800; text-align: center; margin-bottom: 32px; }
.login-logo span:first-child { font-size: 36px; }
.accent { color: var(--primary-dark); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--gray); }
.error-text { color: var(--red); font-size: 13px; margin-top: 12px; text-align: center; }

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

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--dark); color: var(--white);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0;
  z-index: 50; transition: transform .3s;
}
.sidebar__header {
  padding: 20px 24px; display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 800; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__logo { font-size: 28px; }
.sidebar__nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-radius: var(--radius-sm); color: rgba(255,255,255,0.6);
  font-size: 14px; font-weight: 500; transition: all .2s; width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.nav-item.active { background: var(--primary); color: var(--dark); font-weight: 700; }
.nav-item i { font-size: 20px; }
.sidebar__footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }

/* ─── Main ────────────────────────────────────────────────────── */
.main { flex: 1; margin-left: var(--sidebar-w); }
.topbar {
  height: var(--topbar-h); background: var(--white);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 40;
}
.topbar__burger { display: none; padding: 8px; }
.topbar__burger i { font-size: 24px; color: var(--dark); }
.topbar__title { font-size: 20px; font-weight: 700; flex: 1; }
.topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__user { font-size: 14px; font-weight: 600; color: var(--gray); }
.content { padding: 24px; }

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.card--flush { padding: 0; }
.card__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
}
.card__header h3 { font-size: 16px; font-weight: 700; }
.card__body { padding: 24px; }

/* ─── Stats Grid ──────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card__label { font-size: 13px; color: var(--gray); font-weight: 500; margin-bottom: 8px; }
.stat-card__value { font-size: 28px; font-weight: 800; }
.stat-card__change { font-size: 12px; margin-top: 4px; }
.stat-card__change--up { color: var(--green); }
.stat-card__change--down { color: var(--red); }
.stat-card--primary { background: var(--primary); }
.stat-card--primary .stat-card__label { color: rgba(0,0,0,0.5); }
.stat-card--dark { background: var(--dark); color: var(--white); }
.stat-card--dark .stat-card__label { color: rgba(255,255,255,0.6); }

/* ─── Badge ───────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge--green { background: rgba(34,197,94,0.1); color: var(--green); }
.badge--red { background: rgba(239,68,68,0.1); color: var(--red); }
.badge--yellow { background: rgba(255,193,7,0.15); color: #b8860b; }
.badge--blue { background: rgba(59,130,246,0.1); color: var(--blue); }
.badge--gray { background: var(--gray-light); color: var(--gray); }

/* ─── Toolbar (above tables) ──────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px; border-bottom: 1px solid var(--gray-200);
}
.toolbar__search {
  flex: 1; max-width: 320px;
}
.toolbar__search input {
  padding-left: 36px;
  background: var(--gray-light) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") 12px center no-repeat;
  border: none;
}

/* ─── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab {
  padding: 12px 20px; font-size: 14px; font-weight: 600;
  color: var(--gray); border-bottom: 2px solid transparent;
  margin-bottom: -2px; cursor: pointer; transition: all .2s;
}
.tab:hover { color: var(--dark); }
.tab.active { color: var(--dark); border-color: var(--primary); }

/* ─── Form grid ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.form-full { grid-column: 1 / -1; }

/* ─── Modal ───────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal__overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal__card {
  position: relative; background: var(--white); border-radius: 16px;
  padding: 32px; width: 500px; max-width: 90vw; max-height: 85vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal__card h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.modal__card--sos { border: 3px solid var(--red); }
.modal__card--sos h2 { color: var(--red); text-align: center; }
.modal__close {
  position: absolute; top: 16px; right: 16px; font-size: 20px;
  color: var(--gray); cursor: pointer;
}

/* ─── Chat ────────────────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; height: 500px; }
.chat__messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 70%; padding: 10px 14px; border-radius: 12px; font-size: 14px; }
.chat-msg--admin { background: var(--primary); align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg--user { background: var(--gray-light); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat__input {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--gray-200);
}
.chat__input input { flex: 1; }

/* ─── Empty state ─────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px; color: var(--gray); }
.empty i { font-size: 48px; margin-bottom: 12px; display: block; color: var(--gray-200); }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar__burger { display: block; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* ─── Permissions Grid (Roles) ────────────────────────────────── */
.perms-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.perm-item { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.perm-item input[type="checkbox"] { width: auto; }

/* ─── Driver Photos Grid ──────────────────────────────────────── */
.photos-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.photos-grid img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; }

/* ─── Approve Badge ───────────────────────────────────────────── */
.approve-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--orange); color: var(--white);
}

/* ─── Loading spinner ─────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--gray-200);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .6s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.8; } }

/* Address autocomplete (operator dispatch) */
[data-addr-picker] { position: relative; }
[data-addr-picker] .addr-suggestions {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #1d1d1d;
  border: 1px solid #333;
  border-radius: 8px;
  margin-top: 4px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
[data-addr-picker] .addr-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #2a2a2a;
}
[data-addr-picker] .addr-item:last-child { border-bottom: 0; }
[data-addr-picker] .addr-item:hover { background: #2a2a2a; }
[data-addr-picker] .addr-title { font-weight: 600; font-size: 13px; color: #fff; }
[data-addr-picker] .addr-sub { font-size: 11px; color: #888; margin-top: 2px; line-height: 1.3; }
[data-addr-picker] .addr-empty { padding: 12px; color: #888; font-size: 13px; text-align: center; }
