/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0e0f14;
  --surface:   #15161d;
  --surface2:  #1c1e28;
  --border:    #2a2c38;
  --accent:    #00d4aa;
  --accent2:   #ff6b35;
  --text:      #e8eaf0;
  --text-dim:  #8890a4;
  --sidebar-w: 220px;
  --radius:    10px;
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; overflow: hidden; }

/* ── Layout ──────────────────────────────────────────────────── */
body { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}

.main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar Brand ───────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  flex-shrink: 0;
}
.brand-icon svg { width: 20px; height: 20px; }
.brand-name { font-family: var(--font-head); font-weight: 800; font-size: 15px; color: var(--text); }
.brand-sub { font-size: 10px; color: var(--text-dim); letter-spacing: 0.04em; }

/* ── Sidebar Nav ─────────────────────────────────────────────── */
.sidebar-nav { padding: 12px 8px; flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

/* ── Sidebar Footer ──────────────────────────────────────────── */
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.location-badge { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); }
.location-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 2s infinite; flex-shrink: 0; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-family: var(--font-head); font-weight: 700; font-size: 20px; }
.date-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.topbar-right { display: flex; gap: 8px; }
.stat-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.stat-chip.accent { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ── Views ───────────────────────────────────────────────────── */
.view { display: none; padding: 20px 24px; flex: 1; }
.view.active { display: block; }

/* ── Panel Row ───────────────────────────────────────────────── */
.panel-row { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: 520px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  padding: 14px 16px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* ── Controls Panel ──────────────────────────────────────────── */
.controls-panel { overflow-y: auto; padding: 0; }
.controls-panel > * { padding: 0 16px; }
.controls-panel > .form-group { padding: 8px 16px 0; }
.controls-panel > .btn { margin: 8px 16px 0; width: calc(100% - 32px); }
.controls-panel > .appt-list { padding: 8px 16px 16px; }

/* ── Form ────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600; }

.input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.input:focus { border-color: var(--accent); }
select.input option { background: var(--surface2); }

/* ── Tech List ───────────────────────────────────────────────── */
.tech-list { display: flex; flex-direction: column; gap: 4px; }
.tech-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.tech-item input[type="checkbox"] { accent-color: var(--accent); }
.tech-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent);
  color: #000; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tech-item.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 14px;
  border: none; border-radius: 7px; cursor: pointer;
  font-family: var(--font-head); font-weight: 700; font-size: 13px;
  letter-spacing: 0.02em;
  transition: all 0.15s;
}
.btn svg { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--text-dim); }

.btn-primary {
  background: var(--accent); color: #000;
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn-lg { padding: 13px 24px; font-size: 14px; }

/* ── Appointment List ─────────────────────────────────────────── */
.appt-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.appt-item {
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 6px;
  border-left: 3px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
}
.appt-item.has-address { border-left-color: var(--accent); }
.appt-name { font-weight: 600; color: var(--text); }
.appt-time { color: var(--text-dim); }
.appt-addr { color: var(--text-dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Map Panel ───────────────────────────────────────────────── */
.map-panel { position: relative; }
.map-container { flex: 1; position: relative; }
.map-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--text-dim); font-size: 13px;
}
.map-placeholder-icon { font-size: 40px; opacity: 0.4; }
#map > div { border-radius: 0 !important; }

.map-controls { display: flex; gap: 6px; }
.map-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; padding: 3px 8px; cursor: pointer;
  font-size: 14px;
}
.map-btn:hover { border-color: var(--accent); }

/* ── Route Results ───────────────────────────────────────────── */
.route-results { margin-top: 20px; }
.route-results.hidden { display: none; }

.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.results-header h2 { font-family: var(--font-head); font-size: 18px; }
.results-meta { font-size: 12px; color: var(--text-dim); }

.route-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 16px; }

.route-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.route-card-head {
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.tech-badge {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-head); font-weight: 700; font-size: 13px;
}
.tech-avatar-lg {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #000;
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

.route-meta { font-size: 11px; color: var(--text-dim); text-align: right; line-height: 1.6; }

.route-stops { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }

.stop-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: start;
  font-size: 12px;
}
.stop-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #000;
  font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.stop-info { min-width: 0; }
.stop-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-addr { color: var(--text-dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-eta { color: var(--accent); font-size: 11px; font-weight: 600; white-space: nowrap; }

.route-card-footer { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.btn-open-maps {
  flex: 1; padding: 8px; font-size: 12px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; cursor: pointer;
  font-family: var(--font-body); font-weight: 500;
  transition: all 0.15s; text-decoration: none; text-align: center;
}
.btn-open-maps:hover { border-color: var(--accent); color: var(--accent); }

.btn-sms-single {
  padding: 8px 12px; font-size: 12px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1px solid var(--accent);
  color: var(--accent); border-radius: 6px; cursor: pointer;
  font-family: var(--font-body); font-weight: 600;
  transition: all 0.15s;
}
.btn-sms-single:hover { background: var(--accent); color: #000; }

/* ── Dispatch Bar ─────────────────────────────────────────────── */
.dispatch-bar { display: flex; gap: 12px; align-items: flex-start; margin-top: 12px; }
.dispatch-note { resize: vertical; min-height: 44px; max-height: 100px; flex: 1; }

/* ── Loading State ─────────────────────────────────────────────── */
.loading { position: relative; pointer-events: none; }
.loading::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(14,15,20,0.6);
  border-radius: inherit;
  display: flex; align-items: center; justify-content: center;
}

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  min-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--accent2); }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
