* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Contenedor Principal */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Barra Superior */
.top-navbar {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 1000;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.event-banner-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  max-width: 420px;
}

.event-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.event-title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Área Principal Dividida (Sidebar + Mapa) */
.main-workspace {
  display: flex;
  flex: 1;
  height: calc(100vh - 64px);
  position: relative;
  overflow: hidden;
}

/* Barra Lateral de Consulta */
.sidebar-panel {
  width: 480px;
  min-width: 380px;
  max-width: 580px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: transform var(--transition-normal);
  height: 100%;
  overflow: hidden;
}

/* Banner de Configuración de Origen */
.origin-card-banner {
  padding: 0.9rem 1.15rem;
  background: linear-gradient(180deg, rgba(14, 23, 38, 0.95), rgba(11, 18, 32, 0.98));
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

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

.origin-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-cyan);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.origin-coords-text {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.origin-location-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.origin-btn-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

/* Controles de Filtros y Búsqueda */
.search-filter-section {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 0.85rem;
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  border-radius: var(--radius-md);
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-select {
  flex: 1;
  min-width: 110px;
  padding: 0.45rem 0.65rem;
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--accent-cyan);
}

/* Sliders de Distancia / Tiempo */
.travel-threshold-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.slider-container input[type="range"] {
  flex: 1;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

/* Barra de Ordenamiento y Conteo */
.results-header-bar {
  padding: 0.6rem 1.15rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sort-select {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
}

/* Lista Scrollable de Vacantes */
.vacancies-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.vacancies-scroll-container::-webkit-scrollbar {
  width: 6px;
}

.vacancies-scroll-container::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

/* Panel del Mapa */
.map-panel {
  flex: 1;
  height: 100%;
  position: relative;
  background: #0b121e;
}

#leaflet-map {
  width: 100%;
  height: 100%;
  z-index: 10;
}

/* Floating Controls en el Mapa */
.map-floating-overlay {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.map-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  transition: all var(--transition-fast);
}

.map-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
}

/* Controles móviles (ocultos en escritorio) */
.mobile-view-switcher {
  display: none;
}

.btn-toggle-filters-mobile {
  display: none;
}

.mobile-map-route-card {
  display: none;
}

.filters-collapsible-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Responsive Completo para Móviles y Tablets */
@media (max-width: 900px) {
  body, .app-container {
    height: 100dvh;
    height: -webkit-fill-available;
    overflow: hidden;
  }

  .top-navbar {
    height: 54px;
    padding: 0 0.75rem;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
  }

  .brand-icon svg {
    width: 18px;
    height: 18px;
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }

  .brand-badge {
    font-size: 0.62rem;
    padding: 1px 5px;
  }

  .brand-subtitle,
  .event-banner-pill {
    display: none;
  }

  .navbar-actions {
    gap: 0.35rem;
  }

  .navbar-actions .btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.74rem;
  }

  .main-workspace {
    height: calc(100dvh - 54px);
    height: calc(100% - 54px);
    position: relative;
    overflow: hidden;
  }

  /* Vista Lista por defecto en móvil */
  .main-workspace.mobile-mode-list .sidebar-panel {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    min-width: 100%;
    height: 100%;
    z-index: 100;
    border-right: none;
    border-top: none;
    background: var(--bg-body);
  }

  .main-workspace.mobile-mode-list .map-panel {
    display: none !important;
  }

  /* Vista Mapa en móvil */
  .main-workspace.mobile-mode-map .sidebar-panel {
    display: none !important;
  }

  .main-workspace.mobile-mode-map .map-panel {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
  }

  /* Switcher Flotante Elegante en Móvil */
  .mobile-view-switcher {
    display: flex;
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1500;
    background: rgba(14, 23, 38, 0.94);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-full);
    padding: 4px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.65), 0 0 20px var(--accent-cyan-glow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    gap: 4px;
  }

  .mobile-switch-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
  }

  .mobile-switch-btn.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: white;
    box-shadow: 0 2px 10px rgba(6, 182, 212, 0.4);
  }

  /* Filtros colapsables en móvil */
  .btn-toggle-filters-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .btn-toggle-filters-mobile:hover,
  .btn-toggle-filters-mobile:active {
    border-color: var(--accent-cyan);
    background: var(--bg-card-hover);
  }

  .filters-collapsible-wrapper {
    display: none;
    flex-direction: column;
    gap: 0.65rem;
    padding-top: 0.5rem;
    animation: fadeIn 0.2s ease;
  }

  .filters-collapsible-wrapper.open {
    display: flex;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .origin-card-banner {
    padding: 0.65rem 0.85rem;
    gap: 0.35rem;
  }

  .origin-location-name {
    font-size: 0.85rem;
  }

  .origin-btn-group .btn {
    padding: 0.3rem 0.55rem;
    font-size: 0.74rem;
  }

  .search-filter-section {
    padding: 0.65rem 0.85rem;
    gap: 0.5rem;
  }

  .results-header-bar {
    padding: 0.5rem 0.85rem;
  }

  /* Lista Scrollable fluida en móvil */
  .vacancies-scroll-container {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
    padding: 0.75rem 0.75rem 5.5rem 0.75rem;
    gap: 0.65rem;
  }

  /* Ficha flotante de ruta seleccionada en móvil sobre el mapa */
  .mobile-map-route-card {
    position: absolute;
    bottom: 5rem;
    left: 0.85rem;
    right: 0.85rem;
    z-index: 1400;
    background: rgba(14, 23, 38, 0.95);
    border: 1px solid var(--accent-cyan);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 15px var(--accent-cyan-glow);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: slide-up 0.25s ease-out;
  }

  @keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .mobile-map-school-name {
    font-weight: 700;
    font-size: 0.84rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-map-school-meta {
    font-size: 0.76rem;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    margin-top: 2px;
  }

  /* Controles flotantes de mapa adaptados para móvil */
  .map-floating-overlay {
    top: 0.75rem;
    right: 0.75rem;
  }

  .map-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.75rem;
  }
}

/* Banner de Modo Selección de Origen en Mapa */
.map-picker-banner {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(14, 23, 38, 0.94);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-size: 0.85rem;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  animation: slide-down 0.25s ease-out;
}

@keyframes slide-down {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
