/* =============================================
   COOKIE CONSENT — GDPR + LSSI-CE
   Usa tokens de color de style.css (:root)
============================================= */

/* ── Banner principal ───────────────────────── */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-base);
    border-top: 2px solid var(--primary);
    box-shadow: 0 -8px 40px var(--shadow-lg);
    z-index: 99990;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.cookie-banner--visible {
    transform: translateY(0);
}

.cookie-banner__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-banner__icon {
    font-size: 28px;
    flex-shrink: 0;
    display: none; /* visible solo en desktop */
}

.cookie-banner__text {
    flex: 1;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
    min-width: 220px;
}

.cookie-banner__text a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid rgba(254, 214, 0, 0.30);
    transition: border-color 0.2s;
}

.cookie-banner__text a:hover {
    border-bottom-color: var(--accent);
}

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

/* ── Botones de cookies ─────────────────────── */
.cookie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
    font-family: inherit;
}

/* Aceptar — rojo primario */
.cookie-btn--primary {
    background: var(--primary);
    color: var(--text-on-dark);
    box-shadow: 0 0 16px var(--primary-glow);
}

.cookie-btn--primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 24px var(--primary-glow-lg);
    transform: translateY(-1px);
}

/* Rechazar — contorno */
.cookie-btn--outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border-mid);
}

.cookie-btn--outline:hover {
    background: var(--glass);
    color: var(--text-on-dark);
    border-color: var(--border-strong);
}

/* Personalizar — texto tenue */
.cookie-btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    padding: 10px 12px;
}

.cookie-btn--ghost:hover {
    color: var(--text);
    background: var(--glass);
}

/* ── Modal de preferencias ──────────────────── */
.cookie-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.cookie-modal--visible {
    opacity: 1;
    pointer-events: all;
}

.cookie-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
}

.cookie-modal__box {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 12px;
    padding: 36px 32px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.cookie-modal--visible .cookie-modal__box {
    transform: translateY(0);
}

.cookie-modal__close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    transition: color 0.2s;
    font-family: inherit;
}

.cookie-modal__close:hover {
    color: var(--primary);
}

.cookie-modal__box h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-on-dark);
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.cookie-modal__box > p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 24px;
    line-height: 1.6;
}

/* ── Categorías de cookies ──────────────────── */
.cookie-category {
    border-top: 1px solid var(--border);
    padding: 18px 0;
}

.cookie-category:last-of-type {
    border-bottom: 1px solid var(--border);
}

.cookie-category__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.cookie-category__header > div:first-child {
    flex: 1;
}

.cookie-category h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-on-dark);
    margin: 0 0 4px;
}

.cookie-category p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ── Toggle switch ──────────────────────────── */
.cookie-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.cookie-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.cookie-toggle__slider {
    display: block;
    width: 46px;
    height: 26px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 13px;
    transition: background 0.25s ease, border-color 0.25s ease;
    position: relative;
}

.cookie-toggle__slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.40);
    border-radius: 50%;
    transition: transform 0.25s ease, background 0.25s ease;
}

.cookie-toggle input:checked + .cookie-toggle__slider {
    background: var(--primary);
    border-color: var(--primary);
}

.cookie-toggle input:checked + .cookie-toggle__slider::after {
    transform: translateX(20px);
    background: var(--text-on-dark);
}

.cookie-toggle input:focus-visible + .cookie-toggle__slider {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Toggle desactivado (Necesarias) */
.cookie-toggle--disabled {
    cursor: default;
}

.cookie-toggle--disabled span {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

/* ── Acciones del modal ─────────────────────── */
.cookie-modal__actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Botón flotante reabrir ─────────────────── */
.cookie-reopen {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 42px;
    height: 42px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    box-shadow: 0 4px 16px var(--shadow-md);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.cookie-reopen svg {
    display: block;
    flex-shrink: 0;
}

.cookie-reopen:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-on-dark);
    transform: scale(1.1);
}

/* Bloquear scroll cuando modal abierto */
body.cookie-modal-open {
    overflow: hidden;
}

/* ── Responsive ─────────────────────────────── */
@media (min-width: 769px) {
    .cookie-banner__icon {
        display: block;
    }

    .cookie-banner__actions {
        flex-wrap: nowrap;
    }
}

@media (max-width: 768px) {
    .cookie-banner__inner {
        padding: 16px 16px env(safe-area-inset-bottom, 16px);
        gap: 14px;
    }

    .cookie-banner__text {
        font-size: 12px;
    }

    .cookie-banner__actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* Aceptar ocupa el ancho completo */
    .cookie-btn--primary {
        grid-column: 1 / -1;
        padding: 12px;
        font-size: 14px;
    }

    .cookie-btn--outline,
    .cookie-btn--ghost {
        font-size: 12px;
        padding: 9px 12px;
    }

    .cookie-modal__box {
        padding: 28px 20px;
        border-radius: 10px;
        margin: 0;
    }

    .cookie-reopen {
        bottom: 100px; /* por encima del botón de llamar fijo */
    }
}
