/* =========================================================
   COOKIE CONSENT - ESTILO COMPARTILHADO
   ---------------------------------------------------------
   Este arquivo deve ser carregado no FINAL do <head>, depois
   do css/style.css e de qualquer <style> inline da pagina,
   para sobrescrever versoes antigas do banner de cookies.

   O aviso de cookies e exibido como um MODAL centralizado,
   com rolagem interna quando o conteudo nao couber na tela.
   ========================================================= */

/* ---------------------------------------------------------
   RESET LOCAL
   --------------------------------------------------------- */

#cookie-consent,
#cookie-consent *,
#cookie-settings-overlay,
#cookie-settings-overlay * {
    box-sizing: border-box;
}


/* =========================================================
   AVISO DE COOKIES (MODAL CENTRALIZADO)
   ========================================================= */

#cookie-consent {
    position: fixed;

    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;

    transform: translate(-50%, -50%);

    z-index: 99999;

    width: calc(100% - 32px);
    max-width: 620px;

    /* Garante rolagem interna em telas pequenas */
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);

    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 14px;

    padding: 26px 28px;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    text-align: left;

    /* O primeiro box-shadow funciona como fundo escurecido */
    box-shadow:
        0 0 0 100vmax rgba(15, 23, 42, 0.55),
        0 20px 60px rgba(0, 0, 0, 0.30);

    display: none;
}

#cookie-consent.cookie-visible {
    display: block;
}

.cookie-container {
    display: block;

    max-width: none;
    margin: 0;
}

.cookie-content {
    flex: none;
    width: 100%;
}

.cookie-title {
    margin: 0 0 10px 0;

    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;

    color: #1f2937;
}

.cookie-text {
    margin: 0;

    font-size: 14px;
    line-height: 1.6;

    color: #4b5563;
}

.cookie-text a {
    color: #2f4a6d;
    font-weight: 600;
    text-decoration: underline;
}


/* =========================================================
   BOTOES
   ========================================================= */

.cookie-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;

    margin-top: 20px;
}

.cookie-btn {
    /* Reset: evita deformacao causada por estilos globais */
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    width: auto;
    min-width: 0;
    height: auto;

    margin: 0;
    padding: 11px 18px;

    border: 1px solid transparent;
    border-radius: 8px;

    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: normal;
    text-transform: none;
    text-align: center;
    white-space: nowrap;
    text-decoration: none;

    cursor: pointer;
    box-shadow: none;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.1s ease;
}

.cookie-btn:hover {
    transform: translateY(-1px);
}

.cookie-btn:active {
    transform: translateY(0);
}

.cookie-btn:focus-visible {
    outline: 3px solid rgba(47, 74, 109, 0.45);
    outline-offset: 2px;
}

.cookie-btn-primary {
    background: #2f4a6d;
    border-color: #2f4a6d;
    color: #ffffff;
}

.cookie-btn-primary:hover {
    background: #263e5b;
    border-color: #263e5b;
}

.cookie-btn-secondary {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #374151;
}

.cookie-btn-secondary:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.cookie-btn-outline {
    background: #ffffff;
    border-color: #2f4a6d;
    color: #2f4a6d;
}

.cookie-btn-outline:hover {
    background: #f3f6fa;
}


/* =========================================================
   OVERLAY DO MODAL DE CONFIGURACOES
   ========================================================= */

#cookie-settings-overlay {
    position: fixed;

    inset: 0;

    z-index: 100000;

    background: rgba(0, 0, 0, 0.55);

    display: none;

    align-items: center;
    justify-content: center;

    padding: 20px;

    overflow-y: auto;
}

#cookie-settings-overlay.cookie-modal-visible {
    display: flex;
}


/* =========================================================
   MODAL DE CONFIGURACOES
   ========================================================= */

.cookie-modal {
    width: 100%;
    max-width: 650px;

    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);

    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    background: #ffffff;

    border-radius: 12px;

    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    text-align: left;
}

.cookie-modal-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;

    padding: 22px 25px;

    border-bottom: 1px solid #e5e7eb;
}

.cookie-modal-header h2 {
    margin: 0;

    font-size: 21px;

    color: #1f2937;
}

.cookie-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    width: 40px;
    height: 40px;

    border: none;
    border-radius: 8px;

    background: transparent;

    font-family: inherit;
    font-size: 27px;
    line-height: 1;

    color: #6b7280;

    cursor: pointer;
    padding: 0;
}

.cookie-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.cookie-modal-body {
    padding: 25px;
}

.cookie-modal-description {
    margin-top: 0;
    margin-bottom: 22px;

    color: #4b5563;

    font-size: 14px;
    line-height: 1.6;
}


/* =========================================================
   CATEGORIAS
   ========================================================= */

.cookie-category {
    border: 1px solid #e5e7eb;

    border-radius: 8px;

    margin-bottom: 12px;

    overflow: hidden;
}

.cookie-category-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;

    padding: 15px 17px;

    background: #f9fafb;
}

.cookie-category-title {
    font-weight: 700;

    color: #1f2937;

    font-size: 15px;
}

.cookie-category-description {
    padding: 0 17px 15px;

    margin: 0;

    font-size: 13px;

    line-height: 1.5;

    color: #6b7280;
}

.cookie-always-active {
    font-size: 12px;

    color: #16a34a;

    font-weight: 600;
}


/* =========================================================
   SWITCH
   ========================================================= */

.cookie-switch {
    position: relative;

    display: inline-block;

    width: 46px;
    height: 25px;

    flex-shrink: 0;
}

.cookie-switch input {
    opacity: 0;

    width: 0;
    height: 0;
}

.cookie-slider {
    position: absolute;

    cursor: pointer;

    inset: 0;

    background: #d1d5db;

    border-radius: 30px;

    transition: 0.2s;
}

.cookie-slider::before {
    content: "";

    position: absolute;

    width: 19px;
    height: 19px;

    left: 3px;
    top: 3px;

    background: #ffffff;

    border-radius: 50%;

    transition: 0.2s;

    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.cookie-switch input:checked + .cookie-slider {
    background: #2f4a6d;
}

.cookie-switch input:checked + .cookie-slider::before {
    transform: translateX(21px);
}

.cookie-switch input:disabled + .cookie-slider {
    background: #9ca3af;

    cursor: not-allowed;
}


/* =========================================================
   RODAPE DO MODAL
   ========================================================= */

.cookie-modal-footer {
    display: flex;
    flex-wrap: wrap;

    justify-content: flex-end;

    gap: 10px;

    padding: 18px 25px;

    border-top: 1px solid #e5e7eb;

    background: #f9fafb;
}


/* =========================================================
   RESPONSIVO
   ========================================================= */

@media (max-width: 640px) {

    #cookie-consent {
        width: calc(100% - 20px);

        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);

        padding: 20px;
        border-radius: 12px;
    }

    .cookie-title {
        font-size: 17px;
    }

    .cookie-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .cookie-btn {
        flex: 0 0 auto;

        width: 100%;
        white-space: normal;
    }

    #cookie-settings-overlay {
        padding: 10px;
    }

    .cookie-modal {
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
    }

    .cookie-modal-header {
        padding: 16px 18px;
    }

    .cookie-modal-body {
        padding: 18px;
    }

    .cookie-modal-footer {
        padding: 15px 18px;

        flex-direction: column;
    }

    .cookie-modal-footer .cookie-btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {

    .cookie-btn,
    .cookie-slider,
    .cookie-slider::before {
        transition: none;
    }

    .cookie-btn:hover {
        transform: none;
    }
}
