/* ==========================================================================
   PORTAL PRINCIPAL — ESTILOS DEL SHELL M3 (METEO & TRÁFICO)
   ========================================================================== */

:root {
  --portal-header-height: 72px;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family-body);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

/* Header del Portal Principal */
.portal-header {
  height: var(--portal-header-height);
  background: var(--md-sys-color-surface-container-lowest);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-elevation-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1000;
  position: relative;
  transition: background-color var(--duration-medium) ease, border-color var(--duration-medium) ease;
}

[data-theme="dark"] .portal-header {
  background: var(--md-sys-color-surface-container-low);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* Brand Section */
.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
  user-select: none;
}

.portal-brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--shape-md);
  background: linear-gradient(135deg, #006495 0%, #0284c7 50%, #0369a1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 100, 149, 0.25);
  transition: transform var(--duration-short) ease;
}

.portal-brand:hover .portal-brand-logo {
  transform: scale(1.05);
}

.portal-brand-titles {
  display: flex;
  flex-direction: column;
}

.portal-brand-title {
  font-family: var(--font-family-brand);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--md-sys-color-on-surface);
  letter-spacing: -0.02em;
}

.portal-brand-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--md-sys-color-primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ==========================================================================
   SELECTOR DE LOCALIZACIÓN EN CABECERA DEL PORTAL (GLOBAL)
   ========================================================================== */
.portal-location-wrapper {
  position: relative;
}

.portal-loc-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--shape-full);
  padding: 0.35rem 0.85rem;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: all var(--duration-short) ease;
  user-select: none;
}

.portal-loc-btn:hover {
  background: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.portal-loc-btn .loc-icon {
  font-size: 20px;
  color: #0284c7;
  flex-shrink: 0;
}

.portal-loc-btn .loc-text-group {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.15;
}

.portal-loc-btn .loc-city {
  font-family: var(--font-family-brand);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.portal-loc-btn .loc-sub {
  font-size: 0.68rem;
  color: var(--md-sys-color-outline);
  font-weight: 500;
}

.portal-loc-btn .loc-arrow {
  font-size: 18px;
  color: var(--md-sys-color-outline);
  transition: transform var(--duration-short) ease;
}

.portal-loc-btn[aria-expanded="true"] .loc-arrow {
  transform: rotate(180deg);
}

/* Dropdown Flotante */
.portal-loc-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 330px;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--shape-xl);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 1rem;
  z-index: 2000;
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  backdrop-filter: blur(16px);
  animation: fadeInDown 0.2s ease-out;
}

[data-theme="dark"] .portal-loc-dropdown {
  background: var(--md-sys-color-surface-container-low);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.portal-loc-dropdown.visible {
  display: flex;
}

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

.loc-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-family-brand);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.loc-search-box {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--shape-md);
  padding: 0.35rem 0.65rem;
}

.loc-search-box input {
  border: none;
  background: transparent;
  width: 100%;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--md-sys-color-on-surface);
  outline: none;
}

.loc-clear-btn {
  background: transparent;
  border: none;
  color: var(--md-sys-color-outline);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
}

.loc-gps-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--shape-md);
  padding: 0.45rem 0.75rem;
  color: #0284c7;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-short) ease;
}

.loc-gps-btn:hover {
  background: rgba(2, 132, 199, 0.16);
}

.loc-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--md-sys-color-outline);
  letter-spacing: 0.04em;
}

.loc-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
}

.loc-city-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--shape-full);
  padding: 0.35rem 0.65rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all var(--duration-short) ease;
  text-align: left;
}

.loc-city-pill:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-primary);
}

.loc-city-pill.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.loc-city-pill .pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

.loc-city-pill .pill-star {
  font-size: 15px;
  color: #f59e0b;
  flex-shrink: 0;
}

.loc-city-pill.active .pill-star {
  color: #fef08a;
}

.loc-empty-favorites {
  padding: 0.75rem 0.5rem;
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  background: var(--md-sys-color-surface-container);
  border-radius: var(--shape-md);
  border: 1px dashed var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  line-height: 1.3;
}

.loc-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  padding-top: 0.4rem;
}

.loc-result-item {
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.6rem;
  border-radius: var(--shape-sm);
  cursor: pointer;
  font-size: 0.8rem;
}

.loc-result-item:hover {
  background: var(--md-sys-color-surface-container-high);
}

/* Navigation Tabs (Material Design 3 Segmented / Pill Tabs) */
.portal-nav-tabs {
  display: flex;
  align-items: center;
  background: var(--md-sys-color-surface-container);
  padding: 0.3rem;
  border-radius: var(--shape-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  gap: 0.35rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .portal-nav-tabs {
  background: var(--md-sys-color-surface-container-high);
}

.portal-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--shape-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--font-family-brand);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-short) ease;
  position: relative;
  text-decoration: none;
  user-select: none;
}

.portal-tab-btn:hover {
  color: var(--md-sys-color-on-surface);
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .portal-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.portal-tab-btn.active {
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .portal-tab-btn.active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.portal-tab-btn .tab-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--shape-full);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-outline);
  transition: all var(--duration-short) ease;
}

.portal-tab-btn.active .tab-badge {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

[data-theme="dark"] .portal-tab-btn.active .tab-badge {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

/* Actions Section */
.portal-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.portal-status-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--shape-full);
  padding: 0.35rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Badge de Usuario Google Autenticado */
.portal-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--shape-full);
  padding: 0.25rem 0.7rem 0.25rem 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  max-width: 190px;
}

.portal-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #006495 0%, #0284c7 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.portal-user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main Viewport Container */
.portal-viewport-container {
  width: 100%;
  height: calc(100vh - var(--portal-header-height));
  position: relative;
  background: var(--md-sys-color-surface);
  overflow: hidden;
}

.portal-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity var(--duration-medium) ease, visibility var(--duration-medium) ease;
}

.portal-frame.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

/* Mobile & Responsive Rules */
@media (max-width: 900px) {
  .portal-header {
    height: auto;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .portal-viewport-container {
    height: calc(100vh - 120px);
  }

  .portal-status-pill {
    display: none;
  }

  .portal-nav-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .portal-tab-btn {
    flex: 1;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}
