/*
 * Aki Cadastro Responsivo v2.2
 * Correção: nenhuma categoria fica inacessível.
 * O painel inteiro permanece estável e somente a relação de segmentos
 * recebe rolagem quando não couber na altura disponível.
 */

html,
body {
    width: 100%;
    min-height: 100%;
}

.aki-register-page,
.aki-register-main,
.aki-register-shell,
.aki-segment-form,
.aki-segment-groups {
    min-width: 0;
}

.aki-segment-search {
    display: none;
    position: relative;
    margin: 0 0 12px;
}

.aki-segment-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #7a8799;
    pointer-events: none;
}

.aki-segment-search input {
    width: 100%;
    height: 42px;
    box-sizing: border-box;
    padding: 0 14px 0 42px;
    border: 1px solid #dbe3ed;
    border-radius: 13px;
    background: #fff;
    color: #111827;
    font: inherit;
    outline: none;
}

.aki-segment-search input:focus {
    border-color: #ff7a1a;
    box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.12);
}

.aki-empty-search {
    display: none;
    padding: 18px;
    text-align: center;
    color: #64748b;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    background: #fff;
}

.aki-category-group[hidden],
.aki-niche[hidden] {
    display: none !important;
}

/*
 * Desktop e notebooks.
 * A página não rola, porém a lista de segmentos sempre pode rolar.
 */
@media (min-width: 1100px) {
    body {
        overflow: hidden;
    }

    .aki-register-page {
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    .aki-register-hero,
    .aki-register-main {
        height: 100dvh;
        min-height: 0;
    }

    .aki-register-hero {
        overflow: hidden;
    }

    .aki-register-main {
        overflow: hidden;
    }

    .aki-register-shell {
        height: 100%;
        min-height: 0;
        max-height: 100dvh;
        box-sizing: border-box;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .aki-steps,
    .aki-form-header,
    .aki-segment-actions,
    .aki-login {
        flex: 0 0 auto;
    }

    .aki-segment-form {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /*
     * CORREÇÃO PRINCIPAL:
     * no pacote v2.1 esta área usava overflow:hidden.
     */
    .aki-segment-groups {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto !important;
        overflow-x: hidden;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
        padding-right: 7px;
    }

    .aki-segment-groups::-webkit-scrollbar {
        width: 7px;
    }

    .aki-segment-groups::-webkit-scrollbar-track {
        background: transparent;
    }

    .aki-segment-groups::-webkit-scrollbar-thumb {
        background: rgba(100, 116, 139, 0.28);
        border-radius: 999px;
    }

    .aki-category-group:last-child {
        padding-bottom: 8px;
    }
}

/* Notebook 1366x768 e resoluções próximas. */
@media (min-width: 1100px) and (max-height: 850px) {
    .aki-register-page {
        grid-template-columns: minmax(390px, 39%) minmax(0, 1fr);
    }

    .aki-register-shell {
        padding-top: 16px;
        padding-bottom: 12px;
    }

    .aki-steps {
        margin-bottom: 9px;
    }

    .aki-form-header {
        margin-bottom: 7px;
    }

    .aki-form-header h2 {
        margin-bottom: 3px;
        font-size: clamp(27px, 2.3vw, 37px);
        line-height: 1.05;
    }

    .aki-form-header p {
        margin: 0;
        font-size: 12px;
        line-height: 1.35;
    }

    .aki-category {
        margin: 8px 0 5px;
        font-size: 10px;
        line-height: 1.2;
        letter-spacing: .07em;
    }

    .aki-niches {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 7px;
    }

    .aki-niche {
        min-height: 48px;
        padding: 7px 9px;
        border-radius: 11px;
        display: grid;
        grid-template-columns: 24px minmax(0, 1fr);
        align-items: center;
        gap: 7px;
        text-align: left;
    }

    .aki-niche-icon {
        margin: 0;
        font-size: 18px;
        line-height: 1;
    }

    .aki-niche-name {
        font-size: 10.5px;
        line-height: 1.12;
    }

    .aki-check {
        top: 4px;
        right: 4px;
        font-size: 11px;
    }

    .aki-segment-actions {
        margin-top: 8px;
    }

    .aki-segment-actions .aki-btn {
        min-height: 42px;
        padding: 10px 18px;
    }

    .aki-login {
        margin-top: 6px;
        font-size: 11px;
    }

    .aki-hero-copy h1 {
        font-size: clamp(38px, 4.2vw, 59px);
        line-height: .98;
    }

    .aki-hero-copy > p {
        font-size: 13px;
        line-height: 1.45;
    }
}

/* Monitores largos: mais colunas diminuem a necessidade de rolagem. */
@media (min-width: 1500px) and (max-height: 900px) {
    .aki-niches {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

/* Em telas realmente baixas, exibe também a pesquisa. */
@media (min-width: 1100px) and (max-height: 700px) {
    .aki-segment-search {
        display: block;
        flex: 0 0 auto;
        margin-bottom: 8px;
    }

    .aki-segment-search input {
        height: 37px;
        border-radius: 11px;
        font-size: 12px;
    }

    .aki-register-hero {
        padding-top: 22px;
        padding-bottom: 22px;
    }
}

/* Tablet: rolagem natural e duas colunas. */
@media (max-width: 1099px) {
    body {
        overflow: auto;
    }

    .aki-register-page {
        min-height: 100dvh;
        height: auto;
    }

    .aki-register-main,
    .aki-register-shell,
    .aki-segment-groups {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .aki-segment-search {
        display: block;
    }

    .aki-niches {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .aki-niche {
        min-height: 72px;
    }
}

/* Celular: uma coluna e botão acessível. */
@media (max-width: 640px) {
    .aki-register-hero {
        display: none;
    }

    .aki-register-main {
        width: 100%;
    }

    .aki-register-shell {
        padding: 20px 15px 28px;
    }

    .aki-form-header h2 {
        font-size: 28px;
    }

    .aki-niches {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .aki-niche {
        min-height: 62px;
        padding: 11px 13px;
        display: grid;
        grid-template-columns: 30px minmax(0, 1fr);
        align-items: center;
        gap: 10px;
        text-align: left;
    }

    .aki-niche-icon {
        margin: 0;
    }

    .aki-actions {
        position: sticky;
        bottom: 0;
        z-index: 10;
        padding: 10px 0 max(10px, env(safe-area-inset-bottom));
        background: linear-gradient(to top, #f7f9fc 72%, rgba(247, 249, 252, 0));
    }
}
