/* ==========================================================================
   EASY DELIVERY - APP DEL REPARTIDOR (primero móvil, 360px)
   Usa los tokens de css/main.css. Sin datos simulados: todo viene del backend.
   ========================================================================== */

body.drv-body {
  background: var(--bg-main);
  min-height: 100vh;
}

.drv-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

/* ---------------------------------------------------------------------- */
/* Pantalla de acceso                                                     */
/* ---------------------------------------------------------------------- */
.drv-login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.75rem 1.25rem;
  gap: 1.5rem;
}

.drv-login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.drv-login-brand img {
  height: 42px;
  width: auto;
}

.drv-login-brand h1 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.drv-login-brand p {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.drv-login-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-lg);
}

.drv-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.drv-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

/* main.css no trae .form-control (vive en admin-base.css, que esta página
   no carga para no arrastrar estilos de vistas ajenas): se define aquí. */
.form-control {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  color: var(--input-text);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.drv-login-status {
  font-size: 0.82rem;
  font-weight: 600;
  min-height: 1.2rem;
}

.drv-login-status.is-error { color: var(--easy-red); }
.drv-login-status.is-info { color: var(--text-muted); }

.drv-submit-btn {
  padding: 0.85rem;
  font-size: 0.95rem;
  font-weight: 700;
}

/* ---------------------------------------------------------------------- */
/* Cabecera de la app                                                     */
/* ---------------------------------------------------------------------- */
.drv-header {
  position: sticky;
  top: 0;
  z-index: 500;
  background: var(--bg-surface-glass, var(--bg-surface));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.drv-header-identity {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.drv-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--easy-blue-light);
  color: var(--easy-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

.drv-header-identity-text {
  min-width: 0;
}

.drv-header-identity-text strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drv-header-identity-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.drv-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.drv-icon-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.drv-icon-btn:hover { color: var(--text-main); border-color: var(--easy-blue); }

/* Interruptor Disponible / Fuera de servicio */
.drv-status-bar {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.drv-status-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.drv-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-subtle);
}

.drv-status-dot.is-free { background: var(--easy-green); box-shadow: 0 0 8px var(--easy-green); }
.drv-status-dot.is-busy { background: var(--easy-amber); box-shadow: 0 0 8px var(--easy-amber); }
.drv-status-dot.is-offline { background: var(--text-subtle); }

.drv-toggle {
  position: relative;
  width: 52px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  flex-shrink: 0;
}

.drv-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-subtle);
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.drv-toggle.is-on .drv-toggle-knob {
  transform: translateX(24px);
  background: var(--easy-green);
}

.drv-toggle:disabled,
.drv-toggle.is-disabled { opacity: 0.5; cursor: not-allowed; }

/* Aviso de ubicación */
.drv-gps-banner {
  margin: 0.75rem 1rem 0;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--easy-amber-light);
  border: 1px solid rgba(212, 139, 64, 0.4);
  color: var(--easy-amber);
  font-size: 0.78rem;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

/* Aviso de nueva entrega */
.drv-new-order-banner {
  margin: 0.75rem 1rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--easy-blue-light);
  border: 1px solid rgba(0, 169, 255, 0.4);
  color: var(--easy-blue);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  animation: drvPulseBanner 1.4s ease-in-out infinite;
}

@keyframes drvPulseBanner {
  0%, 100% { box-shadow: 0 0 0 rgba(0, 169, 255, 0.4); }
  50% { box-shadow: 0 0 14px rgba(0, 169, 255, 0.4); }
}

/* ---------------------------------------------------------------------- */
/* Contenido / lista                                                      */
/* ---------------------------------------------------------------------- */
.drv-content {
  flex: 1;
  padding: 0.85rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.drv-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-top: 0.4rem;
}

.drv-order-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.drv-order-card:active { transform: scale(0.98); }
.drv-order-card:hover { border-color: var(--easy-blue); }

.drv-order-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.drv-order-ref {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

.drv-order-dest {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.drv-order-meta {
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.drv-empty-state,
.drv-error-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.drv-error-state { color: var(--easy-red); }

.drv-loading-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------- */
/* Detalle de la orden                                                    */
/* ---------------------------------------------------------------------- */
.drv-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--easy-blue);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0;
  align-self: flex-start;
}

.drv-detail-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drv-detail-block-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.drv-detail-row {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.45;
}

.drv-detail-row a {
  color: var(--easy-blue);
  text-decoration: none;
  font-weight: 700;
}

.drv-detail-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

#drv-map {
  height: 220px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-main);
}

.drv-nav-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.drv-nav-buttons a.btn {
  font-size: 0.82rem;
}

.drv-actions-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.drv-actions-row .btn {
  padding: 0.85rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.drv-lock-notice {
  background: var(--easy-red-light);
  border: 1px solid rgba(209, 23, 20, 0.35);
  color: var(--easy-red);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ---------------------------------------------------------------------- */
/* Modales de entrega / no entrega                                        */
/* ---------------------------------------------------------------------- */
.drv-modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.drv-attempts-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.drv-attempts-note.is-warning { color: var(--easy-amber); font-weight: 700; }

.drv-field-error {
  font-size: 0.76rem;
  color: var(--easy-red);
  min-height: 1rem;
}

.drv-char-counter {
  font-size: 0.72rem;
  color: var(--text-subtle);
  text-align: right;
}

textarea.form-control {
  resize: vertical;
  min-height: 90px;
  font-family: inherit;
}

/* ---------------------------------------------------------------------- */
/* Utilidades                                                              */
/* ---------------------------------------------------------------------- */
.drv-hidden { display: none !important; }

.drv-spin {
  animation: drvSpin 0.8s linear infinite;
}

@keyframes drvSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Pantallas a ancho completo (login / sesión caducada) reusan drv-shell */
@media (min-width: 560px) {
  .drv-shell {
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xl);
  }
}
