/* --- Variables de Diseño Cliente PWA (Modo Claro - Legibilidad Alta) --- */
:root {
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'Space Grotesk', monospace;

  /* Colores */
  --bg-light: #ffffff;
  --bg-app: #f8fafc;            /* Slate 50 */
  --bg-card: rgba(255, 255, 255, 0.9);
  --border-glass: rgba(15, 23, 42, 0.08);

  --primary: #8b5cf6;          /* Violet */
  --primary-light: #a78bfa;
  --accent-cyan: #0284c7;
  --color-success: #10b981;
  --color-success-light: #059669;
  --color-danger: #e11d48;
  --color-warning: #d97706;
  --color-muted: #475569;
  --text-main: #0f172a;        /* Slate 900 */
  --text-muted: #334155;       /* Slate 700 - Contraste alto */
}

/* --- Estilos Globales --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  background-color: #f8fafc;    /* Slate 50 */
  color: var(--text-main);
  min-height: 100vh;
  display: block;
  padding: 5.5rem 0 0 280px;    /* Deja espacio para el Sidebar en Desktop */
  overflow-y: auto;
}

.glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 10% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(2, 132, 199, 0.08) 0%, transparent 45%);
  z-index: -1;
  pointer-events: none;
}

/* --- Pantallas/Vistas de la App --- */
.app-screen {
  display: none;
  flex-direction: column;
  padding: 2rem 2rem 5rem 2rem;
  background: transparent;
}

.app-screen.active {
  display: flex;
  animation: slideFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-header {
  margin-bottom: 2rem;
  margin-top: 0.5rem;
}

.app-header h2 {
  font-size: 2.1rem;            /* Más grande para Desktop */
  font-weight: 850;
  letter-spacing: -1px;
  color: var(--text-main);
}

.app-header p {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 0.25rem;
}

/* --- Adaptabilidad y Disposición Premium (Sidebar / Bottom-bar) --- */

/* Escritorio (ancho >= 768px) */
@media (min-width: 768px) {
  .phone-navbar {
    position: fixed;
    left: 0;
    top: 4.5rem; /* Abajo del demo-top-bar */
    width: 280px;
    height: calc(100vh - 4.5rem);
    background: #ffffff;
    border-right: 1px solid var(--border-glass);
    border-top: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 2.5rem 1.5rem;
    box-shadow: 4px 0 25px rgba(15, 23, 42, 0.015);
    z-index: 90;
  }

  .nav-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.1rem;
    cursor: pointer;
    width: 100%;
    padding: 0.95rem 1.5rem;
    border-radius: 16px;
    font-family: var(--font-sans);
    font-size: 0.98rem;
    font-weight: 700;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
  }

  .nav-icon {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
  }

  .nav-tab:hover {
    color: var(--text-main);
    background: rgba(139, 92, 246, 0.04);
  }

  .nav-tab.active {
    color: var(--primary);
    background: rgba(139, 92, 246, 0.08);
  }

  .nav-tab.active .nav-icon {
    transform: scale(1.08);
  }

  .app-screen {
    max-width: 1050px;
    margin: 0 auto;
    padding: 2.5rem 3rem 6rem 3rem;
  }
}

/* Dispositivos Móviles (ancho < 768px) */
@media (max-width: 767px) {
  body {
    padding: 5rem 0.75rem 5.5rem 0.75rem;
  }

  .phone-navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 68px;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0.5rem);
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .nav-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    flex: 1;
    padding: 0.4rem 0;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 700;
    transition: color 0.2s ease;
    min-width: 0;
  }

  .nav-icon {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
  }

  .nav-tab.active { color: var(--primary); }
  .nav-tab.active .nav-icon { transform: scale(1.12); }

  .app-screen {
    padding: 1rem 0.25rem 2.5rem 0.25rem;
  }

  .app-header h2 {
    font-size: 1.5rem;
    letter-spacing: -0.5px;
  }

  .app-header p { font-size: 0.88rem; }

  /* Progress steps responsive */
  .progress-bar-steps {
    padding: 0 0.5rem;
    gap: 0;
  }
  .step-dot {
    width: 28px;
    height: 28px;
    font-size: 0.78rem;
  }

  /* Form responsive */
  .form-container { gap: 0.85rem; }
  input, select {
    font-size: 16px; /* Prevent iOS zoom */
    padding: 0.75rem 1rem;
  }
  .btn { font-size: 0.95rem; padding: 0.8rem 1.1rem; }
  .btn-lg { padding: 0.95rem 1.25rem; font-size: 1rem; }
  .navigation-buttons { gap: 0.6rem; }

  /* Invoice summary responsive */
  .quote-invoice-summary { padding: 1.1rem; }
  .result-row { font-size: 0.88rem; }
  .total-row { font-size: 1rem; }
  .total-row .highlight { font-size: 1.15rem; }
  .rule-box { font-size: 0.78rem; padding: 0.75rem; }

  /* Client telemetry metrics */
  .client-telemetry-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  /* Payment card row — stack on mobile */
  .input-card-row {
    flex-direction: column;
    gap: 0.6rem;
  }

  /* History items */
  .history-item {
    padding: 0.85rem 1rem;
  }

  /* Signature canvas */
  #signature-canvas { height: 100px; }

  /* Camera/media capture */
  .camera-modal-overlay,
  .camera-capture-section {
    border-radius: 0 !important;
    padding: 1rem !important;
  }
}

/* --- Formulario & Inputs --- */
.form-container {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-bottom: 1.5rem;
}

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

.form-group label {
  font-size: 0.88rem;           /* Más grande */
  font-weight: 700;
  color: var(--text-muted);
}

input, select {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.18); /* Borde más visible */
  border-radius: 12px;
  color: var(--text-main);
  padding: 0.8rem 1.1rem;       /* Más espacioso */
  font-size: 0.98rem;           /* Más grande */
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s ease;
}

input:focus, select:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

/* Campo numérico monetario */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-symbol {
  position: absolute;
  left: 1.1rem;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 1.05rem;
}

.input-wrapper input {
  padding-left: 2.2rem;
}

/* --- Botones --- */
.btn {
  font-family: var(--font-sans);
  font-size: 1rem;              /* Más grande */
  font-weight: 750;             /* Más negrita */
  padding: 0.85rem 1.35rem;     /* Más espacioso */
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  padding: 1.1rem 1.5rem;
  font-size: 1.05rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35);
  filter: brightness(1.05);
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.15);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-secondary-light {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  color: var(--primary);
}

.btn-secondary-light:hover {
  background: rgba(139, 92, 246, 0.12);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* Indicadores de Pasos (Wizard Steps) */
.progress-bar-steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  padding: 0 0.5rem;
}

.step-dot {
  width: 28px;                  /* Más grandes */
  height: 28px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-muted);
  font-size: 0.85rem;           /* Más grandes */
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 2;
  border: 1.5px solid rgba(15, 23, 42, 0.02);
}

.step-dot.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
}

.step-connector {
  flex: 1;
  height: 2.5px;
  background: rgba(15, 23, 42, 0.05);
  margin: 0 0.2rem;
  transition: background 0.3s ease;
  z-index: 1;
}

.step-connector.active {
  background: var(--primary);
}

/* Wizard Steps Screens */
.wizard-step {
  display: none;
  flex-direction: column;
  gap: 1.35rem;
}

.wizard-step.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.wizard-step h3 {
  font-size: 1.25rem;           /* Más grande */
  font-weight: 800;
}

.step-info {
  font-size: 0.88rem;           /* Más grande */
  color: var(--text-muted);
  margin-top: -0.8rem;
  font-weight: 600;
}

.navigation-buttons {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.navigation-buttons button {
  flex: 1;
}

/* --- Selector de Inventario --- */
.inventory-selector {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.inv-item {
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 18px;
  padding: 1.1rem 1.3rem;       /* Más espacioso */
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.inv-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.inv-title {
  font-size: 0.98rem;           /* Más grande */
  font-weight: 750;
}

.inv-sub {
  font-size: 0.82rem;           /* Más grande */
  color: var(--text-muted);
  font-weight: 600;
}

.inv-counter {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.inv-counter button {
  width: 32px;                  /* Más grande */
  height: 32px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.15);
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.03);
  transition: all 0.2s;
}

.inv-counter button:hover {
  background: #f1f5f9;
  border-color: rgba(15, 23, 42, 0.2);
}

.inv-counter span {
  font-family: var(--font-mono);
  font-size: 1.05rem;           /* Más grande */
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

/* Panel de volumen total */
.volume-panel {
  background: rgba(139, 92, 246, 0.05);
  border: 1px dashed rgba(139, 92, 246, 0.25);
  padding: 1.1rem;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.vol-lbl {
  font-size: 0.92rem;           /* Más grande */
  color: var(--text-muted);
  font-weight: 700;
}

.vol-val {
  font-family: var(--font-mono);
  font-size: 1.2rem;            /* Más grande */
  font-weight: 800;
  color: var(--primary);
}

/* --- Toggles / Switches --- */
.toggle-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.015);
  border: 1px solid rgba(15, 23, 42, 0.05);
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
}

.toggle-label {
  font-size: 0.88rem;           /* Más grande */
  color: var(--text-muted);
  font-weight: 600;
}

.toggle-switch {
  width: 44px;
  height: 24px;
  appearance: none;
  -webkit-appearance: none;
  background: #cbd5e1;
  border-radius: 20px;
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background 0.2s ease;
  border: none;
  padding: 0;
}

.toggle-switch:checked {
  background: var(--primary);
}

.toggle-switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.toggle-switch:checked::before {
  transform: translateX(20px);
}

/* --- Resumen de Factura --- */
.quote-invoice-summary {
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 18px;
  padding: 1.5rem;
}

.summary-title {
  font-size: 1.05rem;           /* Más grande */
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.9rem;
}

.summary-details {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;           /* Más grande */
  color: var(--text-muted);
}

.result-row .value {
  color: var(--text-main);
  font-weight: 700;
}

.tax-line {
  padding-left: 0.6rem;
  border-left: 2px solid var(--primary-light);
}

.divider {
  height: 1px;
  background: rgba(15, 23, 42, 0.1);
  margin: 0.4rem 0;
}

.total-row {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.total-row .highlight {
  color: var(--primary);
  font-size: 1.3rem;            /* Más grande */
  font-family: var(--font-mono);
}

.rule-box {
  background: rgba(139, 92, 246, 0.05);
  border: 1px dashed rgba(139, 92, 246, 0.25);
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  font-size: 0.82rem;           /* Más grande */
  line-height: 1.5;
  margin-top: 1rem;
  color: var(--primary);
  font-weight: 500;
}

/* --- Firma Digital --- */
.contract-card {
  background: rgba(15, 23, 42, 0.015);
  border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 18px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.contract-card h4 {
  font-size: 0.92rem;           /* Más grande */
  font-weight: 750;
}

.contract-terms {
  font-size: 0.78rem;           /* Más grande */
  color: var(--text-muted);
  line-height: 1.45;
  font-weight: 600;
}

.signature-container {
  position: relative;
  width: 100%;
}

#signature-canvas {
  background: #f8fafc;
  border: 1.5px solid rgba(15, 23, 42, 0.12); /* Más visible */
  border-radius: 12px;
  display: block;
  width: 100%;
  height: 120px;                /* Más alto */
  cursor: crosshair;
}

.btn-clear-sig {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.72rem;           /* Más grande */
  font-weight: 800;
  color: var(--color-danger);
  background: rgba(225, 29, 72, 0.07);
  border: 1px solid rgba(225, 29, 72, 0.2);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

/* Tarjeta de Pago */
.payment-card {
  background: rgba(15, 23, 42, 0.015);
  border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 18px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.payment-card h4 {
  font-size: 0.92rem;
  font-weight: 750;
}

.input-card {
  font-family: var(--font-mono);
  font-size: 0.92rem;
}

.input-card-row {
  display: flex;
  justify-content: space-between;
}

/* --- Panel de Tracking --- */
.track-status-box {
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: 18px;
  padding: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.pulse-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  animation: pulse-ring 1.8s infinite ease-in-out;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.9; }
  50% { transform: scale(1.5); opacity: 0.3; }
  100% { transform: scale(0.9); opacity: 0.9; }
}

.status-details h4 {
  font-size: 0.98rem;           /* Más grande */
  font-weight: 800;
}

.status-details p {
  font-size: 0.82rem;           /* Más grande */
  color: var(--text-muted);
  margin-top: 0.15rem;
  font-weight: 600;
}

/* Mapa del Cliente */
.client-map-wrapper {
  background: #f1f5f9;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 20px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.client-map-svg {
  width: 100%;
  height: auto;
  display: block;
}

.client-map-lbl {
  font-size: 8.5px;             /* Etiquetas de mapa más grandes */
  font-family: var(--font-mono);
  font-weight: 700;
  pointer-events: none;
}

.client-telemetry-panel {
  display: flex;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.cli-metric {
  flex: 1;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 0.95rem;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.cli-metric-lbl {
  font-size: 0.75rem;           /* Más grande */
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

.cli-metric-val {
  font-family: var(--font-mono);
  font-size: 1.05rem;           /* Más grande */
  font-weight: 800;
}

.highlight-purple {
  color: var(--primary);
}

.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* --- Perfil / Historial --- */
.profile-card {
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 18px;
  padding: 1.1rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.25rem;
}

.profile-avatar {
  font-size: 2.2rem;
  background: rgba(139, 92, 246, 0.08);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-info h4 {
  font-size: 1.05rem;           /* Más grande */
  font-weight: 800;
}

.profile-info p {
  font-size: 0.85rem;           /* Más grande */
  color: var(--text-muted);
  font-weight: 500;
}

.section-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.history-item {
  background: rgba(15, 23, 42, 0.015);
  border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 16px;
  padding: 1rem 1.2rem;
}

.history-item.empty {
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 1.75rem;
  font-weight: 500;
}

.hist-left {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hist-id {
  font-size: 0.88rem;
  font-weight: 800;
}

.hist-route {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.hist-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.hist-price {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 750;
}

.hist-status {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
}

.admin-link-box {
  margin-top: 1.75rem;
  text-align: center;
}

.admin-link {
  font-size: 0.88rem;           /* Más grande */
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 700;
  transition: opacity 0.2s;
}

.admin-link:hover {
  opacity: 0.8;
}

/* --- Keyframes --- */
@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Barra de Navegación de Demo Superior --- */
.demo-top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  z-index: 999999;
  font-family: 'Outfit', sans-serif;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.demo-logo {
  font-weight: 850;
  font-size: 1.1rem;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: -0.5px;
}

.demo-logo span {
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.demo-links {
  display: flex;
  gap: 0.75rem;
}

.demo-link-btn {
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 750;
  color: #475569;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.demo-link-btn:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.04);
}

.demo-link-btn.active-client {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.15);
}

.demo-link-btn.active-driver {
  color: #f97316;
  background: rgba(249, 115, 22, 0.08);
  border-color: rgba(249, 115, 22, 0.15);
}

.demo-link-btn.active-admin {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.15);
}

@media (max-width: 480px) {
  .demo-top-bar {
    padding: 0 0.75rem;
    height: 54px;
  }
  .demo-logo {
    display: none;
  }
  .demo-links {
    width: 100%;
    justify-content: space-around;
  }
  .demo-link-btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
  }
}

/* Selector de idioma en el demo bar */
.demo-lang-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.demo-lang-lbl {
  font-size: 0.8rem;
  font-weight: 750;
  color: #475569;
}

.demo-lang-select {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 6px;
  color: #0f172a;
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 750;
  font-family: 'Outfit', sans-serif;
  outline: none;
  cursor: pointer;
  width: auto;
}

.demo-lang-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

/* --- Auto-escalamiento responsivo premium (Dispositivos pequeños y viewport de altura reducida) --- */
@media (max-height: 900px) and (min-width: 481px) {
  .phone-frame {
    transform: scale(0.9);
    transform-origin: center top;
    margin-top: -10px;
    margin-bottom: -70px;
  }
}
@media (max-height: 800px) and (min-width: 481px) {
  .phone-frame {
    transform: scale(0.8);
    transform-origin: center top;
    margin-top: -50px;
    margin-bottom: -150px;
  }
}
@media (max-height: 700px) and (min-width: 481px) {
  .phone-frame {
    transform: scale(0.7);
    transform-origin: center top;
    margin-top: -85px;
    margin-bottom: -220px;
  }
}
@media (max-height: 600px) and (min-width: 481px) {
  .phone-frame {
    transform: scale(0.6);
    transform-origin: center top;
    margin-top: -115px;
    margin-bottom: -300px;
  }
}

/* =====================================================
   RESPONSIVE MAESTRO — Sistema Profundo Multi-breakpoint
   ===================================================== */

/* --- Pantallas pequeñas (< 480px) --- */
@media (max-width: 480px) {
  body { padding: 4.8rem 0.6rem 5rem 0.6rem; }

  .demo-top-bar {
    padding: 0 0.75rem;
    height: 52px;
  }
  .demo-logo { display: none; }
  .demo-links { width: 100%; justify-content: space-around; gap: 0; }
  .demo-link-btn { font-size: 0.78rem; padding: 0.3rem 0.5rem; }
  .demo-lang-lbl { display: none; }

  .app-header h2 { font-size: 1.3rem; }
  .app-header p { font-size: 0.82rem; }

  .wizard-step h3 { font-size: 0.95rem; font-weight: 800; }

  .inv-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .inv-counter { width: 100%; justify-content: flex-end; }

  .profile-card {
    flex-direction: column;
    text-align: center;
    padding: 1.25rem;
    gap: 0.75rem;
  }

  .client-telemetry-panel {
    grid-template-columns: 1fr 1fr;
  }
  .cli-metric { padding: 0.75rem; }
  .cli-metric-val { font-size: 0.9rem; }

  .track-status-box { flex-direction: column; text-align: center; gap: 0.6rem; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .invoice-card {
    border-radius: 24px 24px 0 0 !important;
    max-height: 92vh !important;
    padding: 1.5rem 1.25rem !important;
  }

  #signature-canvas { height: 90px; }
}

/* --- Pantallas muy pequeñas (< 400px) --- */
@media (max-width: 400px) {
  .app-header h2 { font-size: 1.15rem; }
  .step-dot { width: 24px; height: 24px; font-size: 0.7rem; }
  .step-connector { min-width: 20px; }
  .btn { font-size: 0.88rem; padding: 0.7rem 0.9rem; }
  .btn-lg { font-size: 0.92rem; padding: 0.85rem 1rem; }
  .result-row { font-size: 0.82rem; }
  .total-row .highlight { font-size: 1.05rem; }
  input, select { font-size: 16px; padding: 0.7rem 0.85rem; }
  .demo-link-btn { font-size: 0.72rem; padding: 0.25rem 0.4rem; }
}

/* --- Pantallas mínimas (< 360px) — Galaxy S5, iPhone SE 1st gen --- */
@media (max-width: 360px) {
  body { padding: 4.5rem 0.4rem 4.8rem 0.4rem; }
  .app-header h2 { font-size: 1rem; }
  .nav-tab { font-size: 0.65rem; }
  .nav-icon { width: 18px; height: 18px; }
  .phone-navbar { height: 60px; }
  .btn { font-size: 0.82rem; padding: 0.65rem 0.8rem; }
}

/* --- Landscape mobile (altura < 500px, ancho > 500px) --- */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    padding: 4rem 1rem 1rem 280px; /* Sidebar visible en landscape */
  }
  .phone-navbar {
    /* En landscape usar sidebar si hay espacio */
    width: 70px;
    height: 100vh;
    top: 0;
    bottom: auto;
    left: 0;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    padding-bottom: 0;
    border-top: none;
    border-right: 1px solid rgba(15, 23, 42, 0.08);
    padding: 1rem 0;
  }
  .nav-tab { width: 100%; padding: 0.5rem 0; font-size: 0; }
  .nav-icon { width: 24px; height: 24px; }
  .app-screen { padding: 1rem; }
}

/* --- Safe-area para iPhone X+ (notch & home indicator) --- */
@supports (padding: max(0px)) {
  body {
    padding-bottom: max(5.5rem, calc(5rem + env(safe-area-inset-bottom)));
  }
  .phone-navbar {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    height: calc(68px + env(safe-area-inset-bottom));
  }
  .demo-top-bar {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
}

/* --- Optimizaciones táctiles globales --- */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 44px; }
  .nav-tab { min-height: 44px; }
  .inv-counter button { width: 40px; height: 40px; }
  input, select { min-height: 44px; }
  .toggle-switch { width: 52px; height: 28px; }
  .toggle-switch::before { width: 24px; height: 24px; }
  .toggle-switch:checked::before { transform: translateX(24px); }
}

