/* ================================================================
   PaintLab AI — Estilos PWA
   Banner de conexão, status pill, update banner, install prompt
================================================================ */

/* ── Barra de conexão (online/offline) ──────────────────────── */
.pwa-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9990;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Inter', system-ui, sans-serif;
}

.pwa-bar-visible { transform: translateY(0); }
.pwa-bar-hidden  { transform: translateY(100%); pointer-events: none; }

.pwa-bar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}

/* Offline */
.pwa-bar-offline .pwa-bar-inner {
  background: linear-gradient(135deg, #7f1d1d, #991b1b);
  border-top: 2px solid #ef4444;
  color: #fef2f2;
  box-shadow: 0 -4px 24px rgba(220,38,38,0.4);
}

/* Sincronizando */
.pwa-bar-syncing .pwa-bar-inner {
  background: linear-gradient(135deg, #0a2554, #144196);
  border-top: 2px solid #4d7fd4;
  color: #eaf0fb;
  box-shadow: 0 -4px 24px rgba(20,65,150,0.4);
}

/* Dots de status */
.pwa-bar-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-offline {
  background: #fca5a5;
  box-shadow: 0 0 8px #f87171;
}

.dot-syncing {
  background: #93c5fd;
  box-shadow: 0 0 8px #4d7fd4;
  animation: dotSpin 1s linear infinite;
}

.dot-online {
  background: #4ade80;
  box-shadow: 0 0 8px #22c55e;
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotSpin   { to { transform: rotate(360deg); } }
@keyframes dotPulse  { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(.8)} }

.pwa-bar-msg { flex: 1; }
.pwa-bar-ts  { font-size: 11px; opacity: 0.7; white-space: nowrap; }

.pwa-bar-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.15s;
}
.pwa-bar-btn:hover { background: rgba(255,255,255,0.25); }

.pwa-bar-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
  transition: color 0.15s;
}
.pwa-bar-close:hover { color: white; }

/* ── Status Pill (sempre visível no canto) ──────────────────── */
.pwa-status-pill {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9980;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(15,23,42,0.85);
  border: 1px solid rgba(77,127,212,0.25);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'Inter', system-ui, sans-serif;
  color: #94a3b8;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
  pointer-events: none;
}

.pwa-status-pill:hover { pointer-events: auto; }

.pwa-pill-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pwa-pill-label { color: #cbd5e1; }
.pwa-pill-ts    { font-size: 10px; opacity: 0.6; font-weight: 400; }

/* Botão de instalação */
.pwa-install-btn {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: linear-gradient(135deg, #144196, #0a2554);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Inter', system-ui, sans-serif;
  cursor: pointer;
  transition: opacity 0.15s;
  pointer-events: auto;
  margin-left: 6px;
}
.pwa-install-btn:hover { opacity: 0.85; }

/* ── Banner de atualização disponível ───────────────────────── */
.pwa-update-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  animation: slideDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

.pwa-update-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #0a2554, #144196);
  border-bottom: 2px solid #4d7fd4;
  color: #eaf0fb;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', system-ui, sans-serif;
  box-shadow: 0 4px 20px rgba(20,65,150,0.4);
}

.pwa-update-inner i { color: #a8c4ea; font-size: 16px; }

.pwa-update-btn {
  margin-left: auto;
  padding: 7px 16px;
  background: linear-gradient(135deg, #144196, #c9a400);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.pwa-update-btn:hover { opacity: 0.85; }

.pwa-update-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  transition: color 0.15s;
}
.pwa-update-dismiss:hover { color: white; }

/* ── Indicador de conexão no topbar ────────────────────────── */
#pwa-topbar-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  transition: all 0.3s;
}

#pwa-topbar-indicator.online {
  background: rgba(22,163,74,0.1);
  border-color: rgba(22,163,74,0.25);
  color: #16a34a;
}

#pwa-topbar-indicator.offline {
  background: rgba(220,38,38,0.1);
  border-color: rgba(220,38,38,0.25);
  color: #dc2626;
  animation: offlinePulse 1.5s ease-in-out infinite;
}

@keyframes offlinePulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* ── Tela de splash de carregamento ────────────────────────── */
#pwa-splash {
  position: fixed;
  inset: 0;
  background: #071530;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  transition: opacity 0.5s ease, visibility 0.5s;
}

#pwa-splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pwa-splash-logo {
  width: min(78vw, 340px);
  height: auto;
  border-radius: 16px;
  box-shadow: 0 0 60px rgba(20,65,150,0.6), 0 0 120px rgba(201,164,0,0.25);
  animation: splashPulse 2s ease-in-out infinite;
}

@keyframes splashPulse {
  0%,100% { box-shadow: 0 0 40px rgba(20,65,150,0.5), 0 0 80px rgba(201,164,0,0.15); }
  50%      { box-shadow: 0 0 80px rgba(20,65,150,0.8), 0 0 160px rgba(201,164,0,0.35); }
}

.pwa-splash-name {
  font-family: 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 900;
  background: linear-gradient(135deg, #4d7fd4, #144196, #fff000);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.pwa-splash-sub {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #475569;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.pwa-splash-bar {
  width: 200px; height: 3px;
  background: rgba(77,127,212,0.15);
  border-radius: 3px;
  overflow: hidden;
}

.pwa-splash-progress {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #144196, #4d7fd4, #fff000);
  background-size: 200% 100%;
  animation: splashLoad 1.8s ease-in-out forwards, gradientShift 1.5s linear infinite;
}

@keyframes splashLoad {
  from { width: 0%; }
  to   { width: 100%; }
}

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

/* ── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .pwa-status-pill {
    bottom: 8px; right: 8px;
    font-size: 10.5px;
    padding: 5px 10px;
  }
  .pwa-bar-inner { padding: 10px 14px; font-size: 12px; }
  .pwa-bar-ts    { display: none; }
  .pwa-update-inner { flex-wrap: wrap; gap: 8px; }
}

/* ── Modo instalado standalone (sem barra do browser) ──────── */
@media (display-mode: standalone) {
  .pwa-status-pill { bottom: env(safe-area-inset-bottom, 16px); right: env(safe-area-inset-right, 16px); }
  .pwa-bar         { padding-bottom: env(safe-area-inset-bottom, 0px); }
}
