/**
 * Shell compartido: cabecera, toasts, footer fijo y columna de contenido (576px).
 * Referencia visual: home, login, registro.
 */
:root {
  --mobbi-content-max: 576px;
  --mobbi-footer-max: 600px;
  /* Altura aproximada barra superior (safe area + contenido); ajustar si cambia el padding del header */
  --mobbi-header-sticky-offset: 76px;
  --mobbi-header-blur: 20px;
  --mobbi-brand: #0d6efd;
  --mobbi-brand-dark: #0a58ca;
  --mobbi-text: #111827;
  --mobbi-text-muted: #6b7280;
}

body {
  background-color: #f5f5f5;
  padding-bottom: 80px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Cabecera tipo app nativa (blur + safe area + CTAs pill) */
.top-header,
.search-top-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  display: block;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(var(--mobbi-header-blur));
  -webkit-backdrop-filter: saturate(180%) blur(var(--mobbi-header-blur));
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 4px 24px -6px rgba(0, 0, 0, 0.07);
}

.search-top-bar {
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

/* Fila única: logo | buscador | usuario */
.app-header-bar__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: var(--mobbi-footer-max);
  margin: 0 auto;
  min-height: 44px;
}

.app-header-bar__logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  line-height: 0;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}

.app-header-bar__logo .logo {
  height: 32px;
  width: auto;
  display: block;
}

.app-header-bar__search-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}

.app-header-bar__search-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  color: var(--mobbi-text-muted);
  pointer-events: none;
  z-index: 1;
}

.app-header-bar__input {
  width: 100%;
  margin: 0;
  padding: 9px 12px 9px 36px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--mobbi-text);
  background: rgba(0, 0, 0, 0.045);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.app-header-bar__input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.app-header-bar__input:focus {
  outline: none;
  border-color: rgba(13, 110, 253, 0.45);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.app-header-bar__suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.18);
  max-height: min(320px, 55vh);
  overflow-y: auto;
  z-index: 2000;
  -webkit-overflow-scrolling: touch;
}

.app-header-bar__suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  text-decoration: none;
  color: var(--mobbi-text);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: background 0.15s ease;
}

.app-header-bar__suggest-item:last-child {
  border-bottom: none;
}

.app-header-bar__suggest-item:hover,
.app-header-bar__suggest-item:focus-visible {
  background: rgba(13, 110, 253, 0.06);
  color: var(--mobbi-brand);
}

.app-header-bar__suggest-item--active,
.app-header-bar__suggest-item--active:hover {
  background: rgba(13, 110, 253, 0.1);
  color: var(--mobbi-brand);
}

.app-header-bar__suggest-item--current .app-header-bar__suggest-text {
  font-weight: 700;
}

.app-header-bar__suggest-ico {
  font-size: 1.1rem;
  color: var(--mobbi-brand);
  flex-shrink: 0;
}

.app-header-bar__user {
  flex-shrink: 0;
  min-width: 0;
}

.app-header-bar__guest {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-header-bar__user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(120px, 28vw);
  padding: 4px 4px 4px 4px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--mobbi-text);
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.app-header-bar__user-chip:hover {
  background: rgba(13, 110, 253, 0.08);
  border-color: rgba(13, 110, 253, 0.25);
  color: var(--mobbi-text);
}

.app-header-bar__user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-header-bar__user-name {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fallback si el navegador no soporta backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .top-header,
  .search-top-bar {
    background: #fff;
  }
}

.top-header .container-fluid {
  width: 100%;
  max-width: 100%;
}

.top-header .container-fluid a,
.search-top-bar .container-fluid a,
.search-top-bar a.d-flex {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

/* Headers compactos sin container (p. ej. Mis viajes, Mensajes) */
.top-header.d-flex > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
  color: var(--mobbi-text-muted);
}

.top-header.d-flex > a:hover {
  color: var(--mobbi-brand);
  background: rgba(13, 110, 253, 0.06);
}

.top-header.d-flex > .fw-semibold {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--mobbi-text);
}

.top-header .logo,
.search-top-bar .logo {
  height: 36px;
  width: auto;
  vertical-align: middle;
}

.top-header .header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.top-header .header-action-btn {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  border: none;
  white-space: nowrap;
}

.top-header .btn-login-header {
  background: #fff;
  color: var(--mobbi-text);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.top-header .btn-login-header:hover {
  background: #f9fafb;
  color: var(--mobbi-text);
  border-color: rgba(0, 0, 0, 0.1);
}

.top-header .btn-login-header:active {
  transform: scale(0.98);
}

.top-header .btn-register-header {
  background: linear-gradient(180deg, var(--mobbi-brand) 0%, var(--mobbi-brand-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(13, 110, 253, 0.35);
}

.top-header .btn-register-header:hover {
  background: linear-gradient(180deg, #3d8bfd 0%, var(--mobbi-brand) 100%);
  color: #fff;
  filter: brightness(1.02);
}

.top-header .btn-register-header:active {
  transform: scale(0.98);
}

/* Saludo: micro-jerarquía tipo Uber / Rappi */
.top-header .user-welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
  max-width: min(200px, 46vw);
  text-align: right;
  line-height: 1.2;
}

.top-header .user-welcome .welcome-text {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mobbi-text-muted);
}

.top-header .user-welcome .user-name {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--mobbi-text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 576px) {
  .top-header,
  .search-top-bar {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: 10px;
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .top-header .logo,
  .search-top-bar .logo {
    height: 30px;
  }

  .app-header-bar__logo .logo {
    height: 28px;
  }

  .app-header-bar__inner {
    gap: 8px;
  }

  .top-header .header-action-btn {
    padding: 8px 10px;
    font-size: 0.72rem;
  }

  .top-header .user-welcome {
    max-width: min(160px, 50vw);
  }

  .top-header .user-welcome .user-name {
    font-size: 0.875rem;
  }
}

@media (max-width: 380px) {
  .app-header-bar__user-name {
    display: none;
  }

  .app-header-bar__user-chip {
    max-width: none;
    padding: 2px;
  }
}

/* Toasts (debajo del header con safe area) */
.toast-container {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 80px);
  right: max(16px, env(safe-area-inset-right));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.toast {
  min-width: 300px;
  max-width: 400px;
}

@media (max-width: 576px) {
  .toast-container {
    top: calc(env(safe-area-inset-top, 0px) + 64px);
    right: max(10px, env(safe-area-inset-right));
    left: auto;
    align-items: flex-end;
  }

  .toast {
    min-width: auto;
    max-width: calc(100vw - 20px);
  }
}

/* Footer fijo tipo app */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 10px 0;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.footer-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: var(--mobbi-footer-max);
  margin: 0 auto;
}

.footer-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--mobbi-gray-500);
  font-size: 0.75rem;
  transition: color 0.3s;
}

.footer-item:hover {
  color: var(--mobbi-brand);
}

.footer-item i {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.footer-item.active {
  color: var(--mobbi-brand);
}

/* Columna de contenido centrada (márgenes laterales alineados) */
.mobbi-page,
.trips-container,
.profile-container,
.form-page,
.detail-page,
.page {
  max-width: var(--mobbi-content-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 15px;
  padding-right: 15px;
  box-sizing: border-box;
}

/* Hilo de mensajes: columna centrada (más reglas en messages_thread.html) */
.chat-wrap {
  max-width: var(--mobbi-content-max);
  margin-left: auto;
  margin-right: auto;
}
