
/* ============================================================
   ZONA WIFI — GOBERNACIÓN DE NARIÑO
   Hoja de estilos del portal cautivo (solo presentación)
   ============================================================ */

:root {
    --gn-verde:        #0B6B36;
    --gn-verde-oscuro: #07512A;
    --gn-verde-claro:  #E7F3EC;
    --gn-verde-suave:  #F4F9F6;
    --gn-ambar:        #E8A020;
    --gn-texto:        #122B1D;
    --gn-texto-2:      #4E6B5B;
    --gn-texto-3:      #8A9A90;
    --gn-borde:        #DCE5DF;
    --gn-radio:        24px;
    --gn-sombra:       0 24px 60px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.12);
}

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

html, body {
    width: 100%;
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

input, button, select, textarea { touch-action: manipulation; }

body {
    font-family: 'Hind Madurai', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    background-color: var(--gn-verde);
    background-image:
        radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
        radial-gradient(ellipse at 15% 0%, rgba(255, 255, 255, 0.10), transparent 55%),
        radial-gradient(ellipse at 90% 100%, rgba(0, 0, 0, 0.22), transparent 55%);
    background-size: 18px 18px, 100% 100%, 100% 100%;
    color: var(--gn-texto);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   LAYOUT GENERAL
   ============================================ */
#portal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
    justify-content: center;
    width: 100%;
    max-width: 1150px;
    margin: 0 auto;
    min-width: 0;
}

#portal-layout > * { min-width: 0; }

/* ============================================
   FORMULARIO — TARJETA PROTAGONISTA
   ============================================ */
.tarjeta {
    position: relative;
    background: #fff;
    border-radius: var(--gn-radio);
    padding: clamp(20px, 3.2vh, 34px) clamp(20px, 2.4vw, 32px) clamp(16px, 2.6vh, 28px);
    box-shadow: var(--gn-sombra);
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

/* Franja superior de acento institucional */
.tarjeta::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--gn-ambar) 0%, var(--gn-ambar) 30%, var(--gn-verde) 30%);
}

.portal-logo {
    width: clamp(120px, 15vh, 165px);
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto clamp(10px, 1.6vh, 16px);
}

.wifi-icon {
    width: clamp(44px, 6vh, 56px);
    height: clamp(44px, 6vh, 56px);
    margin: 0 auto clamp(8px, 1.2vh, 12px);
    border-radius: 50%;
    background: var(--gn-verde);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(11, 107, 54, 0.35);
}

.wifi-icon svg {
    width: 55%;
    height: 55%;
    stroke: #fff !important;
}

.tarjeta h1 {
    font-size: clamp(1.4rem, 2.8vh, 1.75rem);
    color: var(--gn-texto);
    margin: 0 0 2px;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.2px;
}

.portal-subtitle {
    text-align: center;
    color: var(--gn-texto-2);
    font-size: 0.92rem;
    margin-bottom: clamp(10px, 1.6vh, 16px);
    font-weight: 500;
}

/* Mensaje de bienvenida (generado por CSS, sin tocar el HTML) */
.tarjeta form::before {
    content: "Bienvenido a la Zona WiFi de la Gobernación de Nariño. Regístrate para acceder a la red y disfrutar de una conexión gratuita.";
    grid-column: 1 / -1;
    text-align: center;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--gn-texto-2);
    background: var(--gn-verde-suave);
    border-left: 3px solid var(--gn-verde);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: clamp(12px, 2vh, 18px);
}

/* --- Formulario en rejilla: Nombre y Apellido lado a lado --- */
.tarjeta form {
    margin-top: clamp(2px, 0.6vh, 6px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 0;
}

.tarjeta form > * { grid-column: 1 / -1; min-width: 0; }

.tarjeta label[for="nombre"]   { grid-column: 1; grid-row: 1; }
.tarjeta input#nombre          { grid-column: 1; grid-row: 2; }
.tarjeta label[for="apellido"] { grid-column: 2; grid-row: 1; }
.tarjeta input#apellido        { grid-column: 2; grid-row: 2; }

.tarjeta label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gn-texto-2);
    margin-bottom: clamp(4px, 0.6vh, 6px);
    letter-spacing: 0.2px;
}

.tarjeta input[type="text"],
.tarjeta input[type="tel"],
.tarjeta input[type="email"] {
    width: 100%;
    height: clamp(42px, 5.4vh, 48px);
    padding: 0 14px 0 42px;
    border: 1.5px solid var(--gn-borde);
    border-radius: 12px;
    font-size: 0.95rem;
    background-color: var(--gn-verde-suave);
    background-repeat: no-repeat;
    background-position: 14px center;
    background-size: 18px 18px;
    margin-bottom: clamp(10px, 1.5vh, 14px);
    font-family: inherit;
    color: var(--gn-texto);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.tarjeta input::placeholder { color: #9AA8A0; }

/* Iconos dentro de los campos (sin tocar el HTML) */
.tarjeta input[type="text"] {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B6B36' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='8' r='4'/><path d='M4 21a8 8 0 0 1 16 0'/></svg>");
}
.tarjeta input[type="tel"] {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B6B36' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='6' y='3' width='12' height='18' rx='2'/><path d='M11 18h2'/></svg>");
}
.tarjeta input[type="email"] {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B6B36' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='14' rx='2'/><path d='M3 7l9 6 9-6'/></svg>");
}

.tarjeta input[type="text"]:focus,
.tarjeta input[type="tel"]:focus,
.tarjeta input[type="email"]:focus {
    border-color: var(--gn-verde);
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(11, 107, 54, 0.14);
}

.tarjeta input:invalid:not(:placeholder-shown) {
    border-color: var(--gn-ambar);
}

.required-note {
    font-size: 0.74rem;
    color: var(--gn-texto-3);
    font-weight: 500;
    margin: 0 0 clamp(6px, 1vh, 10px);
}

.terms-box {
    margin: 0 0 clamp(10px, 1.6vh, 16px);
    padding: clamp(8px, 1.2vh, 12px) 12px;
    background: var(--gn-verde-suave);
    border-radius: 12px;
}

.terms-box label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: clamp(6px, 1vh, 8px);
    font-size: 0.8rem;
    color: var(--gn-texto-2);
    line-height: 1.4;
    cursor: pointer;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.terms-box label:last-child { margin-bottom: 0; }

.terms-box input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    accent-color: var(--gn-verde);
    margin-top: 1px;
    cursor: pointer;
}

.terms-box a {
    color: var(--gn-verde);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.tarjeta button[type="submit"] {
    width: 100%;
    height: clamp(46px, 6vh, 52px);
    background: var(--gn-verde);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(11, 107, 54, 0.35);
    font-family: inherit;
    text-transform: none;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.tarjeta button[type="submit"]::after {
    content: "";
    width: 18px;
    height: 18px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12h14M13 6l6 6-6 6'/></svg>") center/contain no-repeat;
    transition: transform 0.2s;
}

.tarjeta button[type="submit"]:hover {
    background: var(--gn-verde-oscuro);
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(11, 107, 54, 0.42);
}
.tarjeta button[type="submit"]:hover::after { transform: translateX(3px); }
.tarjeta button[type="submit"]:active { transform: translateY(0); }

/* Línea de confianza bajo el botón */
.tarjeta form::after {
    content: "Conexión segura · Red institucional";
    grid-column: 1 / -1;
    text-align: center;
    font-size: 0.72rem;
    color: var(--gn-texto-3);
    margin-top: clamp(8px, 1.4vh, 14px);
    padding-left: 20px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A9A90' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z'/><path d='M9 12l2 2 4-4'/></svg>") calc(50% - 92px) center / 14px 14px no-repeat;
}

/* ============================================
   NOTICIAS (IFRAME)
   ============================================ */
#portal-news-wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    border-radius: 0;
    overflow: visible;
    background: transparent;
}

#portal-news-wrap iframe {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    min-height: 0;
}

/* ============================================
   DESKTOP — todo dentro del viewport
   ============================================ */
@media (min-width: 769px) {
    body {
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        padding: clamp(16px, 2.4vh, 28px) clamp(16px, 2.4vw, 32px);
    }

    #portal-layout {
        /* Orden visual: Noticias a la izquierda, Formulario a la derecha.
           El DOM no cambia (formulario sigue primero para foco y lectores). */
        grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
        /* La fila toma la altura natural del formulario y las noticias
           se estiran a esa misma altura. Solo se limita al viewport
           cuando la pantalla es más baja que el formulario. */
        grid-template-rows: minmax(0, auto);
        align-items: stretch;
        gap: clamp(20px, 2.4vw, 32px);
        height: auto;
        max-height: 100%;
        max-width: 1240px;
    }

    #portal-news-wrap {
        grid-column: 1;
        grid-row: 1;
        height: auto;
        max-height: 100%;
        align-self: stretch;
    }

    .tarjeta {
        grid-column: 2;
        grid-row: 1;
        height: auto;
        max-height: 100%;
        min-height: 0;
        overflow-y: auto;
    }
}

/* ============================================
   MÓVIL — 1 columna, scroll natural
   ============================================ */
@media (max-width: 768px) {
    body {
        padding: 16px;
        align-items: flex-start;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    #portal-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto;
        gap: 20px;
        height: auto;
        max-height: none;
    }

    /* Orden visual en móvil: Noticias primero, Formulario después */
    #portal-news-wrap { order: -1; }
    .tarjeta { order: 0; }

    .tarjeta {
        padding: 28px 20px 22px;
        height: auto;
        max-height: none;
        overflow: hidden;
    }

    .portal-logo { width: 140px; }

    /* Nombre y Apellido vuelven a apilarse */
    .tarjeta form { grid-template-columns: minmax(0, 1fr); }
    .tarjeta label[for="nombre"],
    .tarjeta input#nombre,
    .tarjeta label[for="apellido"],
    .tarjeta input#apellido { grid-column: 1; grid-row: auto; }

    /* 16px mínimo: iOS hace zoom automático al enfocar campos más pequeños */
    .tarjeta input[type="text"],
    .tarjeta input[type="tel"],
    .tarjeta input[type="email"] {
        height: 48px;
        font-size: 16px;
        margin-bottom: 14px;
    }

    .tarjeta button[type="submit"] { height: 52px; font-size: 16px; }

    #portal-news-wrap {
        /* noticias.php en móvil: destacada (~350px) + 4 secundarias de 124px
           + cabecera y separaciones. Alturas conocidas → sin scroll interno. */
        height: 990px;
    }
}