/* Jávem — Auth modal
   Depends on brand CSS vars: --brand-primary, --brand-card, --brand-text, --brand-border, --brand-bg */

:root {
    --auth-modal-width: 400px;
    --auth-modal-radius: 22px;
    --auth-modal-radius-sm: 12px;
    --auth-modal-z: 1050;
    --auth-modal-muted: color-mix(in srgb, var(--brand-text, #1A1A2E) 55%, transparent);
    --auth-modal-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    --auth-modal-ease: 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

body.auth-modal-open {
    overflow: hidden;
}

/* —— Root / backdrop / dialog —— */

.auth-modal-root {
    position: fixed;
    inset: 0;
    z-index: var(--auth-modal-z);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    visibility: hidden;
    pointer-events: none;
}

.auth-modal-root[hidden] {
    display: none !important;
}

.auth-modal-root.is-open {
    visibility: visible;
    pointer-events: auto;
}

.auth-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 26, 46, 0.52);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity var(--auth-modal-ease);
    cursor: pointer;
}

.auth-modal-root.is-open .auth-modal-backdrop {
    opacity: 1;
}

.auth-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: min(100%, var(--auth-modal-width, 400px));
    max-height: min(88vh, 640px);
    margin: 0;
    display: flex;
    flex-direction: column;
    outline: none;
    transform: translateY(18px) scale(0.97);
    opacity: 0;
    transition:
        transform var(--auth-modal-ease),
        opacity var(--auth-modal-ease);
}

.auth-modal-root.is-open .auth-modal-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.auth-modal-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: min(88vh, 640px);
    overflow: hidden;
    background: var(--brand-card, #fff);
    color: var(--brand-text, #1A1A2E);
    border: 1px solid var(--brand-border, #E9ECEF);
    border-radius: var(--auth-modal-radius);
    box-shadow: var(--auth-modal-shadow);
}

/* —— Side illustration (optional; só em telas largas + modal largo) —— */

.auth-modal-side {
    display: none;
    position: relative;
    flex: 0 0 42%;
    min-height: 0;
    overflow: hidden;
    background:
        linear-gradient(160deg, #D00000 0%, var(--brand-primary, #E85D04) 48%, #F48C06 100%);
    color: #fff;
}

.auth-modal-side img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-modal-side-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.75rem;
    height: 100%;
    padding: 2rem;
    background: linear-gradient(180deg, transparent 20%, rgba(26, 26, 46, 0.55) 100%);
}

.auth-modal-side-content h2,
.auth-modal-side-title {
    margin: 0;
    font-family: Fraunces, Georgia, serif;
    font-size: clamp(1.5rem, 2.2vw, 1.85rem);
    font-weight: 700;
    line-height: 1.2;
}

.auth-modal-side-content p,
.auth-modal-side-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.45;
    opacity: 0.92;
    max-width: 28ch;
}

/* —— Main column —— */

.auth-modal-main {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1.1rem 1.15rem 1.2rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--brand-card, #fff);
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--brand-primary, #E85D04) 55%, #c4c4c4)
        color-mix(in srgb, var(--brand-border, #E9ECEF) 70%, transparent);
}

/* Scrollbar moderna (Chromium / Safari / Edge) */
.auth-modal-main::-webkit-scrollbar {
    width: 8px;
}

.auth-modal-main::-webkit-scrollbar-track {
    margin: 10px 0;
    background: transparent;
    border-radius: 999px;
}

.auth-modal-main::-webkit-scrollbar-thumb {
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--brand-primary, #E85D04) 45%, #cfcfcf),
        color-mix(in srgb, var(--brand-primary, #E85D04) 70%, #999)
    );
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
    min-height: 40px;
}

.auth-modal-main::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(
        180deg,
        var(--brand-primary, #E85D04),
        color-mix(in srgb, var(--brand-primary, #E85D04) 80%, #000)
    );
    border: 2px solid transparent;
    background-clip: padding-box;
}

.auth-modal-main::-webkit-scrollbar-corner {
    background: transparent;
}

.auth-modal-close {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border: 1px solid var(--brand-border, #E9ECEF);
    border-radius: 999px;
    background: var(--brand-bg, #F8F5F2);
    color: var(--brand-text, #1A1A2E);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.auth-modal-close:hover {
    background: color-mix(in srgb, var(--brand-primary, #E85D04) 12%, var(--brand-card, #fff));
    border-color: color-mix(in srgb, var(--brand-primary, #E85D04) 35%, var(--brand-border, #E9ECEF));
    color: var(--brand-primary, #E85D04);
}

.auth-modal-head {
    margin: 0 2rem 0.85rem 0;
}

.auth-modal-head h2,
.auth-modal-heading,
#auth-modal-title {
    margin: 0;
    font-family: Fraunces, Georgia, serif;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--brand-text, #1A1A2E);
}

.auth-modal-head p:not(.visually-hidden),
.auth-modal-subheading {
    margin: 0.3rem 0 0;
    font-size: 0.84rem;
    line-height: 1.4;
    color: var(--auth-modal-muted);
}

/* —— Tabs —— */

.auth-modal-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 0 0 0.95rem;
    padding: 0.22rem;
    border-radius: 999px;
    background: var(--brand-bg, #F8F5F2);
    border: 1px solid var(--brand-border, #E9ECEF);
}

.auth-modal-tab {
    flex: 1 1 0;
    margin: 0;
    padding: 0.45rem 0.6rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--auth-modal-muted);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.auth-modal-tab:hover {
    color: var(--brand-text, #1A1A2E);
}

.auth-modal-tab.is-active {
    background: var(--brand-card, #fff);
    color: var(--brand-primary, #E85D04);
    box-shadow: 0 1px 4px rgba(26, 26, 46, 0.08);
}

/* —— Views —— */

.auth-modal-view {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    animation: auth-modal-fade-in 0.22s ease;
}

.auth-modal-view.is-active {
    display: flex;
}

.auth-modal-view[hidden] {
    display: none !important;
}

@keyframes auth-modal-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* —— Alerts —— */

.auth-modal-alert {
    display: none;
    margin: 0;
    padding: 0.7rem 0.85rem;
    border-radius: var(--auth-modal-radius-sm);
    border: 1px solid transparent;
    font-size: 0.875rem;
    line-height: 1.4;
}

.auth-modal-alert.is-visible,
.auth-modal-alert:not(:empty) {
    display: block;
}

.auth-modal-alert--error,
.auth-modal-alert.is-error {
    background: color-mix(in srgb, #DC3545 10%, var(--brand-card, #fff));
    border-color: color-mix(in srgb, #DC3545 35%, var(--brand-border, #E9ECEF));
    color: #A71D2A;
}

.auth-modal-alert--success,
.auth-modal-alert.is-success {
    background: color-mix(in srgb, #198754 10%, var(--brand-card, #fff));
    border-color: color-mix(in srgb, #198754 35%, var(--brand-border, #E9ECEF));
    color: #0F5132;
}

.auth-modal-alert ul {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
}

.auth-modal-alert li + li {
    margin-top: 0.15rem;
}

/* —— Role choice cards —— */

.auth-role-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.auth-role-card {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    width: 100%;
    margin: 0;
    padding: 1rem 1.05rem;
    text-align: left;
    border: 1px solid var(--brand-border, #E9ECEF);
    border-radius: var(--auth-modal-radius-sm);
    background: var(--brand-bg, #F8F5F2);
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-role-card:hover {
    border-color: color-mix(in srgb, var(--brand-primary, #E85D04) 45%, var(--brand-border, #E9ECEF));
    background: color-mix(in srgb, var(--brand-primary, #E85D04) 6%, var(--brand-card, #fff));
    box-shadow: 0 4px 16px rgba(232, 93, 4, 0.1);
    transform: translateY(-1px);
}

.auth-role-card-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 12px;
    background: color-mix(in srgb, var(--brand-primary, #E85D04) 14%, transparent);
    color: var(--brand-primary, #E85D04);
    font-size: 1.2rem;
}

.auth-role-card-body {
    flex: 1 1 auto;
    min-width: 0;
}

.auth-role-card-title {
    display: block;
    margin: 0 0 0.2rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--brand-text, #1A1A2E);
}

.auth-role-card-text {
    display: block;
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--auth-modal-muted);
}

/* —— Multi-step dots —— */

.auth-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin: 0 0 0.25rem;
}

.auth-step-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    background: var(--brand-border, #E9ECEF);
    border: none;
    padding: 0;
    transition: width 0.2s ease, background 0.2s ease;
}

.auth-step-dot.is-active {
    width: 1.35rem;
    background: var(--brand-primary, #E85D04);
}

.auth-step-dot.is-done {
    background: color-mix(in srgb, var(--brand-primary, #E85D04) 55%, var(--brand-border, #E9ECEF));
}

.auth-step-panel {
    display: none;
    flex-direction: column;
    gap: 0.85rem;
}

.auth-step-panel.is-active {
    display: flex;
}

.auth-step-panel[hidden] {
    display: none !important;
}

.auth-step-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.35rem;
}

.auth-step-actions .auth-btn-primary,
.auth-step-actions .auth-btn-ghost {
    flex: 1 1 auto;
}

/* —— Forms —— */

.auth-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

.auth-form-grid--2 {
    grid-template-columns: 1fr;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.auth-field label,
.auth-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--brand-text, #1A1A2E);
}

.auth-field .auth-hint,
.auth-hint {
    font-size: 0.78rem;
    color: var(--auth-modal-muted);
}

.auth-modal-main input[type="text"],
.auth-modal-main input[type="email"],
.auth-modal-main input[type="password"],
.auth-modal-main input[type="tel"],
.auth-modal-main input[type="search"],
.auth-modal-main input[type="number"],
.auth-modal-main input[type="date"],
.auth-modal-main input[type="time"],
.auth-modal-main input[type="datetime-local"],
.auth-modal-main select,
.auth-modal-main textarea,
.auth-modal-main .form-control,
.auth-modal-main .form-select,
.auth-input,
.auth-select,
.auth-textarea {
    width: 100%;
    margin: 0;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--brand-border, #E9ECEF);
    border-radius: 10px;
    background: var(--brand-card, #fff);
    color: var(--brand-text, #1A1A2E);
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.35;
    min-height: 42px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    accent-color: var(--brand-primary, #E85D04);
    color-scheme: inherit;
}

.auth-modal-main textarea,
.auth-textarea {
    min-height: 5rem;
    resize: vertical;
}

.auth-modal-main input::placeholder,
.auth-modal-main textarea::placeholder {
    color: color-mix(in srgb, var(--brand-text, #1A1A2E) 40%, transparent);
}

.auth-modal-main input:hover,
.auth-modal-main select:hover,
.auth-modal-main textarea:hover,
.auth-modal-main .form-control:hover,
.auth-modal-main .form-select:hover,
.auth-input:hover,
.auth-select:hover,
.auth-textarea:hover {
    border-color: color-mix(in srgb, var(--brand-primary, #E85D04) 30%, var(--brand-border, #E9ECEF));
}

.auth-modal-main input:focus,
.auth-modal-main select:focus,
.auth-modal-main textarea:focus,
.auth-modal-main .form-control:focus,
.auth-modal-main .form-select:focus,
.auth-input:focus,
.auth-select:focus,
.auth-textarea:focus {
    outline: none;
    border-color: var(--brand-primary, #E85D04);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary, #E85D04) 22%, transparent);
}

.auth-check {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--brand-text, #1A1A2E);
}

.auth-check input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 1rem;
    height: 1rem;
    accent-color: var(--brand-primary, #E85D04);
    flex-shrink: 0;
}

.auth-form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.auth-form-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.88rem;
}

/* —— Buttons & links —— */

.auth-btn-primary,
.auth-btn-ghost {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

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

.auth-btn-primary:hover:not(:disabled):not(.is-loading) {
    background: color-mix(in srgb, var(--brand-primary, #E85D04) 88%, #000);
    border-color: color-mix(in srgb, var(--brand-primary, #E85D04) 88%, #000);
    transform: translateY(-1px);
}

.auth-btn-ghost {
    background: transparent;
    border-color: var(--brand-border, #E9ECEF);
    color: var(--brand-text, #1A1A2E);
}

.auth-btn-ghost:hover:not(:disabled):not(.is-loading) {
    background: var(--brand-bg, #F8F5F2);
    border-color: color-mix(in srgb, var(--brand-primary, #E85D04) 30%, var(--brand-border, #E9ECEF));
}

.auth-btn-primary:disabled,
.auth-btn-ghost:disabled,
.auth-btn-primary.is-loading,
.auth-btn-ghost.is-loading {
    cursor: not-allowed;
    opacity: 0.72;
    transform: none;
}

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

.auth-link {
    color: var(--brand-primary, #E85D04);
    font-weight: 600;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.auth-link:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* —— Footer note —— */

.auth-modal-footer-note {
    margin: 0.5rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--brand-border, #E9ECEF);
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--auth-modal-muted);
    text-align: center;
}

.auth-modal-noscript-hint {
    display: none !important;
}

.auth-modal-main .mb-3 {
    margin-bottom: 0.7rem !important;
}

.auth-modal-main .form-label {
    margin-bottom: 0.3rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.auth-modal-main .form-check {
    margin-bottom: 0.65rem !important;
    min-height: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding-left: 0;
}

.auth-modal-main .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.15rem;
    margin-left: 0;
    float: none;
    flex-shrink: 0;
    cursor: pointer;
    border: 2px solid color-mix(in srgb, var(--brand-primary, #E85D04) 45%, var(--brand-border, #E9ECEF));
    background-color: var(--brand-card, #fff);
    accent-color: var(--brand-primary, #E85D04);
}

.auth-modal-main .form-check-input:checked {
    background-color: var(--brand-primary, #E85D04);
    border-color: var(--brand-primary, #E85D04);
}

.auth-modal-main .form-check-label {
    font-size: 0.84rem;
    cursor: pointer;
    line-height: 1.45;
    padding-top: 0.1rem;
}

.auth-modal-main .auth-terms-check .form-check-label a {
    color: var(--brand-primary, #E85D04);
    text-decoration: underline;
    font-weight: 600;
    pointer-events: auto;
}

/* —— Focus visible —— */

.auth-modal-root a:focus-visible,
.auth-modal-root button:focus-visible,
.auth-modal-root input:focus-visible,
.auth-modal-root select:focus-visible,
.auth-modal-root textarea:focus-visible,
.auth-modal-close:focus-visible,
.auth-modal-tab:focus-visible,
.auth-role-card:focus-visible,
.auth-btn-primary:focus-visible,
.auth-btn-ghost:focus-visible,
.auth-link:focus-visible {
    outline: 2px solid var(--brand-primary, #E85D04);
    outline-offset: 2px;
}

/* —— Desktop (continua card compacto; painel lateral só se o modal for largo) —— */

@media (min-width: 768px) {
    .auth-modal-root {
        align-items: center;
        padding: 1.5rem;
    }

    .auth-modal-dialog {
        max-width: var(--auth-modal-width, 400px);
        max-height: min(86vh, 620px);
    }

    .auth-modal-panel {
        max-height: min(86vh, 620px);
        border-radius: var(--auth-modal-radius);
    }

    .auth-modal-main {
        padding: 1.25rem 1.35rem 1.3rem;
    }

    .auth-modal-head h2,
    .auth-modal-heading,
    #auth-modal-title {
        font-size: 1.28rem;
    }

    .auth-form-grid--2 {
        grid-template-columns: 1fr 1fr;
    }

    .auth-role-grid {
        grid-template-columns: 1fr;
    }

    .auth-form-actions {
        flex-direction: row;
        align-items: center;
    }

    .auth-form-actions .auth-btn-primary {
        flex: 1 1 auto;
    }
}

@media (min-width: 900px) {
    .auth-role-grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* —— Reduced motion —— */

@media (prefers-reduced-motion: reduce) {
    .auth-modal-backdrop,
    .auth-modal-dialog,
    .auth-modal-view,
    .auth-modal-close,
    .auth-modal-tab,
    .auth-role-card,
    .auth-btn-primary,
    .auth-btn-ghost,
    .auth-step-dot {
        transition: none !important;
        animation: none !important;
    }

    .auth-modal-dialog {
        transform: none;
        opacity: 1;
    }

    .auth-modal-root.is-open .auth-modal-dialog {
        transform: none;
        opacity: 1;
    }

    .auth-btn-primary.is-loading,
    .auth-btn-ghost.is-loading {
        opacity: 0.6;
    }
}

/* Celular: país + DDD + número */
.auth-phone-row .form-control {
    text-align: center;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}
.auth-phone-row .col-6 .form-control {
    text-align: left;
    padding-left: 0.75rem;
}
