/* Mr Poolman App Styles — matches landing page design language */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --deep-blue: #0a1628;
  --pool-blue: #0ea5e9;
  --pool-light: #7dd3fc;
  --white: #f8fafc;
  --gray: #94a3b8;
  --sand: #f5f0e8;
  --surface: #0f1f38;
  --surface2: #172a45;
  --border: rgba(14, 165, 233, 0.12);
  --border-hover: rgba(14, 165, 233, 0.35);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #f8fafc;
  --text-muted: #94a3b8;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--deep-blue);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Nav ─────────────────────────────────────────────────────── */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--pool-light);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  color: var(--gray);
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover, .nav-links a.active {
  background: rgba(14, 165, 233, 0.1);
  color: var(--pool-light);
}

.nav-action {
  display: flex;
  gap: 0.5rem;
}

/* ── Page Layout ─────────────────────────────────────────────── */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--gray);
  margin-top: 0.25rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--pool-blue);
  color: white;
}
.btn-primary:hover { background: #0284c7; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-hover);
  color: var(--pool-light);
}
.btn-outline:hover { background: rgba(14, 165, 233, 0.1); }

.btn-ghost {
  background: transparent;
  color: var(--gray);
  border: none;
}
.btn-ghost:hover { background: rgba(148, 163, 184, 0.1); color: var(--white); }

.btn-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #16a34a; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
}

.card-body { padding: 1.5rem; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.stat-card-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  margin-bottom: 0.5rem;
}

.stat-card-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--pool-blue);
  line-height: 1;
}

.stat-card-sub {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 0.35rem;
}

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(14, 165, 233, 0.04); }

.td-name {
  font-weight: 500;
  color: var(--white);
}

.td-muted { color: var(--gray); }

/* ── Badges / Status ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-scheduled { background: rgba(14, 165, 233, 0.12); color: var(--pool-light); }
.badge-completed { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.badge-cancelled { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-pending { background: rgba(245, 158, 11, 0.12); color: var(--warning); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, textarea {
  background: rgba(14, 165, 233, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--pool-blue);
  background: rgba(14, 165, 233, 0.08);
}

input::placeholder, textarea::placeholder { color: var(--gray); }

select option { background: var(--surface); color: var(--white); }

textarea { resize: vertical; min-height: 80px; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--gray);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  color: var(--white);
  margin-bottom: 0.5rem;
}

/* ── Search ──────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  background: rgba(14, 165, 233, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 0.9rem;
  gap: 0.5rem;
  min-width: 220px;
}

.search-bar input {
  background: none;
  border: none;
  padding: 0.55rem 0;
}

.search-bar input:focus { border: none; background: none; }

/* ── Calendar ────────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  margin-bottom: 1px;
}

.cal-day-name {
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  font-weight: 500;
}

.cal-cell {
  background: var(--surface);
  min-height: 90px;
  padding: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.cal-cell:hover { background: var(--surface2); }
.cal-cell.today { background: rgba(14, 165, 233, 0.07); }
.cal-cell.selected { background: rgba(14, 165, 233, 0.14); }
.cal-cell.other-month { opacity: 0.4; }

.cal-date {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray);
  margin-bottom: 0.25rem;
}

.cal-cell.today .cal-date {
  color: var(--pool-blue);
  font-weight: 700;
}

.cal-appt {
  background: rgba(14, 165, 233, 0.2);
  border-left: 2px solid var(--pool-blue);
  border-radius: 3px;
  padding: 0.15rem 0.3rem;
  font-size: 0.7rem;
  color: var(--pool-light);
  margin-bottom: 2px;
  truncate: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-appt.completed {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--success);
  color: var(--success);
}

/* ── Route List ──────────────────────────────────────────────── */
.route-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.route-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}

.route-item:hover { border-color: var(--border-hover); }

.route-num {
  width: 28px;
  height: 28px;
  background: rgba(14, 165, 233, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--pool-blue);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.route-info { flex: 1; }

.route-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.route-address {
  font-size: 0.82rem;
  color: var(--gray);
  margin-bottom: 0.25rem;
}

.route-service {
  font-size: 0.8rem;
  color: var(--pool-light);
}

.route-time {
  font-size: 0.8rem;
  color: var(--gray);
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-body { padding: 1.5rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--white); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}

.alert.show { display: block; }
.alert-success { background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.25); color: var(--success); }
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.25); color: var(--danger); }

/* ── Misc ────────────────────────────────────────────────────── */
.text-muted { color: var(--gray); }
.text-blue { color: var(--pool-light); }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.w-full { width: 100%; }

.pool-type-badge {
  display: inline-flex;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  background: rgba(125, 211, 252, 0.1);
  color: var(--pool-light);
  border: 1px solid rgba(125, 211, 252, 0.2);
}

/* ── Loading spinner ─────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(14, 165, 233, 0.2);
  border-top-color: var(--pool-blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
  font-size: 0.875rem;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 768px) {
  .page { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .app-nav { padding: 0 1rem; }
  .nav-links { display: none; }
  .cal-grid, .cal-header { grid-template-columns: repeat(7, 1fr); }
  .cal-cell { min-height: 60px; }
}
