/* ==========================================================================
   CO-PILOTE AUTO - NEXT-GEN AUTOMOTIVE WEB APP
   100% Native Mobile App Feel • Zero Horizontal Scroll • Pure Modern UI
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg-app: #080c14;
  --bg-surface: #0f1624;
  --bg-card: #151f32;
  --bg-card-hover: #1b273e;
  --bg-elevated: #1f2c44;
  --bg-input: #0a0f18;
  
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --border-focus: #3b82f6;

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

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #93c5fd;
  --primary-glow: rgba(59, 130, 246, 0.25);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.25);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.25);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.25);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-full: 9999px;

  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 10px 30px rgba(0, 0, 0, 0.5);
  
  --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   RESET & ZERO HORIZONTAL SCROLL ENFORCEMENT
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  max-width: 100%;
}

html, body {
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
  position: relative;
  -webkit-text-size-adjust: 100%;
}

html {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background-color: var(--bg-app);
  color: var(--text-main);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(59, 130, 246, 0.14), transparent 70%),
    radial-gradient(circle at 100% 40%, rgba(16, 185, 129, 0.04), transparent 50%),
    var(--bg-app);
  background-attachment: fixed;
  padding-bottom: calc(75px + env(safe-area-inset-bottom, 16px)); /* Espace pour la bottom nav */
}

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

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ==========================================================================
   LAYOUT & CONTAINERS (MOBILE OPTIMIZED)
   ========================================================================== */
.container {
  width: 100%;
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 768px) {
  .container {
    padding-left: 28px;
    padding-right: 28px;
  }
}

.main-content {
  flex: 1;
  padding-top: 18px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Grilles réactives fluides (Zéro débordement) */
.app-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  width: 100%;
}

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

.app-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: 100%;
}

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

@media (min-width: 992px) {
  .app-grid-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
}

/* ==========================================================================
   TOP APP BAR (WEB APP STYLE HEADER)
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: rgba(8, 12, 20, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px; /* Format compact app native */
  width: 100%;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: #fff;
  flex-shrink: 0;
}

.brand-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
  flex-shrink: 0;
}

.brand-logo span em {
  font-style: normal;
  color: var(--primary-hover);
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 6px;
}

@media (min-width: 900px) {
  .desktop-nav {
    display: flex;
  }
  .mobile-menu-trigger {
    display: none !important;
  }
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #fff;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.plan-badge.premium {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.plan-badge.free {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.mobile-menu-trigger {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* ==========================================================================
   MOBILE BOTTOM NAVIGATION BAR (FLUIDE & TOUCH-FRIENDLY)
   ========================================================================== */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 95;
  background: rgba(11, 16, 26, 0.94);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 8px));
  box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.4);
}

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

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  flex: 1;
  text-align: center;
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.bottom-nav-item.active {
  color: var(--primary-light);
}

.bottom-nav-item.active svg {
  stroke: var(--primary-light);
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

/* ==========================================================================
   CARDS & PANELS (APP GLASSMORPHISM)
   ========================================================================== */
.card-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  width: 100%;
}

@media (min-width: 768px) {
  .card-box {
    padding: 24px 22px;
  }
}

.card-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transition: all var(--transition);
  border: 1px solid transparent;
  user-select: none;
  min-height: 44px; /* Touch target Apple/Google */
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 15px var(--success-glow);
}

.btn-success:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--primary-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-height: 50px;
  padding: 12px 20px;
  font-size: 0.95rem;
}

.btn-block {
  width: 100% !important;
}

/* VRAI BOUTON MODIFIER LA PHOTO (Pill Glassmorphism) */
.btn-change-photo {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff !important;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  transition: all var(--transition);
  text-decoration: none !important;
  user-select: none;
}

.btn-change-photo:hover, .btn-change-photo:active {
  background: rgba(37, 99, 235, 0.9);
  border-color: rgba(96, 165, 250, 0.5);
  transform: translateY(-1px);
}

/* ==========================================================================
   REALISTIC EU LICENSE PLATE
   ========================================================================== */
.license-plate {
  display: inline-flex;
  align-items: center;
  height: 30px;
  background: #ffffff;
  color: #0f172a;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-weight: 800;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  user-select: all;
  flex-shrink: 0;
}

.license-plate .eu-flag {
  width: 20px;
  height: 100%;
  background: #003399;
  color: #ffcc00;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.52rem;
  font-family: sans-serif;
  font-weight: 900;
  padding: 0 1px;
}

.license-plate .plate-number {
  padding: 0 8px;
}

/* ==========================================================================
   VEHICLE CARDS (GARAGE GRID)
   ========================================================================== */
.garage-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  width: 100%;
}

@media (min-width: 640px) {
  .garage-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

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

.car-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), border-color var(--transition);
}

.car-card:hover {
  border-color: rgba(96, 165, 250, 0.4);
  transform: translateY(-2px);
}

.car-card-img-wrapper {
  position: relative;
  width: 100%;
  height: 175px;
  background-color: #0b111a;
  background-size: cover;
  background-position: center;
}

.car-card-img-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(21, 31, 50, 0.95) 100%);
}

.car-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  gap: 14px;
}

.car-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.car-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}

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

.car-info-row span:first-child {
  color: var(--text-muted);
}

.car-info-row span:last-child {
  font-weight: 700;
  color: #fff;
}

/* ==========================================================================
   HEALTH BADGES & POLES WIDGETS
   ========================================================================== */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.health-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.health-green {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.health-green::before { background: #10b981; box-shadow: 0 0 6px #10b981; }

.health-orange {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.health-orange::before { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }

.health-red {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.health-red::before { background: #ef4444; box-shadow: 0 0 6px #ef4444; }

.pole-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pole-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pole-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
}

.health-progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.health-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
}

.pole-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   MOBILE DATA CARDS & RESPONSIVE TABLES
   ========================================================================== */
.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

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

.app-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}

.app-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

@media (max-width: 767px) {
  .table-desktop-only {
    display: none !important;
  }
}

.mobile-maint-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

@media (min-width: 768px) {
  .mobile-maint-list {
    display: none;
  }
}

.maint-mobile-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.maint-mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.maint-mobile-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  word-break: break-word;
}

.maint-mobile-cost {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-light);
  white-space: nowrap;
}

.maint-mobile-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   FORMS & INPUTS (TOUCH CONVIVIAL)
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
  width: 100%;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1rem; /* 16px évite le zoom Safari */
  outline: none;
  transition: border-color var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 36px;
}

textarea.form-control {
  min-height: 85px;
}

/* MODALS (BOTTOM SHEET SMARTPHONE, POPUP DESKTOP) */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(4, 7, 12, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-elevated);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--transition);
  overflow: hidden;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 20px;
  }
  .modal-card {
    border-radius: var(--radius-xl);
    transform: scale(0.96);
  }
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .modal-overlay.active .modal-card {
    transform: scale(1);
  }
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Stepper progress */
.stepper-progress {
  width: 100%;
  height: 4px;
  background: var(--bg-input);
  overflow: hidden;
}

.stepper-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transition: width 0.3s ease;
}

/* Toast container */
#toastContainer {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}

@media (min-width: 640px) {
  #toastContainer {
    left: auto;
    right: 20px;
    align-items: flex-end;
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: rgba(18, 26, 42, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-elevated);
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.25s ease;
}

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

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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