/* ── MODAL OVERLAY ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14,17,22,0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

    .modal-overlay.show {
        opacity: 1;
        pointer-events: all;
    }

    .modal-overlay.bloqueio-pagina {
        left: 260px;
        z-index: 900;
    }

@media (max-width: 768px) {
    .modal-overlay.bloqueio-pagina {
        left: 0;
        z-index: 2000;
    }

    /* Modal de cadastro: garante que não sai da tela */
    #cadastroOverlay .modal-box {
        max-width: calc(100vw - 32px);
        margin: 0 16px;
        max-height: 92dvh;
        overflow-y: auto;
    }

    /* Modal de login também */
    #loginOverlay .modal-box {
        max-width: calc(100vw - 32px);
        margin: 0 16px;
    }
}
/* Quando o botão Entrar é usado: overlay cobre tudo, incluindo sidebar */
body.blur-sidebar-ativo .modal-overlay.show {
    left: 0;
    z-index: 2000;
}

/* Sidebar recebe blur quando botão Entrar é usado */
#appSidebar {
    position: relative;
}

    #appSidebar::after {
        content: '';
        position: absolute;
        inset: 0;
        backdrop-filter: blur(3px);
        background: rgba(14,17,22,0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s;
        z-index: 1;
    }

body.blur-sidebar-ativo #appSidebar::after {
    opacity: 1;
    pointer-events: all;
}

/* ── MODAL BOX ───────────────────────────────────────────────────── */
.modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 32px 64px rgba(14,17,22,0.28);
    transform: translateY(12px);
    transition: transform .2s;
}

.modal-overlay.show .modal-box {
    transform: translateY(0);
}

/* Modal de cadastro — um pouco mais largo para os campos extras */
#cadastroOverlay .modal-box {
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ── BRAND ───────────────────────────────────────────────────────── */
.modal-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-mark-lg {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--blue-accent);
    flex-shrink: 0;
    position: relative;
}

    .brand-mark-lg::before, .brand-mark-lg::after {
        content: "";
        position: absolute;
        background: rgba(255,255,255,0.9);
        border-radius: 1px;
    }

    .brand-mark-lg::before {
        width: 18px;
        height: 2.5px;
        top: 14px;
        left: 13px;
    }

    .brand-mark-lg::after {
        width: 13px;
        height: 2.5px;
        top: 21px;
        left: 13px;
    }

.modal-brand-name {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--navy-950);
}

.modal-brand-sub {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

/* ── CAMPOS ──────────────────────────────────────────────────────── */
.modal-field {
    margin-bottom: 16px;
}

    .modal-field label {
        display: block;
        font-size: 12.5px;
        font-weight: 700;
        color: var(--navy-950);
        margin-bottom: 6px;
    }

        .modal-field label .obrig {
            color: #d5304a;
            margin-left: 2px;
        }

    .modal-field input {
        width: 100%;
        padding: 12px 14px;
        border: 1.5px solid var(--gray-200);
        border-radius: 9px;
        font-size: 14px;
        font-family: 'Inter', sans-serif;
        background: var(--gray-50);
        color: var(--navy-950);
        outline: none;
        transition: border-color .15s, box-shadow .15s;
        box-sizing: border-box;
    }

        .modal-field input:focus {
            border-color: var(--blue-accent);
            background: #fff;
            box-shadow: 0 0 0 4px rgba(31,111,84,0.12);
        }

/* Dois campos lado a lado */
.modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

    .modal-row .modal-field {
        margin-bottom: 0;
    }

/* ── SENHA ───────────────────────────────────────────────────────── */
.pass-wrap {
    position: relative;
}

    .pass-wrap input {
        padding-right: 44px;
    }

.pass-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
    display: flex;
    align-items: center;
}

    .pass-toggle svg {
        width: 16px;
        height: 16px;
    }

    .pass-toggle:hover {
        color: var(--navy-950);
    }

/* ── ERRO ────────────────────────────────────────────────────────── */
.modal-error {
    font-size: 12.5px;
    color: #d5304a;
    font-weight: 600;
    min-height: 18px;
    margin-bottom: 4px;
}

/* ── BOTÃO ───────────────────────────────────────────────────────── */
.modal-btn {
    width: 100%;
    background: var(--blue-accent);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 13px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .15s;
}

    .modal-btn:hover {
        background: var(--blue-accent-dark);
    }

    .modal-btn:disabled {
        background: var(--gray-200);
        color: var(--gray-400);
        cursor: not-allowed;
    }

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* ── FOOTER DO MODAL ─────────────────────────────────────────────── */
.modal-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 12.5px;
    color: var(--gray-400);
}

    .modal-footer a {
        color: var(--blue-accent);
        text-decoration: none;
        font-weight: 600;
    }

        .modal-footer a:hover {
            text-decoration: underline;
        }

.modal-footer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

    .modal-footer-row span {
        flex: 1;
        height: 1px;
        background: var(--gray-200);
    }

/* ── USER CHIP (pós-login) ───────────────────────────────────────── */
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    padding: 4px 12px 4px 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-950);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blue-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-logout {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 2px;
    display: flex;
    align-items: center;
    margin-left: 2px;
}

    .user-logout svg {
        width: 14px;
        height: 14px;
    }

    .user-logout:hover {
        color: #d5304a;
    }

/* ── MODAL BUSCA DE EMPRESA ──────────────────────────────────────── */
.busca-empresa-wrap {
    position: relative;
    margin-bottom: 12px;
}

.busca-empresa-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--gray-400);
    pointer-events: none;
}

.busca-empresa-wrap input {
    width: 100%;
    padding: 12px 40px 12px 38px;
    border: 1.5px solid var(--gray-200);
    border-radius: 9px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--gray-50);
    color: var(--navy-950);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}

    .busca-empresa-wrap input:focus {
        border-color: var(--blue-accent);
        background: #fff;
        box-shadow: 0 0 0 4px rgba(31,111,84,0.12);
    }

.busca-empresa-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
    display: flex;
    align-items: center;
}

    .busca-empresa-clear svg {
        width: 14px;
        height: 14px;
    }

    .busca-empresa-clear:hover {
        color: var(--navy-950);
    }

/* Lista de resultados */
.busca-empresa-lista {
    max-height: 320px;
    overflow-y: auto;
    border: 1.5px solid var(--gray-200);
    border-radius: 9px;
    background: var(--gray-50);
}

.busca-empresa-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-200);
    transition: background .12s;
    gap: 10px;
}

    .busca-empresa-item:last-child {
        border-bottom: none;
    }

    .busca-empresa-item:hover {
        background: rgba(31,111,84,0.06);
    }

    .busca-empresa-item.selecionada {
        background: rgba(31,111,84,0.10);
    }

.busca-empresa-info {
    flex: 1;
    min-width: 0;
}

.busca-empresa-nome {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--navy-950);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.busca-empresa-cnpj {
    font-size: 11.5px;
    color: var(--gray-400);
    margin-top: 2px;
}

.busca-empresa-badge {
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(31,111,84,0.12);
    color: var(--blue-accent);
    white-space: nowrap;
    flex-shrink: 0;
}

    .busca-empresa-badge.inativa {
        background: rgba(213,48,74,0.10);
        color: #d5304a;
    }

/* Estado vazio / carregando / erro */
.busca-empresa-estado {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px 16px;
    color: var(--gray-400);
    font-size: 13px;
}

.busca-empresa-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--gray-200);
    border-top-color: var(--blue-accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
