/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --sand:      #f5e6c8;
    --sand-dark: #e8c98a;
    --sea:       #0a7ea4;
    --sea-dark:  #065f7e;
    --sky:       #87ceeb;
    --white:     #ffffff;
    --text:      #1a2b3c;
    --text-muted:#6b7a8d;
    --error-bg:  #fff0f0;
    --error-border:#e53e3e;
    --error-text:#c53030;
    --radius:    14px;
    --shadow:    0 8px 40px rgba(10, 126, 164, 0.18);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    color: var(--text);
}

/* ── Background & waves ───────────────────────────────────────────────────── */
.portal-wrapper {
    min-height: 100vh;
    background: linear-gradient(180deg, #87ceeb 0%, #c8e8f8 35%, #e8f5e9 60%, var(--sand) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px 100px;
    position: relative;
    overflow: hidden;
}

.waves {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 0;
}

.wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 80px;
    background: var(--sea);
    border-radius: 50% 50% 0 0 / 30px 30px 0 0;
    opacity: 0.25;
    animation: wave-move 6s linear infinite;
}

.wave2 {
    background: var(--sea-dark);
    opacity: 0.18;
    animation-duration: 9s;
    animation-direction: reverse;
    height: 60px;
}

.wave3 {
    opacity: 0.12;
    animation-duration: 12s;
    height: 50px;
}

@keyframes wave-move {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.portal-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px 28px 40px;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

/* ── Logo ─────────────────────────────────────────────────────────────────── */
.logo-wrap {
    text-align: center;
    margin-bottom: 24px;
}

.logo {
    width: 160px;
    height: 160px;
    object-fit: contain;
}

/* ── Titolo ───────────────────────────────────────────────────────────────── */
.portal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--sea-dark);
    text-align: center;
    margin-bottom: 6px;
}

.portal-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
    line-height: 1.5;
}

/* ── Form ─────────────────────────────────────────────────────────────────── */
.portal-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.field-group input[type="text"],
.field-group input[type="email"],
.field-group input[type="tel"] {
    border: 1.5px solid #d0dbe7;
    border-radius: 10px;
    padding: 13px 16px;
    font-size: 1rem;
    color: var(--text);
    background: #f8fbfd;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.field-group input::placeholder {
    color: #aab8c4;
}

.field-group input:focus {
    outline: none;
    border-color: var(--sea);
    box-shadow: 0 0 0 3px rgba(10, 126, 164, 0.12);
    background: var(--white);
}

.field-group input.input-error,
.field-group input.input-error:focus {
    border-color: var(--error-border) !important;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.15) !important;
    background: #fff8f8;
}

.field-error {
    display: none;
    font-size: 0.8rem;
    color: var(--error-text);
    margin-top: -2px;
}

/* ── Toast notification ───────────────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: #c53030;
    color: #fff;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    max-width: calc(100vw - 32px);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

.toast.toast-show {
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-close {
    margin-left: auto;
    font-size: 1.1rem;
    opacity: 0.75;
    flex-shrink: 0;
}

/* ── Checkbox privacy ─────────────────────────────────────────────────────── */
.checkbox-group {
    flex-direction: row;
    align-items: flex-start;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkmark {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 2px solid #d0dbe7;
    border-radius: 6px;
    background: #f8fbfd;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    margin-top: 1px;
}

.checkbox-label input:checked + .checkmark {
    background: var(--sea);
    border-color: var(--sea);
}

.checkbox-label input:checked + .checkmark::after {
    content: '';
    display: block;
    width: 5px;
    height: 10px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translateY(-1px);
}

.checkbox-text {
    font-size: 0.83rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.link {
    color: var(--sea);
    text-decoration: underline;
}

/* ── Bottone ──────────────────────────────────────────────────────────────── */
.btn-connect {
    background: linear-gradient(135deg, var(--sea) 0%, var(--sea-dark) 100%);
    color: var(--white);
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 16px rgba(10, 126, 164, 0.35);
    margin-top: 4px;
    -webkit-appearance: none;
    appearance: none;
}

.btn-connect:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(10, 126, 164, 0.25);
}

/* ── Errore ───────────────────────────────────────────────────────────────── */
.error-box {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-text);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.9rem;
    margin-bottom: 8px;
    line-height: 1.5;
}

/* ── Successo ─────────────────────────────────────────────────────────────── */
.success-box {
    text-align: center;
    padding: 16px 0 8px;
}

.success-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
}

.success-box h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--sea-dark);
    margin-bottom: 10px;
}

.success-box p {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 8px;
}

.redirect-note {
    font-size: 0.8rem !important;
    color: #aab8c4 !important;
    margin-top: 16px !important;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .portal-card {
        padding: 28px 18px 32px;
        border-radius: 16px;
    }

    .portal-title {
        font-size: 1.3rem;
    }

    .logo {
        max-width: 150px;
    }
}

@media (min-width: 768px) {
    .btn-connect:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 20px rgba(10, 126, 164, 0.4);
    }
}
