/* TJ's Lawncare — Dark Theme with Green Accent */

:root {
  --bg: #0a0a0f;
  --surface: #14141f;
  --surface-hover: #1a1a2e;
  --border: #1e1e2e;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-light: rgba(34,197,94,0.15);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Login ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.login-card h1 {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.login-card input {
  width: 100%;
  margin-bottom: 16px;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ===== 2FA Screen ===== */
.twofa-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}

.twofa-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.twofa-footer strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Zoom-in transition after 2FA success */
@keyframes zoomIn {
  from { transform: scale(1.5); filter: blur(10px); opacity: 0; }
  to   { transform: scale(1);   filter: blur(0);    opacity: 1; }
}

.zoom-in {
  animation: zoomIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.2s;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.sidebar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.sidebar-nav {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.nav-link svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* ===== Mobile Header ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  align-items: center;
  gap: 12px;
  z-index: 90;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.mobile-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ===== Content ===== */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
}

/* ===== Grid ===== */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== Stat Cards ===== */
.stat { text-align: center; }
.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }
.btn-full { width: 100%; }

.btn-group { display: flex; gap: 8px; }

/* ===== Forms ===== */
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

select { cursor: pointer; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* Checkbox / Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

tr:hover td { background: var(--surface-hover); }

.amount-pos { color: var(--success); font-weight: 600; }
.amount-neg { color: var(--danger); font-weight: 600; }

/* ===== Tags / Badges ===== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.tag-active { background: rgba(34,197,94,0.15); color: var(--success); }
.tag-inactive { background: rgba(239,68,68,0.15); color: var(--danger); }
.tag-pending { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.tag-en-route { background: rgba(6,182,212,0.15); color: var(--info); }
.tag-in-progress { background: rgba(245,158,11,0.15); color: var(--warning); }
.tag-completed { background: rgba(34,197,94,0.15); color: var(--success); }
.tag-skipped { background: rgba(239,68,68,0.15); color: var(--danger); }
.tag-bumped { background: rgba(249,115,22,0.15); color: #f97316; }
.tag-sent { background: rgba(99,102,241,0.15); color: #6366f1; }
.tag-paid { background: rgba(34,197,94,0.15); color: var(--success); }
.tag-overdue { background: rgba(239,68,68,0.15); color: var(--danger); }
.tag-draft { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.tag-cancelled { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* Time + Price badges */
.time-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(6,182,212,0.15);
  color: var(--info);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.price-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

/* ===== Status Dot ===== */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.pending { background: var(--text-muted); }
.status-dot.en_route { background: var(--info); }
.status-dot.in_progress { background: var(--warning); }
.status-dot.completed { background: var(--success); }
.status-dot.skipped { background: var(--danger); }
.status-dot.bumped { background: #f97316; }

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

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

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

.modal-header h2 { font-size: 18px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.modal-body { padding: 24px; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
}

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

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ===== Chart containers ===== */
.chart-container {
  position: relative;
  width: 100%;
  max-height: 350px;
}

/* ===== Schedule Grid ===== */
.schedule-week {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.day-column {
  flex: 1;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.day-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
}

.day-header.today {
  background: var(--accent-light);
  color: var(--accent);
}

.day-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.day-body {
  padding: 8px;
  flex: 1;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.day-add {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.day-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Schedule Card (yard visit within day column) */
.sched-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.sched-card:hover { border-color: var(--accent); }
.sched-card.completed { opacity: 0.6; }

.sched-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sched-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Week Navigation */
.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.week-nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s;
}

.week-nav-btn:hover { background: var(--surface-hover); }

.week-label {
  font-size: 15px;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

/* ===== Route List ===== */
.route-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  height: calc(100vh - 180px);
}

.route-list {
  overflow-y: auto;
}

.route-stop {
  display: flex;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.route-stop:last-child { border-bottom: none; }

.stop-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.stop-number.completed { background: var(--text-muted); }

.stop-info { flex: 1; }

.stop-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
}

.stop-address {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stop-meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stop-drive {
  font-size: 11px;
  color: var(--info);
  display: flex;
  align-items: center;
  gap: 4px;
}

.route-map {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 400px;
}

.route-summary {
  display: flex;
  gap: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.route-summary-item {
  text-align: center;
  flex: 1;
}

.route-summary-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.route-summary-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Invoice Cards ===== */
.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.filter-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.filter-tab:hover { color: var(--text); }
.filter-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Search Bar ===== */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.search-bar input { flex: 1; }

/* ===== Customer Cards (mobile list) ===== */
.customer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.customer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.15s;
}

.customer-card:hover { border-color: var(--accent); }

.customer-info { flex: 1; }

.customer-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
}

.customer-address {
  font-size: 12px;
  color: var(--text-muted);
}

.customer-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ===== Settings Sections ===== */
.settings-section {
  margin-bottom: 32px;
}

.settings-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  margin-bottom: 16px;
  font-size: 15px;
}

/* ===== QR Code ===== */
.qr-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}

.qr-item {
  text-align: center;
}

.qr-item canvas { border-radius: 8px; }

.qr-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .route-container { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }

  .sidebar-close { display: block; }
  .mobile-header { display: flex; }

  .content {
    margin-left: 0;
    padding: 72px 16px 24px;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .form-row { flex-direction: column; gap: 0; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }

  .schedule-week {
    flex-direction: column;
  }

  .day-column {
    min-width: 100%;
  }

  .route-container {
    grid-template-columns: 1fr;
    height: auto;
  }

  .route-summary { flex-wrap: wrap; gap: 12px; }
  .route-summary-item { min-width: 45%; }

  .filter-tabs { overflow-x: auto; }
}
