/* ═══════════════════════════════════════════════════════
   Cookie Consent Manager — Operação Escola
   Self-hosted, RGPD compliant, dark-themed
   ═══════════════════════════════════════════════════════ */

/* ── Variables (match the site design system) ─────────── */
:root {
    --cc-bg: #0f0f1a;
    --cc-surface: #1a1a2e;
    --cc-border: rgba(124, 92, 252, 0.25);
    --cc-accent: #7c5cfc;
    --cc-accent-hover: #9a7fff;
    --cc-green: #10b981;
    --cc-text: #e2e8f0;
    --cc-muted: #8892a4;
    --cc-radius: 14px;
    --cc-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    --cc-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Backdrop (for modal) ─────────────────────────────── */
#cc-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity var(--cc-transition);
}

#cc-backdrop.visible {
    opacity: 1;
}

/* ── Banner ────────────────────────────────────────────── */
#cc-banner {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    width: min(720px, calc(100vw - 2rem));
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    box-shadow: var(--cc-shadow);
    padding: 1.5rem 1.75rem;
    z-index: 9999;
    transition: transform var(--cc-transition);
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

#cc-banner.visible {
    transform: translateX(-50%) translateY(0);
}

.cc-banner-icon {
    font-size: 2rem;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(124, 92, 252, 0.5));
}

.cc-banner-text {
    flex: 1;
    min-width: 200px;
}

.cc-banner-text h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--cc-text);
}

.cc-banner-text p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--cc-muted);
    line-height: 1.55;
}

.cc-banner-text a {
    color: var(--cc-accent);
    text-decoration: none;
}

.cc-banner-text a:hover {
    text-decoration: underline;
}

.cc-banner-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────── */
.cc-btn {
    padding: 0.55rem 1.2rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.cc-btn-primary {
    background: var(--cc-accent);
    color: #fff;
}

.cc-btn-primary:hover {
    background: var(--cc-accent-hover);
    transform: translateY(-1px);
}

.cc-btn-secondary {
    background: transparent;
    color: var(--cc-muted);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.cc-btn-secondary:hover {
    border-color: var(--cc-accent);
    color: var(--cc-text);
}

.cc-btn-ghost {
    background: transparent;
    color: var(--cc-muted);
    padding: 0.55rem 0.8rem;
    font-size: 0.78rem;
}

.cc-btn-ghost:hover {
    color: var(--cc-text);
}

/* ── Modal ─────────────────────────────────────────────── */
#cc-modal {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

#cc-modal.open {
    display: flex;
}

#cc-modal-box {
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    box-shadow: var(--cc-shadow);
    width: min(560px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: ccSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ccSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cc-modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.4rem 1.6rem 1rem;
    border-bottom: 1px solid var(--cc-border);
}

.cc-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cc-text);
}

.cc-modal-body {
    padding: 1.2rem 1.6rem;
    overflow-y: auto;
    flex: 1;
}

.cc-modal-footer {
    padding: 1rem 1.6rem 1.4rem;
    border-top: 1px solid var(--cc-border);
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ── Category rows ────────────────────────────────────── */
.cc-category {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cc-category:last-child {
    border-bottom: none;
}

.cc-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.cc-category-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--cc-text);
}

.cc-category-description {
    font-size: 0.78rem;
    color: var(--cc-muted);
    line-height: 1.55;
}

.cc-always-on {
    font-size: 0.72rem;
    color: var(--cc-green);
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
}

/* ── Toggle switch ────────────────────────────────────── */
.cc-toggle {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.cc-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.cc-toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    cursor: pointer;
    transition: background 0.2s;
}

.cc-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.cc-toggle input:checked+.cc-toggle-slider {
    background: var(--cc-accent);
}

.cc-toggle input:checked+.cc-toggle-slider::before {
    transform: translateX(18px);
}

/* ── Cookie badge (re-open) ───────────────────────────── */
#cc-badge {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 42px;
    height: 42px;
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9997;
    font-size: 1.2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: all 0.2s;
}

#cc-badge:hover {
    transform: scale(1.1);
    border-color: var(--cc-accent);
}

#cc-badge.show {
    display: flex;
}

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 520px) {
    #cc-banner {
        flex-direction: column;
        align-items: flex-start;
        padding: 1.2rem;
        bottom: 0.75rem;
    }

    .cc-banner-actions {
        width: 100%;
    }

    .cc-btn {
        flex: 1;
        text-align: center;
    }
}