/* ==========================================================================
   DriverAnalytics Pro - Modern Design System (Mobile-First & PWA Ready)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-card-solid: #1e293b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.5);

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-blue: #38bdf8;
  --accent-purple: #a855f7;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-color);
  --shadow-glow: 0 0 25px var(--accent-emerald-glow);

  --bottom-nav-height: 68px;
  --header-height: 64px;
}

[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --bg-card-solid: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(16, 185, 129, 0.6);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.06), 0 0 0 1px var(--border-color);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  padding-bottom: calc(var(--bottom-nav-height) + 20px);
}

@media (min-width: 1024px) {
  body {
    padding-bottom: 30px;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

/* Header & Top Bar */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
}

[data-theme="light"] .top-header {
  background: rgba(241, 245, 249, 0.85);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.brand span.accent {
  color: var(--accent-emerald);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

/* Desktop Navigation */
.desktop-nav {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

@media (min-width: 1024px) {
  .desktop-nav {
    display: flex;
  }
}

.nav-link {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--accent-emerald);
  background: var(--accent-emerald-glow);
}

/* Mobile Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}

[data-theme="light"] .bottom-nav {
  background: rgba(255, 255, 255, 0.92);
}

@media (min-width: 1024px) {
  .bottom-nav {
    display: none;
  }
}

.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.bottom-tab svg {
  width: 20px;
  height: 20px;
}

.bottom-tab.active {
  color: var(--accent-emerald);
  transform: translateY(-2px);
}

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* Page Header */
.page-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .page-title-wrap {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Glassmorphic Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

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

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

@media (min-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.kpi-card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.kpi-value.emerald { color: var(--accent-emerald); }
.kpi-value.blue { color: var(--accent-blue); }
.kpi-value.purple { color: var(--accent-purple); }
.kpi-value.amber { color: var(--accent-amber); }

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Filter Controls */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  align-items: center;
}

.filter-item {
  flex: 1 1 140px;
}

.filter-select, .filter-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--accent-emerald);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 1024px) {
  .charts-grid {
    grid-template-columns: 2fr 1fr;
  }
}

.chart-container {
  position: relative;
  width: 100%;
  min-height: 260px;
  max-height: 340px;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-sim { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-nao { background: rgba(244, 63, 94, 0.15); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-black { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-comfort { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-uberx { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent-emerald);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
  background: #059669;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card-solid);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Strategy & Insights Cards */
.strategy-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .strategy-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.insight-box {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.insight-icon {
  color: var(--accent-emerald);
  flex-shrink: 0;
}

.insight-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.insight-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Table Responsive */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  white-space: nowrap;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.data-table tfoot tr {
  background: rgba(16, 185, 129, 0.08);
  border-top: 2px solid rgba(16, 185, 129, 0.35);
}

.data-table tfoot td {
  padding: 0.95rem 1rem;
  border-bottom: none;
  font-size: 0.88rem;
}

/* Drag & Drop Upload Zone */
.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.25s ease;
}

.drop-zone.dragover {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.05);
  transform: scale(1.01);
}

.drop-zone-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: var(--accent-emerald);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card-solid);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.3s ease;
}

.toast.success { border-color: var(--accent-emerald); }
.toast.error { border-color: var(--accent-rose); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Utilities */
.text-emerald { color: var(--accent-emerald); }
.text-rose { color: var(--accent-rose); }
.text-amber { color: var(--accent-amber); }
.text-blue { color: var(--accent-blue); }
.text-purple { color: var(--accent-purple); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-mono { font-family: ui-monospace, monospace; }
.truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================
   PWA - Mobile Install Banner & iOS Modal
   ========================================================== */
.pwa-install-banner {
  position: fixed;
  bottom: 74px;
  left: 12px;
  right: 12px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(6, 78, 59, 0.95));
  border: 1px solid rgba(16, 185, 129, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 999;
  animation: slideUpPwa 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 768px) {
  .pwa-install-banner {
    left: auto;
    right: 24px;
    bottom: 24px;
    max-width: 390px;
  }
}

@keyframes slideUpPwa {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.pwa-banner-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #090d16;
  border: 1px solid #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.pwa-banner-info {
  flex: 1;
}

.pwa-banner-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pwa-banner-sub {
  font-size: 0.73rem;
  color: #cbd5e1;
  margin: 0;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-pwa-action {
  background: #10b981;
  color: #ffffff;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  white-space: nowrap;
}

.btn-pwa-dismiss {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* iOS PWA Installation Modal */
.ios-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}

.ios-modal-card {
  background: var(--bg-card-solid, #0f172a);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: 20px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
  animation: slideUpPwa 0.35s ease;
  position: relative;
}

.ios-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-main);
}

.ios-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-emerald);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* Standalone PWA adjustments (When opened as installed app) */
@media all and (display-mode: standalone) {
  body {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
  }
  .pwa-install-banner, #btn-pwa-install {
    display: none !important;
  }
  .top-header {
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }
  .bottom-nav {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    height: calc(64px + env(safe-area-inset-bottom, 0px));
  }
}

