/* ===== AVISO DE COOKIES - PROTECOMPU ===== */

/* ---------- FONDO ---------- */
.fondo-aviso-cookies {
    display: none;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    position: fixed;
    z-index: 9999;
    width: 100vw;
    height: 100vh;
    top: 0; left: 0;
    transition: opacity 0.3s ease;
}
.fondo-aviso-cookies.activo { display: block; animation: fadeIn 0.3s ease; }

/* ---------- BANNER SIMPLE ---------- */
.aviso-cookies {
    display: none;
    background: var(--bg-primary, #fff);
    padding: 1.5rem;
    width: calc(100% - 40px);
    max-width: 380px;
    border-radius: 16px;
    position: fixed;
    bottom: 20px; left: 20px;
    z-index: 10000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border: 1px solid rgba(19,133,121,0.1);
}
.aviso-cookies.activo { display: block; animation: slideUp 0.4s ease; }

.aviso-cookies .galleta {
    max-width: 80px;
    margin: 0 auto 1rem;
    display: block;
    animation: bounce 2s ease infinite;
}
.aviso-cookies .titulo {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-size: 1.25rem; font-weight: 700;
    color: var(--text-primary, #1a1a1a);
    margin-bottom: 0.75rem; text-align: center;
}
.aviso-cookies .parrafo {
    font-size: 0.9rem; color: var(--text-secondary, #666);
    margin-bottom: 1.25rem; text-align: center; line-height: 1.6;
}

/* Botones del banner */
.cookie-btns {
    display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem;
}
.cookie-btns .boton {
    width: 100%; border: none; font-weight: 600; cursor: pointer;
    padding: 0.8rem 1.5rem; border-radius: 8px; font-size: 0.9rem;
    transition: all 0.2s ease;
}
.boton-aceptar {
    background: linear-gradient(135deg, #138579, #0d6b61);
    color: #fff;
    box-shadow: 0 4px 12px rgba(19,133,121,0.3);
}
.boton-aceptar:hover { background: linear-gradient(135deg,#0d6b61,#0a5650); transform: translateY(-1px); }

.boton-rechazar {
    background: #1a1a2e; color: #fff;
}
.boton-rechazar:hover { background: #2d2d4a; transform: translateY(-1px); }

.boton-personalizar {
    background: transparent; color: #138579;
    border: 1.5px solid #138579 !important;
    font-size: 0.875rem !important; padding: 0.65rem 1rem !important;
}
.boton-personalizar:hover { background: rgba(19,133,121,0.06); }

.aviso-cookies .enlace {
    color: #138579; text-decoration: none; font-size: 0.8rem;
    font-weight: 500; display: block; text-align: center;
}
.aviso-cookies .enlace:hover { text-decoration: underline; }

/* ---------- MODAL DE PREFERENCIAS ---------- */
.modal-cookies {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(540px, calc(100vw - 32px));
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    z-index: 10001;
    animation: modalIn 0.35s ease;
}
.modal-cookies.activo { display: block; }

@keyframes modalIn {
    from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.5rem 1.75rem 1.25rem;
    border-bottom: 1px solid #eee;
}
.modal-header h3 {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-size: 1.2rem; font-weight: 700; color: #1a1a1a; margin: 0;
}
.modal-cerrar {
    background: none; border: none; cursor: pointer;
    color: #888; padding: 0.25rem; border-radius: 6px;
    transition: all 0.2s; line-height: 1;
}
.modal-cerrar:hover { background: #f0f0f0; color: #333; }

.modal-body { padding: 1.5rem 1.75rem; }

.modal-intro { font-size: 0.9rem; color: #555; line-height: 1.6; margin-bottom: 0.5rem; }
.modal-intro a { color: #138579; }
.modal-ver-mas { font-size: 0.85rem; color: #138579; cursor: pointer; font-weight: 600; }

/* Categorías */
.categorias { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 1px; }

.cat-item {
    border: 1px solid #e5e5e5; border-radius: 10px;
    overflow: hidden; margin-bottom: 6px;
}
.cat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; cursor: pointer;
    background: #fafafa; transition: background 0.2s;
    user-select: none;
}
.cat-header:hover { background: #f0f0f0; }

.cat-header-left { display: flex; align-items: center; gap: 0.6rem; }
.cat-chevron {
    color: #888; transition: transform 0.25s ease; flex-shrink: 0;
}
.cat-item.abierta .cat-chevron { transform: rotate(90deg); }

.cat-nombre {
    font-weight: 700; font-size: 0.975rem; color: #1a1a1a;
}
.cat-siempre {
    font-size: 0.8rem; font-weight: 700; color: #138579;
}

.cat-desc {
    display: none; padding: 0.75rem 1.25rem 1rem;
    font-size: 0.875rem; color: #555; line-height: 1.6;
    border-top: 1px solid #eee; background: #fff;
}
.cat-item.abierta .cat-desc { display: block; }

/* Toggle switch */
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
    position: absolute; inset: 0; background: #ccc; border-radius: 24px;
    cursor: pointer; transition: background 0.25s;
}
.toggle-track::before {
    content: ''; position: absolute;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; top: 3px; left: 3px;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-track { background: #138579; }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(20px); }
.toggle-switch input:disabled + .toggle-track { background: #a0a0a0; cursor: not-allowed; }

/* Botones del modal */
.modal-footer {
    display: flex; gap: 0.75rem; flex-wrap: wrap;
    padding: 1.25rem 1.75rem;
    border-top: 1px solid #eee;
}
.modal-footer button {
    flex: 1; min-width: 130px; padding: 0.8rem;
    border-radius: 8px; font-size: 0.875rem; font-weight: 600;
    cursor: pointer; border: none; transition: all 0.2s;
}
#modal-btn-rechazar {
    background: #1a1a2e; color: #fff;
}
#modal-btn-rechazar:hover { background: #2d2d4a; }

#modal-btn-guardar {
    background: transparent; color: #138579;
    border: 1.5px solid #138579 !important;
}
#modal-btn-guardar:hover { background: rgba(19,133,121,0.06); }

#modal-btn-aceptar {
    background: linear-gradient(135deg, #138579, #0d6b61);
    color: #fff; box-shadow: 0 4px 12px rgba(19,133,121,0.25);
}
#modal-btn-aceptar:hover { filter: brightness(1.05); }

/* ---------- ANIMACIONES COMPARTIDAS ---------- */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; } to { opacity: 1; }
}
@keyframes bounce {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
    .aviso-cookies { max-width: calc(100% - 40px); left: 20px; right: 20px; }
    .modal-footer { flex-direction: column; }
    .modal-footer button { min-width: unset; }
}

/* ---------- TEMA OSCURO ---------- */
[data-theme="dark"] .aviso-cookies,
[data-theme="dark"] .modal-cookies {
    background: var(--bg-secondary, #1a1a1a);
    border-color: rgba(19,133,121,0.2);
}
[data-theme="dark"] .cat-header { background: #222; }
[data-theme="dark"] .cat-header:hover { background: #2a2a2a; }

/* ---------- BOTÓN FLOTANTE GESTIONAR COOKIES ---------- */
.cookie-float-btn {
    position: fixed;
    bottom: 90px;
    left: 24px;
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: #fff;
    color: #138579;
    border: 1.5px solid rgba(19, 133, 121, 0.3);
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transition: all 0.25s ease;
    font-family: var(--font-primary, sans-serif);
}
.cookie-float-btn:hover {
    background: #138579;
    color: #fff;
    border-color: #138579;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(19,133,121,0.3);
}
.cookie-float-btn svg {
    flex-shrink: 0;
    transition: transform 0.25s;
}
.cookie-float-btn:hover svg {
    transform: rotate(20deg);
}

/* Se oculta cuando el banner está activo para no chocar */
.aviso-cookies.activo ~ .cookie-float-btn,
body.cookies-banner-activo .cookie-float-btn {
    opacity: 0;
    pointer-events: none;
}

/* Enlace de cookies en footer */
.footer-cookie-link {
    background: none;
    border: none;
    color: rgba(255,255,255,0.55);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
    font-family: inherit;
    margin-left: 1.25rem;
}
.footer-cookie-link:hover {
    color: #fff;
    text-decoration: underline;
}

/* En móvil el botón flotante es más compacto */
@media (max-width: 768px) {
    .cookie-float-btn span { display: none; }
    .cookie-float-btn { padding: 0.65rem; border-radius: 50%; }
}