/* =============================================================================
   Captive Portal — Splash styling
   Light, premium, mobile-first. Brand colors are injected as CSS variables by
   PHP (see the :root block printed in public/index.php).
   ========================================================================== */

:root {
    --brand:        #2563eb;
    --brand-dark:   #1d4ed8;
    --ink:          #0f172a;
    --muted:        #64748b;
    --line:         #e2e8f0;
    --card:         #ffffff;
    --bg:           #f1f5f9;
    --success:      #16a34a;
    --danger:       #dc2626;
    --radius:       20px;
    --shadow:       0 10px 40px rgba(15, 23, 42, .12);
    --shadow-sm:    0 2px 8px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
                 Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    color: var(--ink);
    background-color: var(--bg);
    background-image:
        linear-gradient(160deg, rgba(37, 99, 235, .10), rgba(15, 23, 42, .06)),
        var(--portal-bg, none);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---- Layout --------------------------------------------------------------- */
.portal-wrap {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.portal-card {
    width: 100%;
    max-width: 460px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: rise .5s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(18px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Header --------------------------------------------------------------- */
.portal-header {
    text-align: center;
    padding: 32px 28px 12px;
}

.portal-logo {
    height: 54px;
    width: auto;
    margin-bottom: 14px;
}

.portal-wifi {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--brand);
    background: rgba(37, 99, 235, .10);
    padding: 6px 14px;
    border-radius: 999px;
    margin-bottom: 14px;
}

.portal-wifi svg { width: 16px; height: 16px; }

.portal-title {
    font-size: 22px;
    font-weight: 700;
    margin: 6px 0 6px;
    letter-spacing: -.01em;
}

.portal-sub {
    font-size: 14.5px;
    color: var(--muted);
    margin: 0 auto;
    max-width: 340px;
    line-height: 1.5;
}

/* ---- Form ----------------------------------------------------------------- */
.portal-body { padding: 8px 28px 28px; }

.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #334155;
}

.field .req { color: var(--danger); }

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"] {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--ink);
    background: #f8fafc;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    transition: border-color .15s, box-shadow .15s, background .15s;
    outline: none;
}

.field input:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.field input.is-invalid { border-color: var(--danger); background: #fef2f2; }

.field .err {
    display: none;
    font-size: 12.5px;
    color: var(--danger);
    margin-top: 5px;
}
.field .err.show { display: block; }

/* ---- Consent checkboxes --------------------------------------------------- */
.consents { margin: 6px 0 18px; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    color: #334155;
    margin-bottom: 10px;
    line-height: 1.45;
}

.check input {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--brand);
    flex: 0 0 auto;
    cursor: pointer;
}

.check a { color: var(--brand); font-weight: 600; text-decoration: none; }
.check a:hover { text-decoration: underline; }

/* ---- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    font-size: 15.5px;
    font-weight: 700;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform .08s, box-shadow .15s, background .15s, opacity .15s;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    box-shadow: 0 8px 20px rgba(37, 99, 235, .30);
}
.btn-primary:hover  { box-shadow: 0 10px 26px rgba(37, 99, 235, .40); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .65; cursor: not-allowed; box-shadow: none; }

.btn .spinner {
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: none;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-label { opacity: .8; }

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

.btn-links {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
.btn-ghost {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--brand);
    background: transparent;
    border: 1.5px solid var(--line);
    padding: 10px;
    border-radius: 12px;
    text-align: center;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: #f8fafc; border-color: var(--brand); }

/* ---- Alerts --------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
}
.alert-danger  { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }
.alert-success { color: #14532d; background: #f0fdf4; border: 1px solid #bbf7d0; }
.alert svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }

/* ---- Connection status ---------------------------------------------------- */
.status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
    padding: 0 28px 20px;
}
.status .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--muted);
}
.status.online  .dot { background: var(--success); box-shadow: 0 0 0 4px rgba(22,163,74,.15); }
.status.working .dot { background: #f59e0b; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---- Footer --------------------------------------------------------------- */
.portal-footer {
    flex-shrink: 0;
    text-align: center;
    font-size: 12.5px;
    color: #94a3b8;
    padding: 18px 16px 28px;
}
.portal-footer a { color: #64748b; text-decoration: none; }
.portal-footer a:hover { text-decoration: underline; }

/* ---- Success screen ------------------------------------------------------- */
.success-icon {
    width: 72px; height: 72px;
    margin: 4px auto 8px;
    display: block;
}
.success-icon circle { stroke-dasharray: 166; stroke-dashoffset: 166;
    animation: stroke .6s cubic-bezier(.65,0,.45,1) forwards; }
.success-icon path { stroke-dasharray: 48; stroke-dashoffset: 48;
    animation: stroke .3s .5s cubic-bezier(.65,0,.45,1) forwards; }
@keyframes stroke { to { stroke-dashoffset: 0; } }

/* ---- Legal pages ---------------------------------------------------------- */
.legal-wrap {
    max-width: 780px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}
.legal-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 36px 40px;
}
.legal-card h1 { font-size: 26px; margin-top: 0; }
.legal-card h2 { font-size: 18px; margin-top: 28px; }
.legal-card p, .legal-card li { color: #334155; line-height: 1.65; font-size: 15px; }
.legal-back {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--brand); font-weight: 600; text-decoration: none;
    margin-bottom: 18px; font-size: 14px;
}
.legal-back:hover { text-decoration: underline; }

/* ---- Responsive tweaks ---------------------------------------------------- */
@media (max-width: 420px) {
    .field-row { flex-direction: column; gap: 0; }
    .portal-header { padding: 26px 20px 8px; }
    .portal-body   { padding: 6px 20px 22px; }
    .legal-card    { padding: 26px 22px; }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
