/* =============================================================================
   ESTILOS RESPONSIVE: PLATAFORMA misdocumentosdeca
   Diseño Mobile-First adaptativo para cualquier resolución y pantalla
   ============================================================================= */

:root {
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --primary-border: #93c5fd;
  --accent: #0284c7;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #10b981;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px -5px rgba(29,78,216,0.15);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Encabezado */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.15rem;
}

.brand-badge {
  background: var(--primary);
  color: white;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-tag {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Contenedor Principal */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

/* Tarjetas y Secciones */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--primary-light);
  padding-bottom: 6px;
}

/* Grids Flexibles y Adaptables */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 640px) {
  .form-grid.two-cols {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid.three-cols {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Formularios y Campos */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  color: var(--text-main);
  background: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 44px; /* Touch target optimizado para móvil */
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 127, 130, 0.15);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  min-height: 44px;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
}
.btn-secondary:hover { background: #d7efef; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-main);
}
.btn-outline:hover { background: #f1f5f9; }

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fecaca; }

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  min-height: 34px;
}

.btn-full { width: 100%; }

.btn-whatsapp {
  background: #25D366;
  color: white;
}
.btn-whatsapp:hover { background: #1ebd5b; }

/* Paradas Intermedias */
.stops-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.stop-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px;
}

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

.stop-title {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.9rem;
}

.stop-actions {
  display: flex;
  gap: 6px;
}

/* Modal y Alertas */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  background: white;
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}

.qr-display {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.qr-display svg, .qr-display canvas {
  border: 4px solid white;
  box-shadow: var(--shadow-md);
  border-radius: 8px;
}

/* Listado de Documentos en Móvil */
.doc-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.doc-item:hover {
  box-shadow: var(--shadow-md);
}

.doc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.doc-code {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

.doc-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.doc-badge.emitido { background: #dcfce7; color: #166534; }
.doc-badge.rectificado { background: #fef9c3; color: #854d0e; }
.doc-badge.anulado { background: #fee2e2; color: #991b1b; }

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

.doc-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* Utilidades */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
