/* ============================================================
   TUBASA — Design System
   Inspirado en tubasa.es: azul corporativo, fondo claro, badges
   ============================================================ */

/* === Variables === */
:root {
  /* Colores principales (de tubasa.es) */
  --primary: #4A90D9;
  --primary-dark: #3a7bc8;
  --primary-light: #6ba8e8;
  --primary-bg: #e8f0fa;

  /* Neutrales */
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-hover: #f0f4f8;
  --text: #1a2332;
  --text-secondary: #5a6577;
  --text-muted: #8895a7;
  --border: #e2e8f0;
  --border-light: #edf2f7;

  /* Acentos */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --proximo: #22c55e;

  /* Espaciado */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Tipografía */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.7rem;
  --font-size-sm: 0.8rem;
  --font-size-base: 0.95rem;
  --font-size-lg: 1.1rem;
  --font-size-xl: 1.35rem;
  --font-size-2xl: 1.6rem;

  /* Bordes */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.06);

  /* Transiciones */
  --transition-fast: 150ms ease;
  --transition: 250ms ease;
  --transition-slow: 400ms ease;
}

/* === Reset === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

input {
  font-family: inherit;
}

/* === App Layout === */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: var(--space-md) var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(74, 144, 217, 0.3);
}

.app-header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-logo {
  font-size: var(--font-size-xl);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.app-logo span {
  opacity: 0.8;
  font-weight: 300;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: var(--space-2xl);
}

/* === View Header === */
.view-header {
  margin-bottom: var(--space-lg);
}

.view-header h1 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.view-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* === Disclaimer === */
.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--primary-bg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  color: var(--primary-dark);
  line-height: 1.5;
  margin-bottom: var(--space-lg);
  border: 1px solid rgba(74, 144, 217, 0.15);
}

.disclaimer svg {
  flex-shrink: 0;
  margin-top: 1px;
  opacity: 0.7;
}

/* === Líneas Grid === */
.lineas-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.linea-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
}

.linea-card.animate-in {
  animation: slideUp 0.4s ease forwards;
  animation-delay: var(--delay, 0ms);
}

.linea-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--line-color, var(--primary));
  opacity: 0;
  transition: opacity var(--transition);
}

.linea-card:hover,
.linea-card:active {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
  transform: translateY(-1px);
}

.linea-card:hover::before,
.linea-card:active::before {
  opacity: 1;
}

.linea-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: var(--font-size-sm);
  letter-spacing: 0.5px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition-fast);
}

.linea-card:hover .linea-badge {
  transform: scale(1.05);
}

.linea-info {
  flex: 1;
  min-width: 0;
}

.linea-nombre {
  display: block;
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--text);
}

.linea-desc {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linea-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.linea-card:hover .linea-arrow {
  transform: translateX(3px);
  color: var(--primary);
}

/* === Paradas Header === */
.paradas-header {
  margin-bottom: var(--space-md);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

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

.header-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.header-title-group h1 {
  font-size: var(--font-size-lg);
}

.header-title-group .view-subtitle {
  font-size: var(--font-size-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.linea-badge-large {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: var(--font-size-base);
  letter-spacing: 0.5px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* === Search === */
.search-wrapper {
  position: relative;
  margin-bottom: var(--space-md);
}

.search-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: var(--space-md) var(--space-md) var(--space-md) 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  background: var(--bg-card);
  color: var(--text);
  transition: all var(--transition-fast);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* === Paradas List === */
.paradas-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.parada-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
  opacity: 0;
  transform: translateY(8px);
}

.parada-card.animate-in {
  animation: slideUp 0.35s ease forwards;
  animation-delay: var(--delay, 0ms);
}

.parada-card:hover,
.parada-card:active {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

/* Sentido badge (Ida / Vuelta) */
.sentido-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.3px;
  vertical-align: middle;
  margin-left: 6px;
}

.sentido-ida {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.sentido-vuelta {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

.parada-seq {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg);
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.parada-seq-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.sentido-badge-sm {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.parada-info {
  flex: 1;
  min-width: 0;
}

.parada-top {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.parada-code {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.parada-name {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.parada-lineas {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: var(--space-xs);
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  letter-spacing: 0.3px;
  line-height: 1.5;
}

.parada-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.parada-card:hover .parada-arrow {
  transform: translateX(3px);
  color: var(--primary);
}

/* === Tiempos === */
.tiempos-header {
  margin-bottom: var(--space-md);
}

.parada-icon-large {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--primary-bg);
  color: var(--primary);
  flex-shrink: 0;
}

.tiempos-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  gap: var(--space-md);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-refresh:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(74, 144, 217, 0.3);
}

.btn-refresh.spinning svg {
  animation: spin 0.6s ease;
}

.auto-refresh-indicator {
  flex: 1;
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-full);
  overflow: hidden;
  height: 28px;
  display: flex;
  align-items: center;
}

.refresh-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--primary-bg), rgba(74, 144, 217, 0.2));
  width: 0%;
  transition: width 1s linear;
  border-radius: var(--radius-full);
}

#refresh-countdown {
  position: relative;
  z-index: 1;
  padding: 0 var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.tiempos-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.tiempo-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  opacity: 0;
  transform: translateY(8px);
  transition: all var(--transition);
}

.tiempo-card.animate-in {
  animation: slideUp 0.4s ease forwards;
  animation-delay: var(--delay, 0ms);
}

.tiempo-card.tiempo-proximo {
  border-color: rgba(34, 197, 94, 0.3);
  background: linear-gradient(135deg, #f0fdf4 0%, var(--bg-card) 100%);
}

.tiempo-linea-info {
  flex: 1;
  min-width: 0;
}

.tiempo-linea-name {
  display: block;
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--text);
}

.tiempo-distancia {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.tiempo-value {
  flex-shrink: 0;
  text-align: right;
}

.tiempo-minutos {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text);
}

.tiempo-proximo-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: var(--proximo);
  color: white;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 700;
  letter-spacing: 0.3px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
  animation: pulse 1.5s ease infinite;
}

.local-notice {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  color: #92400e;
}

.local-notice svg {
  flex-shrink: 0;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
}

.empty-state svg {
  opacity: 0.4;
  margin-bottom: var(--space-md);
}

.empty-state p {
  font-size: var(--font-size-base);
  font-weight: 500;
}

.empty-hint {
  display: block;
  font-size: var(--font-size-xs);
  margin-top: var(--space-sm);
  opacity: 0.7;
}

/* === Skeleton Loading === */
.skeleton {
  pointer-events: none;
  opacity: 1 !important;
  transform: none !important;
}

.linea-badge-skeleton,
.parada-code-skeleton,
.tiempo-badge-skeleton {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  flex-shrink: 0;
}

.linea-info-skeleton,
.parada-info-skeleton,
.tiempo-info-skeleton {
  flex: 1;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
}

.skeleton-title {
  width: 60%;
  margin-bottom: 8px;
}

.skeleton-desc {
  width: 80%;
  height: 10px;
}

.tiempo-value-skeleton {
  width: 70px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
}

/* === Animations === */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

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

/* === Responsive === */
@media (max-width: 480px) {
  .app-header {
    padding: var(--space-sm) var(--space-md);
  }

  #app {
    padding: var(--space-sm);
  }

  .linea-card {
    padding: var(--space-md);
  }

  .header-title-group .view-subtitle {
    max-width: 180px;
  }

  .tiempos-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* === Touch feedback (mobile) === */
@media (hover: none) {
  .linea-card:active,
  .parada-card:active {
    transform: scale(0.98);
    transition-duration: 50ms;
  }

  .back-btn:active {
    background: var(--primary-bg);
  }
}

/* Correspondencias Tabs */
.dia-tabs-wrapper {
  display: flex;
  gap: 8px;
  padding: 0 16px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dia-tabs-wrapper::-webkit-scrollbar {
  display: none;
}
.dia-tab-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 0.85em;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.dia-tab-btn:hover {
  background: #e5e7eb;
  color: #1f2937;
}
.dia-tab-btn.active {
  background: var(--primary, #4A90D9);
  color: #ffffff;
  border-color: var(--primary, #4A90D9);
  box-shadow: 0 4px 6px -1px rgba(74, 144, 217, 0.2);
}


