/* Happy Haulers Moving - Shared Styles */
/* Dark theme, mobile-first, professional */

:root {
  --bg: #0f0f13;
  --bg-card: #1a1a24;
  --bg-card-hover: #22223a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-dim: #1d3f7a;
  --text: #e8e8f0;
  --text-muted: #8888a8;
  --text-dim: #555570;
  --border: #2a2a3a;
  --success: #10b981;
  --success-dim: #064e3b;
  --warning: #f59e0b;
  --warning-dim: #78350f;
  --danger: #ef4444;
  --danger-dim: #7f1d1d;
  --scheduled-color: #6b7280;
  --active-color: #10b981;
  --complete-color: #3b82f6;
  --cancelled-color: #6b7280;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --transition: 0.18s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ===== Layout ===== */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.topbar-brand span { color: var(--text); }

.topbar-nav { display: flex; gap: 8px; align-items: center; }
.topbar-nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.topbar-nav a:hover, .topbar-nav a.active {
  background: var(--accent-dim);
  color: var(--accent);
  text-decoration: none;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.topbar-user .role-badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.main-content {
  flex: 1;
  padding: 24px 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-warning {
  background: var(--warning);
  color: #000;
}
.btn-warning:hover:not(:disabled) { background: #d97706; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text);
}

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-xl { padding: 18px 32px; font-size: 1.1rem; min-height: 60px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888a8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control { min-height: 100px; resize: vertical; }

/* ===== Status Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-scheduled { background: rgba(107,114,128,0.2); color: var(--scheduled-color); }
.badge-active    { background: rgba(16,185,129,0.15); color: var(--active-color); }
.badge-complete  { background: rgba(59,130,246,0.15); color: var(--complete-color); }
.badge-cancelled { background: rgba(107,114,128,0.15); color: var(--cancelled-color); }
.badge-overrun   { background: rgba(239,68,68,0.2); color: var(--danger); }

/* ===== Alerts/Banners ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid;
}
.alert-warning {
  background: rgba(245,158,11,0.1);
  border-color: rgba(245,158,11,0.3);
  color: var(--warning);
}
.alert-danger {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.3);
  color: var(--danger);
}
.alert-success {
  background: rgba(16,185,129,0.1);
  border-color: rgba(16,185,129,0.3);
  color: var(--success);
}
.alert-info {
  background: rgba(59,130,246,0.1);
  border-color: rgba(59,130,246,0.3);
  color: var(--accent);
}

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(42,42,58,0.5);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== Overrun Highlighting ===== */
.overrun-time { color: var(--danger) !important; font-weight: 700; }
.overrun-next-start { color: var(--danger) !important; font-weight: 700; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text); background: var(--bg-card-hover); }

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

/* ===== GPS Tag ===== */
.gps-tag {
  font-size: 0.75rem;
  color: var(--success);
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: rgba(16,185,129,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ===== Crew Dot ===== */
.crew-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ===== Log Feed ===== */
.log-feed { display: flex; flex-direction: column; gap: 8px; }
.log-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
}
.log-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.log-event {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}
.log-event-enroute    { color: var(--warning); }
.log-event-checkin    { color: var(--success); }
.log-event-checkout   { color: var(--complete-color); }
.log-event-break_start { color: var(--text-muted); }
.log-event-break_end  { color: var(--text-muted); }

/* ===== Note Cards ===== */
.note-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.note-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.note-job-tag {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}
.note-content { font-size: 0.95rem; line-height: 1.6; white-space: pre-wrap; }

/* ===== Timeline ===== */
.timeline-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

.job-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  transition: var(--transition);
  position: relative;
}

.job-row:hover { border-color: rgba(59,130,246,0.3); }
.job-row.overrun-row { border-color: rgba(239,68,68,0.5); background: rgba(239,68,68,0.04); }

.job-row-left { flex: 1; min-width: 200px; }
.job-row-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.job-client { font-weight: 600; font-size: 0.95rem; margin-bottom: 2px; }
.job-address { font-size: 0.82rem; color: var(--text-muted); }

.time-block { display: flex; flex-direction: column; }
.time-label { font-size: 0.72rem; color: var(--text-muted); }
.time-value { font-size: 0.9rem; font-weight: 500; font-family: 'SF Mono', monospace; }

/* ===== Search ===== */
.search-wrap { position: relative; }
.search-wrap .form-control { padding-left: 36px; }
.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .main-content { padding: 16px 14px; }
  .topbar-nav a { display: none; }
  .topbar-nav .nav-mobile { display: block; }

  .btn-xl { min-height: 68px; font-size: 1.15rem; }

  th, td { padding: 8px 10px; }
}

/* ===== Loading overlay ===== */
.loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  z-index: 9999;
  font-size: 1rem;
  color: var(--text-muted);
}
.loading-overlay.hidden { display: none; }

/* ===== Divider ===== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state .empty-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state .empty-text { font-size: 0.85rem; }

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  max-width: 320px;
  animation: toast-in 0.3s ease;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-info    { border-left: 3px solid var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
