/* Portal do paciente — visual profissional */

body.is-portal {
    font-family: var(--font-sans);
    background: #eef2f5;
    color: var(--ink);
}

body.is-portal::before {
    background:
        radial-gradient(900px 400px at 100% -5%, rgba(36, 75, 90, 0.08), transparent 55%),
        radial-gradient(600px 320px at 0% 100%, rgba(47, 95, 112, 0.05), transparent 60%);
}

body.is-portal h1,
body.is-portal h2,
body.is-portal h3 {
    font-family: var(--font-sans);
}

body.is-portal .portal-main.portal-main--wide {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    align-items: stretch;
}

/* Topbar */
.portal-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px clamp(20px, 4vw, 32px);
    background: rgba(26, 47, 56, 0.97);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
}

.portal-topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}

.portal-topbar-brand img {
    width: 36px;
    height: 36px;
    padding: 5px;
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
}

.portal-topbar-brand span {
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.92);
}

.portal-topbar-logout {
    margin: 0;
}

.portal-topbar-logout .portal-btn {
    min-height: 36px;
    padding: 0 14px;
    font-size: 0.82rem;
}

/* Conteúdo */
.portal-home {
    display: grid;
    gap: 20px;
    padding: clamp(24px, 4vw, 36px) clamp(16px, 3vw, 24px) 0;
}

.portal-flash {
    border-radius: 8px;
}

/* Hero */
.portal-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(28px, 4vw, 36px);
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #1a2f38 0%, #244b5a 48%, #2f5f70 100%);
    box-shadow: 0 20px 40px rgba(26, 47, 56, 0.18);
}

.portal-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(420px 220px at 100% 0%, rgba(255, 255, 255, 0.08), transparent 70%),
        radial-gradient(300px 180px at 0% 100%, rgba(0, 0, 0, 0.12), transparent 65%);
    pointer-events: none;
}

.portal-hero-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.portal-hero-copy {
    min-width: 0;
}

.portal-hero-kicker {
    margin: 0 0 8px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.62);
}

.portal-hero h1 {
    margin: 0 0 8px;
    font-size: clamp(1.65rem, 3.5vw, 2.1rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #fff;
    line-height: 1.15;
}

.portal-hero-lead {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.78);
    max-width: 40ch;
}

.portal-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.portal-hero-actions form {
    margin: 0;
}

/* Botões */
.portal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition:
        background 0.2s var(--ease-out),
        border-color 0.2s var(--ease-out),
        box-shadow 0.2s var(--ease-out),
        transform 0.2s var(--ease-out);
}

.portal-btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.portal-btn-sm {
    min-height: 36px;
    padding: 0 14px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.portal-btn-primary {
    background: #fff;
    color: var(--brand-dark);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.portal-btn-primary:hover {
    color: var(--brand-dark);
    background: #f4f8fa;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.portal-btn-on-dark {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.22);
}

.portal-btn-on-dark:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.35);
}

.portal-btn-ghost {
    background: #fff;
    color: var(--brand-dark);
    border-color: var(--line);
    box-shadow: 0 1px 2px rgba(18, 21, 26, 0.04);
}

.portal-btn-ghost:hover {
    color: var(--brand-dark);
    background: var(--brand-soft);
    border-color: #c5d3da;
}

/* Resumo */
.portal-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.portal-summary-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid rgba(220, 227, 232, 0.9);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(18, 21, 26, 0.04);
}

.portal-summary-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 11px;
    flex-shrink: 0;
}

.portal-summary-icon--appointments {
    background: #e8f2f8;
    color: var(--brand-dark);
}

.portal-summary-icon--returns {
    background: #e8f5ee;
    color: var(--accent);
}

.portal-summary-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portal-summary-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.portal-summary-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}

/* Painéis */
.portal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.portal-panel {
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(220, 227, 232, 0.95);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(18, 21, 26, 0.04);
}

.portal-panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.portal-panel-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    flex-shrink: 0;
}

.portal-panel-icon--appointments {
    background: #e8f2f8;
    color: var(--brand-dark);
}

.portal-panel-icon--returns {
    background: #e8f5ee;
    color: var(--accent);
}

.portal-panel-head h2 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.portal-panel-body {
    padding: 20px;
}

.portal-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 20px;
    border-radius: 10px;
    background: #f8fafb;
}

.portal-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: #fff;
    color: var(--brand);
    border: 1px solid var(--line);
    box-shadow: 0 2px 8px rgba(18, 21, 26, 0.04);
}

.portal-empty-title {
    margin: 0 0 6px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
}

.portal-empty p {
    margin: 0;
    max-width: 28ch;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--muted);
}

.portal-empty .portal-btn {
    margin-top: 16px;
}

.portal-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.portal-list li {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 5px;
    background: #fafcfd;
    transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.portal-list li:hover {
    border-color: #c5d3da;
    box-shadow: 0 4px 14px rgba(18, 21, 26, 0.05);
}

.portal-list li strong {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--brand-dark);
}

.portal-list-badge {
    margin-top: 4px;
    width: fit-content;
}

.portal-list-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.portal-list-actions form {
    margin: 0;
}

/* LGPD */
.portal-lgpd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: 18px 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(18, 21, 26, 0.03);
}

.portal-lgpd-head {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.portal-lgpd-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    flex-shrink: 0;
}

.portal-lgpd h2 {
    margin: 0 0 2px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
}

.portal-lgpd p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.portal-lgpd-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.portal-lgpd-actions form {
    margin: 0;
}

/* Auth (login / OTP) */
body.is-portal .portal-main:has(.portal-auth-shell) {
    padding: 0;
    align-items: stretch;
}

body.is-portal:has(.portal-auth-shell) {
    background: #e8eef2;
}

body.is-portal:has(.portal-auth-shell)::before {
    background:
        radial-gradient(900px 480px at 12% 0%, rgba(47, 95, 112, 0.16), transparent 58%),
        radial-gradient(720px 420px at 100% 100%, rgba(26, 47, 56, 0.1), transparent 55%),
        linear-gradient(180deg, #f3f7f9 0%, #e4ebf0 100%);
}

.portal-auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 4vw, 40px) 16px;
}

.portal-auth-stage {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 0;
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid rgba(26, 47, 56, 0.1);
    background: #fff;
    box-shadow:
        0 1px 2px rgba(18, 21, 26, 0.04),
        0 28px 56px rgba(26, 47, 56, 0.14);
}

.portal-auth-welcome {
    position: relative;
    padding: clamp(28px, 4vw, 40px);
    background:
        radial-gradient(480px 280px at 100% 0%, rgba(255, 255, 255, 0.12), transparent 60%),
        linear-gradient(155deg, #1a2f38 0%, #244b5a 48%, #2f5f70 100%);
    color: #fff;
}

.portal-auth-welcome::after {
    content: "";
    position: absolute;
    inset: auto -20% -30% 20%;
    height: 70%;
    background: radial-gradient(circle, rgba(139, 191, 42, 0.18), transparent 70%);
    pointer-events: none;
}

.portal-auth-welcome-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.portal-auth-welcome-logo {
    width: auto;
    height: 40px;
    margin-bottom: 8px;
    object-fit: contain;
}

.portal-auth-welcome-kicker {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.62);
}

.portal-auth-welcome-title {
    margin: 0;
    font-size: clamp(1.45rem, 2.6vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: #fff;
}

.portal-auth-welcome-text {
    margin: 0;
    max-width: 32ch;
    font-size: 0.95rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.78);
}

.portal-auth-welcome-list {
    list-style: none;
    margin: auto 0 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.portal-auth-welcome-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.88rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
}

.portal-auth-welcome-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    flex-shrink: 0;
}

.portal-auth-welcome-icon svg {
    width: 16px;
    height: 16px;
}

.portal-auth-card {
    width: 100%;
    padding: clamp(28px, 4vw, 40px);
    background: #fff;
}

.portal-auth-card-narrow {
    width: min(440px, 100%);
    margin: 0 auto;
    border-radius: 22px;
    border: 1px solid rgba(26, 47, 56, 0.1);
    box-shadow:
        0 1px 2px rgba(18, 21, 26, 0.04),
        0 28px 56px rgba(26, 47, 56, 0.14);
}

.portal-auth-brand {
    text-align: center;
    margin-bottom: 22px;
}

.portal-auth-brand img {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    padding: 12px;
    border-radius: 18px;
    background: linear-gradient(180deg, #f7fafb 0%, #eef4f6 100%);
    border: 1px solid #d5e0e6;
    object-fit: contain;
    box-shadow: 0 8px 18px rgba(26, 47, 56, 0.06);
}

.portal-auth-kicker {
    margin: 0 0 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--brand);
}

.portal-auth-brand-compact .portal-lgpd-icon {
    margin: 0 auto 12px;
    width: 52px;
    height: 52px;
    border-radius: 14px;
}

.portal-auth-brand h1 {
    margin: 0 0 8px;
    font-size: clamp(1.45rem, 3vw, 1.7rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.portal-auth-brand p {
    margin: 0 auto;
    max-width: 34ch;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--muted);
}

.portal-auth-clinic {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: linear-gradient(180deg, #f4f8fa 0%, #eef4f6 100%);
    border: 1px solid #d5e0e6;
    font-size: 0.9rem;
}

.portal-auth-clinic span {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.portal-auth-clinic strong {
    color: var(--brand-dark);
    font-weight: 800;
}

.portal-auth-flash {
    margin-bottom: 14px;
    border-radius: 10px;
}

.portal-form-stack {
    display: grid;
    gap: 16px;
}

.portal-form-stack-tight {
    margin-top: 10px;
    gap: 8px;
}

.portal-field label,
.portal-form-stack label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--brand-dark);
}

.portal-field-hint,
.portal-form-stack .muted {
    display: block;
    margin-top: 7px;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--muted);
}

.portal-form-stack input,
.portal-form-stack select {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid #c5d3da;
    border-radius: 12px;
    background: #fbfcfd;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--ink);
    transition:
        border-color 0.18s var(--ease-out),
        box-shadow 0.18s var(--ease-out),
        background 0.18s var(--ease-out);
}

.portal-form-stack input:hover,
.portal-form-stack select:hover {
    border-color: #a9bfc9;
    background: #fff;
}

.portal-form-stack input:focus,
.portal-form-stack select:focus {
    outline: none;
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(47, 95, 112, 0.14);
}

.portal-btn-block {
    width: 100%;
}

.portal-btn-solid {
    min-height: 50px;
    border-radius: 12px;
    background: linear-gradient(180deg, #2f5f70 0%, #244b5a 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 22px rgba(26, 47, 56, 0.22);
    font-size: 0.95rem;
}

.portal-btn-solid:hover {
    background: linear-gradient(180deg, #35697b 0%, #1f404d 100%);
    color: #fff;
    box-shadow: 0 14px 28px rgba(26, 47, 56, 0.26);
}

.portal-otp-input {
    font-family: var(--font-mono);
    font-size: 1.35rem !important;
    letter-spacing: 0.28em;
    text-align: center;
}

.portal-auth-trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.portal-auth-trust-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--live);
    box-shadow: 0 0 0 4px rgba(139, 191, 42, 0.18);
}

.portal-auth-footer {
    margin: 18px 0 0;
    text-align: center;
    font-size: 0.88rem;
}

.portal-auth-sep {
    margin: 0 6px;
    color: #b6c4cc;
}

.portal-auth-link {
    color: var(--brand-dark);
    font-weight: 700;
    text-decoration: none;
}

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

@media (max-width: 860px) {
    .portal-auth-stage {
        grid-template-columns: 1fr;
        max-width: 460px;
    }

    .portal-auth-welcome {
        padding: 24px 22px 20px;
    }

    .portal-auth-welcome-title {
        font-size: 1.35rem;
    }

    .portal-auth-welcome-text {
        max-width: none;
    }

    .portal-auth-welcome-list {
        margin-top: 8px;
    }

    .portal-auth-welcome-list li {
        padding: 10px 12px;
        font-size: 0.84rem;
    }
}

@media (max-width: 520px) {
    .portal-auth-shell {
        padding: 12px;
    }

    .portal-auth-stage {
        border-radius: 18px;
    }

    .portal-auth-card {
        padding: 24px 18px 22px;
    }

    .portal-auth-brand img {
        width: 64px;
        height: 64px;
    }
}

/* Agendamento */
.portal-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.portal-page-title {
    margin: 0 0 6px;
    font-size: clamp(1.35rem, 3vw, 1.6rem);
    font-weight: 800;
    color: var(--ink);
}

.portal-page-lead {
    margin: 0;
    font-size: 0.92rem;
    color: var(--muted);
}

.portal-schedule-filters {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

@media (max-width: 720px) {
    .portal-schedule-filters {
        grid-template-columns: 1fr;
    }

    .portal-hero-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .portal-hero-actions .portal-btn {
        flex: 1;
    }

    .portal-summary,
    .portal-grid {
        grid-template-columns: 1fr;
    }

    .portal-lgpd {
        flex-direction: column;
        align-items: stretch;
    }

    .portal-lgpd-actions .portal-btn {
        flex: 1;
        min-width: 140px;
    }

    .portal-list-actions .portal-btn {
        flex: 1;
        justify-content: center;
    }

    .portal-page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .portal-page-head .portal-btn {
        align-self: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-btn:hover {
        transform: none;
    }
}
