/* =============================================================
   Módulo legal · Banner / Modal de consentimiento
   Versión "elegante" — CSS standalone, sin dependencias.
   ============================================================= */

.legal-consent-modal,
.legal-consent-modal *,
.legal-consent-toggle,
.legal-consent-toggle * {
    box-sizing: border-box;
}

/* ============================================================
   Pantalla bloqueante
   ============================================================ */
.legal-consent-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", sans-serif;
    color: #1f2937;
    line-height: 1.55;
    animation: legal-fade-in .3s ease-out;
}
.legal-consent-modal[hidden] { display: none; }

.legal-consent-overlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 10%, rgba(99, 102, 241, 0.22), transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(139, 92, 246, 0.18), transparent 55%),
        rgba(15, 20, 30, 0.55);
    backdrop-filter: blur(6px) saturate(140%);
    -webkit-backdrop-filter: blur(6px) saturate(140%);
}

/* ============================================================
   Card
   ============================================================ */
.legal-consent-card {
    position: relative;
    background: #ffffff;
    border-radius: 22px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.5) inset,
        0 30px 80px rgba(15, 23, 42, 0.45),
        0 0 0 1px rgba(15, 23, 42, 0.05);
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: legal-pop-in .4s cubic-bezier(.2, .9, .25, 1.05);
}

/* ============================================================
   Hero (logo + título)
   ============================================================ */
.legal-consent-hero {
    position: relative;
    text-align: center;
    padding: 36px 28px 22px;
    background:
        linear-gradient(180deg, #fafbff 0%, #ffffff 100%);
    overflow: hidden;
}

.legal-consent-hero-glow {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 220px;
    background:
        radial-gradient(ellipse at center,
            rgba(99, 102, 241, 0.22) 0%,
            rgba(139, 92, 246, 0.12) 35%,
            transparent 70%);
    pointer-events: none;
    filter: blur(8px);
}

.legal-consent-logo {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}
.legal-consent-logo img {
    max-width: 160px;
    max-height: 64px;
    height: auto;
    width: auto;
    filter: drop-shadow(0 6px 16px rgba(79, 70, 229, 0.18));
}

.legal-consent-logo-fallback {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 30px;
    font-weight: 700;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.4);
}
.legal-consent-logo-fallback span { line-height: 1; }

.legal-consent-kicker {
    position: relative;
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #6366f1;
    opacity: 0.9;
}

.legal-consent-title {
    position: relative;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

/* ============================================================
   Body
   ============================================================ */
.legal-consent-body {
    padding: 4px 28px 28px;
    overflow-y: auto;
    flex: 1;
}

.legal-consent-intro {
    font-size: 14px;
    color: #475569;
    margin: 0 0 14px;
    text-align: center;
    line-height: 1.6;
}
.legal-consent-intro strong { color: #0f172a; font-weight: 600; }

.legal-consent-links {
    text-align: center;
    font-size: 12.5px;
    color: #94a3b8;
    margin: 0 0 22px;
}
.legal-consent-links a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
    transition: color .15s;
}
.legal-consent-links a:hover { color: #4338ca; text-decoration: underline; }
.legal-consent-links span { margin: 0 8px; opacity: .5; }

/* ============================================================
   Acciones (botones)
   ============================================================ */
.legal-consent-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.legal-consent-actions[data-view="main"]:not([hidden]),
.legal-consent-prefs[data-view="prefs"]:not([hidden]) {
    animation: legal-view-in .3s cubic-bezier(.2, .9, .25, 1);
}
@media (min-width: 480px) {
    .legal-consent-actions { grid-template-columns: 1fr 1fr 1fr; }
}
.legal-consent-actions[hidden] { display: none; }
.legal-consent-prefs[hidden] { display: none; }

.legal-consent-actions-bottom {
    grid-template-columns: 1fr 1.6fr;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #e5e7eb;
}

.legal-btn {
    appearance: none;
    border: 0;
    border-radius: 11px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.legal-btn:active { transform: translateY(1px); }
.legal-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}
.legal-btn-ico { font-size: 13px; opacity: .85; }

/* Primario: gradiente y sombra */
.legal-btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2) inset,
        0 6px 18px rgba(99, 102, 241, 0.45);
}
.legal-btn-primary:hover {
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.25) inset,
        0 10px 26px rgba(99, 102, 241, 0.55);
    transform: translateY(-1px);
}

/* Secundario: pálido */
.legal-btn-secondary {
    color: #1e293b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}
.legal-btn-secondary:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

/* Ghost: enlace con peso de botón */
.legal-btn-ghost {
    color: #475569;
    background: transparent;
    border: 1px solid transparent;
}
.legal-btn-ghost:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* ============================================================
   Categorías (tarjetas)
   ============================================================ */
.legal-consent-cat {
    display: block;
    padding: 14px 16px;
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fafafa;
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.legal-consent-cat:hover { border-color: #c7d2fe; background: #fff; box-shadow: 0 2px 8px rgba(99, 102, 241, 0.06); }
.legal-consent-cat.is-locked { cursor: default; background: #f8fafc; }
.legal-consent-cat.is-locked:hover { border-color: #e5e7eb; box-shadow: none; }

.legal-consent-cat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.legal-consent-cat-info { flex: 1; min-width: 0; }
.legal-consent-cat-info h3 {
    font-size: 14.5px;
    font-weight: 600;
    margin: 0 0 2px;
    color: #0f172a;
    letter-spacing: -0.01em;
}
.legal-consent-cat-info p {
    font-size: 12.5px;
    color: #64748b;
    margin: 0;
    line-height: 1.45;
}

.legal-consent-locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #15803d;
    background: #dcfce7;
    padding: 5px 10px;
    border-radius: 999px;
    flex-shrink: 0;
}

/* ============================================================
   Switch
   ============================================================ */
.legal-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
}
.legal-switch input {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0);
}
.legal-switch-track {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background .25s cubic-bezier(.4, 0, .2, 1);
    cursor: pointer;
}
.legal-switch-track::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), 0 1px 1px rgba(0, 0, 0, 0.06);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}
.legal-switch input:checked + .legal-switch-track {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.legal-switch input:checked + .legal-switch-track::after {
    transform: translateX(18px);
}
.legal-switch input:focus-visible + .legal-switch-track {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

/* ============================================================
   Botón flotante
   ============================================================ */
.legal-consent-toggle {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 2147482000;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.25) inset,
        0 8px 22px rgba(99, 102, 241, 0.45);
    transition: transform .2s, box-shadow .2s;
}
.legal-consent-toggle:hover {
    transform: scale(1.08) rotate(-8deg);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.3) inset,
        0 12px 28px rgba(99, 102, 241, 0.6);
}
.legal-consent-toggle:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 3px;
}
.legal-consent-toggle[hidden] { display: none; }

/* ============================================================
   Accesibilidad y animaciones
   ============================================================ */
.sr-only {
    position: absolute;
    width: 1px; height: 1px; padding: 0;
    margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@keyframes legal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes legal-pop-in {
    0%   { opacity: 0; transform: translateY(20px) scale(.96); }
    60%  { opacity: 1; }
    100% { opacity: 1; transform: none; }
}
@keyframes legal-view-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .legal-consent-modal,
    .legal-consent-card,
    .legal-consent-actions,
    .legal-consent-prefs { animation: none !important; }
    .legal-btn:hover, .legal-consent-toggle:hover { transform: none !important; }
}

/* ============================================================
   Modo oscuro automático
   ============================================================ */
@media (prefers-color-scheme: dark) {
    .legal-consent-card {
        background: #0f172a;
        box-shadow:
            0 1px 0 rgba(255, 255, 255, 0.04) inset,
            0 30px 80px rgba(0, 0, 0, 0.65),
            0 0 0 1px rgba(255, 255, 255, 0.04);
    }
    .legal-consent-hero {
        background: linear-gradient(180deg, #131b30 0%, #0f172a 100%);
    }
    .legal-consent-hero-glow {
        background: radial-gradient(ellipse at center,
            rgba(99, 102, 241, 0.32) 0%,
            rgba(139, 92, 246, 0.18) 35%,
            transparent 70%);
    }
    .legal-consent-title { color: #f8fafc; }
    .legal-consent-kicker { color: #a5b4fc; }
    .legal-consent-intro { color: #cbd5e1; }
    .legal-consent-intro strong { color: #f8fafc; }
    .legal-consent-links { color: #64748b; }
    .legal-consent-links a { color: #a5b4fc; }
    .legal-consent-links a:hover { color: #c7d2fe; }
    .legal-consent-cat {
        background: #131b30;
        border-color: #1e293b;
    }
    .legal-consent-cat:hover {
        background: #1a2238;
        border-color: #4338ca;
        box-shadow: 0 2px 12px rgba(99, 102, 241, 0.18);
    }
    .legal-consent-cat.is-locked { background: #131b30; }
    .legal-consent-cat-info h3 { color: #f8fafc; }
    .legal-consent-cat-info p { color: #94a3b8; }
    .legal-consent-locked-badge {
        background: rgba(34, 197, 94, 0.15);
        color: #4ade80;
    }
    .legal-consent-actions-bottom { border-top-color: #1e293b; }
    .legal-btn-secondary {
        background: #1e293b;
        color: #f1f5f9;
        border-color: #334155;
    }
    .legal-btn-secondary:hover { background: #334155; border-color: #475569; }
    .legal-btn-ghost { color: #94a3b8; }
    .legal-btn-ghost:hover { background: #1e293b; color: #f1f5f9; }
    .legal-switch-track { background: #475569; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 380px) {
    .legal-consent-actions:not(.legal-consent-actions-bottom) {
        grid-template-columns: 1fr;
    }
    .legal-consent-actions-bottom {
        grid-template-columns: 1fr;
    }
}
