/* ============================================================
   Hotspot Captive Portal — Estilos compartilhados
   Mobile-first • Cor primária padrão #1565C0 (sobrescrita por instância via portal.js)
   ============================================================ */

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

:root {
  /* Marca */
  --brand:        #1565C0;
  --brand-dark:   #0D47A1;
  --brand-xdark:  #082A6B;
  --brand-light:  #E3F2FD;
  --brand-mid:    #1976D2;

  /* Semânticas */
  --ok:           #2E7D32;
  --ok-bg:        #E8F5E9;
  --ok-border:    #A5D6A7;
  --err:          #C62828;
  --err-bg:       #FFEBEE;
  --err-border:   #EF9A9A;
  --info:         #01579B;
  --info-bg:      #E1F5FE;
  --info-border:  #81D4FA;
  --warn:         #E65100;

  /* UI */
  --text:         #1C1C2E;
  --text-mid:     #4A4A6A;
  --text-muted:   #6B7280;
  --border:       #D1D5DB;
  --border-focus: var(--brand);
  --bg:           #F0F4F8;
  --card:         #FFFFFF;
  --input-bg:     #FFFFFF;
  --radius:       14px;
  --radius-sm:    8px;
  --radius-xs:    6px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 8px 28px rgba(0,0,0,.08);
  --shadow-sm:    0 1px 3px rgba(0,0,0,.10);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Mono', 'Consolas', monospace;
}

/* ── Base ──────────────────────────────────────────────── */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Layout ────────────────────────────────────────────── */
.page {
  width: 100%;
  max-width: 480px;
  padding: 0 0 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* ── Header ────────────────────────────────────────────── */
.portal-header {
  width: 100%;
  background: linear-gradient(135deg, var(--brand-xdark) 0%, var(--brand) 100%);
  color: #fff;
  padding: 28px 24px 24px;
  text-align: center;
  margin-bottom: 24px;
}

[hidden] { display: none !important; }

/* Logo do órgão (branding/logo-orgao.*); o ícone Wi-Fi é o fallback */
.portal-header .brand-logo {
  display: block;
  max-height: 72px;
  max-width: min(240px, 80%);
  margin: 0 auto 12px;
  object-fit: contain;
}

.portal-header .wifi-icon {
  display: inline-block;
  margin-bottom: 10px;
  opacity: .92;
}

.portal-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.portal-header p {
  font-size: .875rem;
  opacity: .85;
  margin-top: 5px;
}

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  width: calc(100% - 32px);
  max-width: 440px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.4;
}

/* ── Formulário ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: .83rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

label .req { color: var(--err); margin-left: 2px; font-weight: 700; }

.input-wrap { position: relative; }

input[type="text"],
input[type="tel"],
input[type="email"] {
  width: 100%;
  padding: 11px 14px;
  font-size: .97rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(21,101,192,.14);
}

input.input--valid   { border-color: var(--ok);  }
input.input--invalid { border-color: var(--err); }
input.input--info    { border-color: var(--info); }

input::placeholder { color: #B0B7C3; }

/* ── CPF status indicator ──────────────────────────────── */
.cpf-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  margin-top: 5px;
  font-size: .78rem;
  font-weight: 500;
  transition: opacity .2s;
}

.cpf-status:empty { display: none; }

.cpf-status.st-loading { color: var(--text-muted); }
.cpf-status.st-valid   { color: var(--ok); }
.cpf-status.st-invalid { color: var(--err); }
.cpf-status.st-info    { color: var(--info); }

.cpf-status svg { flex-shrink: 0; }

/* ── Spinner inline ────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(100,116,139,.25);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

.spinner--white {
  border-color: rgba(255,255,255,.3);
  border-top-color: #fff;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── LGPD Accordion ────────────────────────────────────── */
.lgpd-section {
  background: #FAFBFF;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  overflow: hidden;
}

.lgpd-accordion {
  width: 100%;
}

.lgpd-accordion summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 13px 16px;
  font-size: .86rem;
  font-weight: 600;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background .15s;
}

.lgpd-accordion summary::-webkit-details-marker { display: none; }
.lgpd-accordion summary::marker { display: none; }

.lgpd-accordion summary:hover { background: var(--brand-light); }

.lgpd-chevron {
  transition: transform .2s;
  flex-shrink: 0;
}

.lgpd-accordion[open] summary { border-bottom: 1px solid var(--border); }
.lgpd-accordion[open] .lgpd-chevron { transform: rotate(180deg); }

.lgpd-body {
  padding: 14px 16px;
  font-size: .82rem;
  color: var(--text-mid);
  line-height: 1.6;
}

.lgpd-body ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.lgpd-body ul li {
  padding-left: 18px;
  position: relative;
}

.lgpd-body ul li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--brand);
  font-weight: 700;
}

.lgpd-body strong { color: var(--text); }

/* ── Checkbox de consentimento ────────────────────────── */
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}

.consent-row:hover { background: var(--brand-light); }

.consent-row input[type="checkbox"] {
  width: 17px; height: 17px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.consent-row label {
  font-size: .84rem;
  font-weight: 500;
  color: var(--text-mid);
  margin-bottom: 0;
  cursor: pointer;
  line-height: 1.4;
}

/* ── Botões ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  font-size: 1rem;
  font-family: var(--font);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
  text-decoration: none;
  letter-spacing: .01em;
  -webkit-appearance: none;
}

.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn-primary:disabled {
  background: #9DB8D9;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--brand-light);
  color: var(--brand);
}

.btn-secondary:hover { background: #BBDEFB; }

.btn-outline {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}

.btn-outline:hover { background: var(--brand-light); }

.btn-sm {
  padding: 9px 16px;
  font-size: .88rem;
}

/* ── Alertas ───────────────────────────────────────────── */
.alert {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: .86rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 16px;
}

.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-border); }
.alert-err  { background: var(--err-bg);  color: var(--err);  border: 1px solid var(--err-border); }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }

/* ── Tela de sucesso ───────────────────────────────────── */
.success-screen {
  text-align: center;
  padding: 8px 0 4px;
}

.success-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--ok), #43A047);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px rgba(46,125,50,.3);
  animation: popIn .4s cubic-bezier(.175,.885,.32,1.275) both;
}

@keyframes popIn {
  from { transform: scale(.5); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.success-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ok);
  margin-bottom: 6px;
}

.success-subtitle {
  font-size: .92rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ── Countdown ─────────────────────────────────────────── */
.countdown-wrap {
  background: linear-gradient(135deg, var(--brand-xdark) 0%, var(--brand) 100%);
  border-radius: var(--radius-sm);
  padding: 18px 16px;
  color: #fff;
  margin-bottom: 20px;
  text-align: center;
}

.countdown-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .75;
  margin-bottom: 6px;
}

.countdown-time {
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  font-family: var(--font-mono);
}

.countdown-time.expired { color: #FFCDD2; font-size: 1.1rem; }

/* ── Footer ────────────────────────────────────────────── */
.portal-footer {
  margin-top: 20px;
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
  padding: 0 16px;
  line-height: 1.6;
}

.portal-footer a { color: var(--brand); text-decoration: none; }

.portal-footer .portal-operator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.portal-footer .operator-logo {
  height: 18px;
  width: auto;
}

/* ── Divider ───────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .78rem;
  color: var(--text-muted);
  margin: 18px 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Link texto ────────────────────────────────────────── */
.link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}

.link:hover { text-decoration: underline; }

.text-center { text-align: center; }
.text-sm     { font-size: .84rem; }
.text-muted  { color: var(--text-muted); }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.hidden      { display: none !important; }

/* ── Tela de erro ──────────────────────────────────────── */
.error-screen { text-align: center; padding: 8px 0 4px; }

.error-icon {
  width: 64px; height: 64px;
  background: var(--err-bg);
  border: 2px solid var(--err-border);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--err);
}

.error-title { font-size: 1.2rem; font-weight: 700; color: var(--err); margin-bottom: 6px; }
.error-msg   { font-size: .9rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 20px; }

/* ── Responsivo ────────────────────────────────────────── */
@media (min-width: 480px) {
  .portal-header {
    border-radius: var(--radius) var(--radius) 0 0;
    margin-bottom: 0;
  }

  .page {
    padding-top: 40px;
    padding-bottom: 64px;
  }

  .page > .card { border-radius: 0 0 var(--radius) var(--radius); }

  body { justify-content: flex-start; }
}
