/* ==========================================================================
   Cookie Consent — banner + modal de preferências (LGPD)
   Isolado e carregado globalmente em head.inc.php.
   ========================================================================== */

:root {
    --cc-primary: var(--color-primary, #0432A9);
    --cc-primary-dark: #032680;
    --cc-text: #1f2733;
    --cc-muted: #5b6675;
    --cc-border: #e2e6ee;
    --cc-radius: 14px;
}

/* ---------- Banner ---------- */
.cookie-consent {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translate(-50%, 160%);
    width: min(1100px, calc(100% - 32px));
    background: #fff;
    color: var(--cc-text);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    box-shadow: 0 18px 50px rgba(4, 50, 169, 0.18);
    z-index: 1080;
    opacity: 0;
    visibility: hidden;
    transition: transform .35s ease, opacity .35s ease, visibility .35s ease;
}

.cookie-consent.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
}

.cookie-consent__inner {
    display: flex;
    align-items: center;
    gap: 18px 24px;
    flex-wrap: wrap;
    padding: 20px 24px;
}

.cookie-consent__text { flex: 1 1 360px; min-width: 0; }

.cookie-consent__title {
    margin: 0 0 4px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--cc-primary);
}

.cookie-consent__desc {
    margin: 0;
    font-size: .92rem;
    line-height: 1.5;
    color: var(--cc-muted);
}

.cookie-consent__link {
    color: var(--cc-primary);
    font-weight: 600;
    text-decoration: underline;
    white-space: nowrap;
}

.cookie-consent__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ---------- Botões ---------- */
.cookie-btn {
    font: inherit;
    font-weight: 600;
    font-size: .9rem;
    line-height: 1;
    padding: 12px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .1s ease;
    white-space: nowrap;
}
.cookie-btn:active { transform: translateY(1px); }

.cookie-btn--primary { background: var(--cc-primary); color: #fff; }
.cookie-btn--primary:hover { background: var(--cc-primary-dark); }

.cookie-btn--outline { background: #fff; color: var(--cc-primary); border-color: var(--cc-primary); }
.cookie-btn--outline:hover { background: rgba(4, 50, 169, .06); }

.cookie-btn--ghost { background: transparent; color: var(--cc-muted); border-color: transparent; text-decoration: underline; }
.cookie-btn--ghost:hover { color: var(--cc-text); }

/* ---------- Modal de preferências ---------- */
.cookie-prefs {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.cookie-prefs.is-open { display: flex; }

.cookie-prefs__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 16, 40, .55);
    backdrop-filter: blur(2px);
}

.cookie-prefs__dialog {
    position: relative;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
    width: min(620px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 28px 28px 24px;
    animation: ccPop .25s ease;
}
@keyframes ccPop { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.cookie-prefs__close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--cc-muted);
    cursor: pointer;
    border-radius: 8px;
}
.cookie-prefs__close:hover { background: #f1f3f8; color: var(--cc-text); }

.cookie-prefs__title { margin: 0 0 6px; font-size: 1.35rem; font-weight: 700; color: var(--cc-primary); }
.cookie-prefs__intro { margin: 0 0 18px; font-size: .92rem; color: var(--cc-muted); line-height: 1.5; }

.cookie-prefs__group { display: flex; flex-direction: column; gap: 4px; }

.cookie-prefs__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-top: 1px solid var(--cc-border);
}
.cookie-prefs__info { flex: 1 1 auto; min-width: 0; }
.cookie-prefs__cat { margin: 0 0 3px; font-size: 1rem; font-weight: 700; color: var(--cc-text); }
.cookie-prefs__catdesc { margin: 0; font-size: .85rem; color: var(--cc-muted); line-height: 1.45; }

.cookie-prefs__always {
    flex: 0 0 auto;
    font-size: .82rem;
    font-weight: 600;
    color: #2e7d32;
    background: #e8f5e9;
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.cookie-prefs__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
}

/* ---------- Toggle switch ---------- */
.cookie-switch { position: relative; display: inline-block; width: 50px; height: 28px; flex: 0 0 auto; }
.cookie-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.cookie-switch__slider {
    position: absolute;
    inset: 0;
    background: #c6ccd8;
    border-radius: 999px;
    transition: background .2s ease;
}
.cookie-switch__slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.cookie-switch input:checked + .cookie-switch__slider { background: var(--cc-primary); }
.cookie-switch input:checked + .cookie-switch__slider::before { transform: translateX(22px); }
.cookie-switch input:focus-visible + .cookie-switch__slider { outline: 2px solid var(--cc-primary); outline-offset: 2px; }

/* ---------- Toast ---------- */
.cookie-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 200%);
    background: #1f2733;
    color: #fff;
    font-size: .9rem;
    font-weight: 600;
    padding: 12px 22px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    z-index: 1095;
    opacity: 0;
    transition: transform .3s ease, opacity .3s ease;
}
.cookie-toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Utilitário ---------- */
body.cookie-no-scroll { overflow: hidden; }

/* ---------- Responsivo ---------- */
@media (max-width: 575px) {
    .cookie-consent { bottom: 0; width: 100%; border-radius: 16px 16px 0 0; }
    .cookie-consent__inner { padding: 18px 18px 20px; }
    .cookie-consent__actions { width: 100%; }
    .cookie-consent__actions .cookie-btn { flex: 1 1 auto; text-align: center; }
    .cookie-prefs__actions { justify-content: stretch; }
    .cookie-prefs__actions .cookie-btn { flex: 1 1 auto; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    .cookie-consent, .cookie-toast, .cookie-switch__slider::before { transition: none; }
    .cookie-prefs__dialog { animation: none; }
}
