/* Dashboard-specific styles — extends theme.css tokens */

.dash-body {
  background: var(--bg);
  min-height: 100vh;
}

/* ---- NAV ---- */
.dash-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 12, 0.9);
  backdrop-filter: blur(12px);
}

.dash-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.dash-logo {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.dash-nav-links {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.nav-link {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--fg);
  background: var(--bg-surface);
}

/* ---- LAYOUT ---- */
.dash-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ---- KPI STRIP ---- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
}

.kpi-value.accent {
  color: var(--accent);
}

/* ---- OPTIMIZE SECTION ---- */
.optimize-card {
  background: var(--bg-elevated);
  border: 1px solid rgba(212, 160, 84, 0.2);
  border-radius: 12px;
  padding: 1.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.optimize-info h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.3rem;
}

.optimize-info p {
  font-size: 0.9rem;
  color: var(--fg-muted);
  max-width: 480px;
}

.no-pending {
  color: var(--accent) !important;
  margin-top: 0.25rem !important;
  font-size: 0.85rem !important;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #0a0a0c;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.85;
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.btn-secondary:hover {
  border-color: rgba(212, 160, 84, 0.3);
  background: var(--bg-elevated);
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-family: var(--font-display);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s;
}

.btn-ghost:hover {
  color: var(--fg);
}

.optimize-result {
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.optimize-result.hidden { display: none; }

.optimize-result.success {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: #6ee7b7;
}

.optimize-result.success a {
  color: var(--accent);
  text-decoration: underline;
}

.optimize-result.error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #fca5a5;
}

/* ---- ROUTE PLAN ---- */
.route-plan-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
}

.plan-badge {
  font-size: 0.75rem;
  font-family: var(--font-display);
  font-weight: 500;
  padding: 0.2rem 0.7rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  background: var(--bg-surface);
}

.plan-badge.status-active {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.08);
}

.plan-summary-strip {
  display: flex;
  gap: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.plan-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.plan-stat-num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.plan-stat-label {
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vehicle-routes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1rem;
}

.vehicle-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.vehicle-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.vehicle-icon { font-size: 1rem; }

.vehicle-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
}

.vehicle-stop-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.stop-list {
  display: flex;
  flex-direction: column;
}

.stop-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

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

.stop-row:hover { background: var(--bg-surface); }

.stop-row.priority-1 .stop-seq { color: #f87171; }
.stop-row.priority-2 .stop-seq { color: var(--accent); }
.stop-row.priority-3 .stop-seq { color: var(--fg-muted); }

.stop-seq {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 24px;
  padding-top: 0.15rem;
}

.stop-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stop-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
}

.stop-addr {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.stop-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  text-align: right;
}

.stop-eta {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.stop-window {
  font-size: 0.72rem;
  color: var(--fg-muted);
}

.stop-vol {
  font-size: 0.72rem;
  color: var(--fg-muted);
}

/* ---- TABLES ---- */
.data-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 0.75rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

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

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--bg-surface);
}

.td-name { font-weight: 500; color: var(--fg); }
.td-addr, .text-muted { color: var(--fg-muted); }

.priority-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 5px;
}

.priority-badge.p1 { background: rgba(248,113,113,0.15); color: #f87171; }
.priority-badge.p2 { background: rgba(212,160,84,0.15); color: var(--accent); }
.priority-badge.p3 { background: rgba(138,134,128,0.15); color: var(--fg-muted); }

.status-chip {
  display: inline-block;
  font-size: 0.72rem;
  font-family: var(--font-display);
  font-weight: 500;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  background: var(--bg-surface);
  text-transform: capitalize;
}

.status-chip.status-pending { color: var(--accent); border-color: rgba(212,160,84,0.3); }
.status-chip.status-scheduled { color: #93c5fd; border-color: rgba(147,197,253,0.3); }
.status-chip.status-in_transit { color: #fdba74; border-color: rgba(253,186,116,0.3); }
.status-chip.status-delivered { color: #6ee7b7; border-color: rgba(110,231,183,0.3); }
.status-chip.status-cancelled { color: #f87171; border-color: rgba(248,113,113,0.3); }
.status-chip.status-available { color: #6ee7b7; border-color: rgba(110,231,183,0.3); }

.empty-row {
  text-align: center;
  color: var(--fg-muted);
  padding: 2.5rem !important;
  font-size: 0.9rem;
}

.btn-icon-sm {
  background: none;
  border: 1px solid transparent;
  color: var(--fg-muted);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-icon-sm:hover {
  color: #f87171;
  border-color: rgba(248,113,113,0.3);
}

.vehicle-icon-sm { margin-right: 0.3rem; }

/* ---- INLINE FORM ---- */
.inline-form {
  background: var(--bg-elevated);
  border: 1px solid rgba(212, 160, 84, 0.2);
  border-radius: 12px;
  padding: 1.5rem;
}

.inline-form.hidden { display: none; }

.inline-form h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

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

.form-field label {
  font-size: 0.75rem;
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-field input,
.form-field select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-field input:focus,
.form-field select:focus {
  border-color: rgba(212, 160, 84, 0.5);
}

.form-field select option {
  background: var(--bg-surface);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
}

.form-error {
  margin-top: 0.75rem;
  padding: 0.65rem 1rem;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: 7px;
  color: #fca5a5;
  font-size: 0.85rem;
}

.form-error.hidden { display: none; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .optimize-card { flex-direction: column; align-items: flex-start; }
  .vehicle-routes { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .dash-main { padding: 1rem; gap: 1.5rem; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .data-table th:nth-child(3),
  .data-table td:nth-child(3) { display: none; }
  .plan-summary-strip { flex-wrap: wrap; gap: 1rem; }
}
