/* ============================================================
   DomainVault — pwa.css  v4.0
   PWA · Push Notifications · Bottom Nav mobile
   Depende de app.css para los tokens CSS
   ============================================================ */

/* ── Install banner ─────────────────────────────────────────── */
.pwa-install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(13, 18, 32, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 500;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.4);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pwa-install-banner.visible { transform: translateY(0); }

[data-theme="light"] .pwa-install-banner {
  background: rgba(248, 250, 252, 0.94);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
}

.pwa-banner-icon {
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--accent), var(--green));
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(59,130,246,0.25);
}
.pwa-banner-text { flex: 1; min-width: 0; }
.pwa-banner-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.9rem;
}
.pwa-banner-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.pwa-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pwa-banner-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 4px;
  transition: background 0.12s;
}
.pwa-banner-close:hover { background: var(--bg3); color: var(--text); }

/* ── Push permission prompt ─────────────────────────────────── */
.push-prompt {
  background: linear-gradient(135deg, rgba(59,130,246,0.08) 0%, var(--card) 60%);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  animation: fade-up 0.3s ease;
}
.push-prompt-icon { font-size: 2rem; flex-shrink: 0; }
.push-prompt-text { flex: 1; }
.push-prompt-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.push-prompt-sub { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.push-prompt-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Push status indicators ─────────────────────────────────── */
.push-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.push-status-on {
  background: var(--green-dim);
  color: var(--green);
  border-color: rgba(34,197,94,0.20);
}
.push-status-off {
  background: rgba(107,114,128,0.08);
  color: var(--muted);
  border-color: var(--border);
}
.push-status-blocked {
  background: rgba(239,68,68,0.08);
  color: var(--danger);
  border-color: rgba(239,68,68,0.20);
}
.push-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.push-status-on .push-status-dot {
  animation: pulse-dot 2s ease-in-out infinite;
  box-shadow: 0 0 5px currentColor;
}

/* ── Device list ────────────────────────────────────────────── */
.device-list { display: flex; flex-direction: column; gap: 5px; }

.device-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
  animation: fade-up 0.2s ease both;
}
.device-item:hover { border-color: var(--border-hover); }

.device-icon { font-size: 1.1rem; flex-shrink: 0; }
.device-info { flex: 1; min-width: 0; }
.device-name { font-size: 0.85rem; font-weight: 550; }
.device-meta { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }
.device-remove {
  background: none; border: none;
  color: var(--subtle); cursor: pointer;
  font-size: 0.78rem; padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.12s;
  font-family: var(--font);
}
.device-remove:hover {
  background: rgba(239,68,68,0.08);
  color: var(--danger);
}

/* ── Notification history ───────────────────────────────────── */
.notif-history { display: flex; flex-direction: column; gap: 4px; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 13px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  transition: border-color 0.12s;
  animation: fade-up 0.2s ease both;
}
.notif-item:hover { border-color: var(--border-hover); }
.notif-item.unread { border-left: 2px solid var(--accent); }

.notif-icon   { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.notif-body-wrap { flex: 1; min-width: 0; }
.notif-title  { font-weight: 600; font-size: 0.83rem; }
.notif-body   { color: var(--muted); margin-top: 2px; font-size: 0.78rem; line-height: 1.4; }
.notif-time   { color: var(--subtle); font-size: 0.68rem; margin-left: auto; white-space: nowrap; flex-shrink: 0; }

/* ── SW update toast ────────────────────────────────────────── */
.sw-update-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  z-index: 600;
  white-space: nowrap;
  font-size: 0.875rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  backdrop-filter: blur(12px);
}
.sw-update-toast.visible {
  opacity: 1;
  pointer-events: all;
}

/* ── Mobile bottom nav (PWA installed mode) ─────────────────── */
@media (max-width: 768px) {
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(13, 18, 32, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 300;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px;
    color: var(--subtle);
    text-decoration: none;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: color 0.15s;
    position: relative;
  }
  .mobile-nav-item svg { width: 20px; height: 20px; }
  .mobile-nav-item.active { color: var(--accent-light); }
  .mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 0 0 2px 2px;
  }
  .mobile-nav-item:hover { color: var(--text); text-decoration: none; }

  /* Badge en nav items móvil */
  .mobile-nav-badge {
    position: absolute;
    top: 6px; right: calc(50% - 18px);
    background: var(--danger);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 1.5px solid var(--bg);
  }

  /* Padding para que el contenido no quede bajo el nav */
  .has-mobile-nav .content {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0));
  }
}

[data-theme="light"] .mobile-bottom-nav {
  background: rgba(248, 250, 252, 0.96);
}

/* ── Responsive fixes ───────────────────────────────────────── */
@media (max-width: 600px) {
  .push-prompt {
    flex-direction: column;
    text-align: center;
  }
  .push-prompt-actions {
    flex-direction: column;
    width: 100%;
  }
  .push-prompt-actions .btn { width: 100%; justify-content: center; }
  .pwa-install-banner { padding: 12px 16px; }
}
