/* ============================================================
   Chairleader Party Rental — Design System
   ============================================================ */

/* ── Variables ─────────────────────────────────────────── */
:root {
  --primary:       #7C3AED;
  --primary-light: #9F67FF;
  --primary-dark:  #5B21B6;
  --gold:          #F59E0B;
  --gold-light:    #FCD34D;
  --bg:            #0D0F17;
  --surface:       #13162A;
  --surface-2:     #1A1E35;
  --surface-3:     #222740;
  --border:        #2D3260;
  --text:          #E8EAED;
  --text-muted:    #8B93B5;
  --success:       #10B981;
  --warning:       #F59E0B;
  --error:         #EF4444;
  --info:          #3B82F6;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:     0 12px 32px rgba(0,0,0,0.5);
  --sidebar-width: 240px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font: inherit; }
ul, ol { list-style: none; }

/* ── Typography ─────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.1rem;  font-weight: 600; }
h4 { font-size: .95rem;  font-weight: 600; }
.muted { color: var(--text-muted); }
.small { font-size: .8rem; }

/* ── Layout ─────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}
.main-content {
  padding: 28px 32px;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.sidebar-brand .logo-img {
  width: 150px;
  height: auto;
  display: block;
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
}
.sidebar-brand .sub {
  font-size: .65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  text-align: center;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 0 12px; margin-bottom: 4px; }
.nav-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 8px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  font-size: .88rem;
  font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.user-chip .user-info { flex: 1; min-width: 0; }
.user-chip .user-name { font-size: .82rem; font-weight: 600; truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.user-chip .user-role { font-size: .7rem; color: var(--text-muted); }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }

/* ── Stat Cards ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-card .stat-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-card .stat-sub   { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.stat-card.primary .stat-value { color: var(--primary-light); }
.stat-card.gold    .stat-value { color: var(--gold); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.error   .stat-value { color: var(--error); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  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;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  line-height: 1;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; pointer-events: none; }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-light); }
.btn-gold      { background: var(--gold);     color: #1a1000; }
.btn-gold:hover     { background: var(--gold-light); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-danger    { background: var(--error);    color: #fff; }
.btn-ghost     { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover    { background: var(--surface-3); }
.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover  { border-color: var(--primary); color: var(--primary-light); }
.btn-sm  { padding: 6px 12px; font-size: .8rem; }
.btn-lg  { padding: 14px 28px; font-size: 1rem; }
.btn-xl  { padding: 18px 36px; font-size: 1.15rem; border-radius: 14px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-maps {
  background: #1a73e8;
  color: #fff;
  gap: 8px;
}
.btn-maps:hover { background: #1558b0; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-pending       { background: rgba(245,158,11,.15);  color: var(--warning); }
.badge-confirmed     { background: rgba(59,130,246,.15);  color: var(--info); }
.badge-scheduled     { background: rgba(139,92,246,.15);  color: #a78bfa; }
.badge-out_for_delivery { background: rgba(245,158,11,.2); color: var(--gold); }
.badge-delivered     { background: rgba(16,185,129,.15);  color: var(--success); }
.badge-completed     { background: rgba(16,185,129,.25);  color: #34d399; }
.badge-cancelled     { background: rgba(239,68,68,.15);   color: var(--error); }
.badge-in_transit    { background: rgba(245,158,11,.2);   color: var(--gold); }
.badge-assigned      { background: rgba(59,130,246,.15);  color: var(--info); }
.badge-failed        { background: rgba(239,68,68,.15);   color: var(--error); }
.badge-admin         { background: rgba(124,58,237,.2);   color: var(--primary-light); }
.badge-worker        { background: rgba(139,92,246,.1);   color: #a78bfa; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody td { padding: 12px 16px; vertical-align: middle; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"],  input[type="number"], input[type="date"],
input[type="time"],  select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .875rem;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,.2);
}
select option { background: var(--surface-2); }
textarea { resize: vertical; min-height: 80px; }
.input-group { position: relative; }
.input-group input { padding-right: 42px; }
.input-group .input-icon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); width: 18px; height: 18px; pointer-events: none;
}
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: .75rem; color: var(--error); margin-top: 5px; }

/* ── Checkbox / Toggle ───────────────────────────────────── */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle input[type="checkbox"] { display: none; }
.toggle-track {
  width: 40px; height: 22px;
  background: var(--surface-3);
  border-radius: 20px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle-track::after {
  content: '';
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-label { font-size: .875rem; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-body    { padding: 24px; }
.modal-footer  {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Toast / Alert ───────────────────────────────────────── */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; min-width: 280px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border-left: 4px solid var(--primary);
  font-size: .875rem;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--error); }
.toast.warning { border-color: var(--warning); }
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }

/* ── Delivery card (mobile worker view) ─────────────────── */
.delivery-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
}
.delivery-card .order-num { font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; }
.delivery-card .customer  { font-size: 1.05rem; font-weight: 700; margin-bottom: 2px; }
.delivery-card .address   { font-size: .875rem; color: var(--text-muted); margin-bottom: 14px; line-height: 1.4; }
.delivery-card .card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Clock widget ────────────────────────────────────────── */
.clock-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
}
.clock-time { font-size: 3rem; font-weight: 800; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.clock-date { font-size: .875rem; color: var(--text-muted); margin-bottom: 24px; }
.clock-status { margin-bottom: 20px; }
.clock-elapsed { font-size: 1.2rem; font-weight: 700; color: var(--gold); margin-top: 8px; }

/* ── Inventory grid ──────────────────────────────────────── */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.inv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inv-card .inv-category {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--primary-light);
  font-weight: 700;
}
.inv-card .inv-name { font-weight: 700; font-size: .95rem; }
.inv-card .inv-qty  { font-size: .82rem; color: var(--text-muted); }
.inv-card .inv-price { color: var(--gold); font-weight: 700; font-size: .95rem; }
.qty-bar { background: var(--surface-3); height: 4px; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.qty-bar-fill { height: 100%; background: var(--success); border-radius: 4px; transition: width .3s; }
.qty-bar-fill.warn  { background: var(--warning); }
.qty-bar-fill.crit  { background: var(--error); }

/* ── Calendar ────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-header { text-align: center; font-size: .72rem; color: var(--text-muted); padding: 4px 0; text-transform: uppercase; }
.cal-day {
  aspect-ratio: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .78rem;
  transition: border-color .15s;
}
.cal-day:hover { border-color: var(--primary); }
.cal-day.today { border-color: var(--gold); }
.cal-day.other-month { opacity: 0.35; }
.cal-day .day-num { font-weight: 700; font-size: .8rem; }
.cal-event {
  font-size: .65rem;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Login page ──────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 60% 20%, rgba(124,58,237,.25) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(245,158,11,.1) 0%, transparent 50%),
              var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo img {
  width: 240px;
  height: auto;
  display: block;
  margin: 0 auto;
  background: #fff;
  border-radius: 14px;
  padding: 14px 18px;
}

/* ── Filters bar ─────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.filters select, .filters input {
  width: auto;
  min-width: 140px;
}

/* ── Permissions grid ────────────────────────────────────── */
.perm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Utils ───────────────────────────────────────────────── */
.flex  { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.mt-4  { margin-top: 16px; }
.text-right { text-align: right; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state .empty-text { font-size: .875rem; }
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile hamburger ────────────────────────────────────── */
.mobile-header {
  display: none;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.hamburger {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100vh;
    z-index: 100;
    width: var(--sidebar-width);
    transition: left .25s ease;
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay.open { display: block; }
  .mobile-header { display: flex; }
  .main-content  { padding: 20px 16px; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .inventory-grid { grid-template-columns: 1fr; }
}
