/* =============================================================================
   TitanShield Cookie Consent (CNIL/RGPD compliant)
   - Banner: Accept all / Reject all / Customize  (3 buttons, equal weight)
   - Customize panel: per-category toggle (Essential locked on)
   - localStorage key: ts_cookie_consent_v1
   - Re-show after 13 months (CNIL guideline)
   No tracking, no third party. EU-sovereign.
   ============================================================================= */

#ts-cc-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1100; /* above legacy cookie-notice (1000) */
    background: #0f172a;
    color: #e2e8f0;
    border-top: 2px solid #4f46e5;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
    display: none;
    padding: 1rem 1.5rem;
    font-size: 0.95rem;
    line-height: 1.45;
}

#ts-cc-banner.ts-cc-show { display: block; }

.ts-cc-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
}

.ts-cc-text {
    flex: 1 1 320px;
    min-width: 0;
}

.ts-cc-text strong { color: #fff; }

.ts-cc-text a {
    color: #818cf8;
    text-decoration: underline;
}

.ts-cc-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.ts-cc-btn {
    background: #4f46e5;
    color: #fff;
    border: 1px solid #4f46e5;
    padding: 0.55rem 1.1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 120ms, border-color 120ms;
    min-width: 110px;
}

.ts-cc-btn:hover { background: #4338ca; border-color: #4338ca; }

.ts-cc-btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #e2e8f0;
}

.ts-cc-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.6);
}

.ts-cc-btn-tertiary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
}

.ts-cc-btn-tertiary:hover { color: #fff; border-color: rgba(255, 255, 255, 0.5); }

/* ---- Customize panel (modal-like) ---- */
#ts-cc-customize {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#ts-cc-customize.ts-cc-show { display: flex; }

.ts-cc-panel {
    background: #fff;
    color: #0f172a;
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .ts-cc-panel {
    background: #1e293b;
    color: #e2e8f0;
}

.ts-cc-panel h2 {
    font-size: 1.4rem;
    margin: 0 0 0.5rem 0;
}

.ts-cc-panel-intro {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 1.25rem;
}

[data-theme="dark"] .ts-cc-panel-intro { color: #cbd5e1; }

.ts-cc-cat {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.65rem;
}

[data-theme="dark"] .ts-cc-cat { border-color: #334155; }

.ts-cc-cat-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.ts-cc-cat-name {
    font-weight: 600;
    font-size: 1rem;
}

.ts-cc-cat-desc {
    font-size: 0.85rem;
    color: #475569;
    margin-top: 0.35rem;
}

[data-theme="dark"] .ts-cc-cat-desc { color: #94a3b8; }

.ts-cc-cat-locked {
    color: #4f46e5;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Toggle switch */
.ts-cc-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.ts-cc-toggle input { opacity: 0; width: 0; height: 0; }

.ts-cc-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    border-radius: 24px;
    transition: background 120ms;
}

.ts-cc-toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 120ms;
}

.ts-cc-toggle input:checked + .ts-cc-toggle-slider { background: #4f46e5; }
.ts-cc-toggle input:checked + .ts-cc-toggle-slider::before { transform: translateX(20px); }
.ts-cc-toggle input:disabled + .ts-cc-toggle-slider { opacity: 0.5; cursor: not-allowed; }

.ts-cc-panel-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .ts-cc-actions { width: 100%; }
    .ts-cc-actions .ts-cc-btn { flex: 1 1 auto; min-width: 0; }
    .ts-cc-panel-actions .ts-cc-btn { flex: 1 1 auto; min-width: 0; }
}

body.ts-cc-banner-visible { padding-bottom: 140px; }
@media (min-width: 800px) {
    body.ts-cc-banner-visible { padding-bottom: 100px; }
}
