/*
 * Iberoclinic Cookies - banner & modal styles
 * Vanilla CSS, no Bootstrap deps. Theme palette: --ic-green #76ac4e, --ic-blue #007bfe.
 */

.ic-cookies-banner,
.ic-cookies-modal {
    --ic-c-green: #76ac4e;
    --ic-c-green-dark: #5e8b3e;
    --ic-c-text: #1f1f1f;
    --ic-c-muted: #6b7280;
    --ic-c-border: #d1d5db;
    --ic-c-bg: #ffffff;
    box-sizing: border-box;
    font-family: inherit;
    color: var(--ic-c-text);
}

.ic-cookies-banner *,
.ic-cookies-modal * {
    box-sizing: border-box;
}

/* ---------- Banner ---------- */
.ic-cookies-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--ic-c-bg);
    border-top: 3px solid var(--ic-c-green);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    z-index: 99998;
    padding: 1rem 1.25rem;
}

.ic-cookies-banner[hidden] {
    display: none !important;
}

.ic-cookies-banner__inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.ic-cookies-banner__text {
    flex: 1 1 320px;
    min-width: 0;
}

.ic-cookies-banner__text strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--ic-c-green);
}

.ic-cookies-banner__text p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--ic-c-text);
    text-align: justify;
}

.ic-cookies-banner__text a {
    color: var(--ic-c-green);
    text-decoration: underline;
}

.ic-cookies-banner__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ---------- Buttons ---------- */
.ic-cookies-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.6rem 1.1rem;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
    white-space: nowrap;
    line-height: 1.2;
    min-width: 110px;
    text-align: center;
}

.ic-cookies-btn--primary {
    background: var(--ic-c-green);
    border-color: var(--ic-c-green);
    color: #ffffff;
}

.ic-cookies-btn--primary:hover,
.ic-cookies-btn--primary:focus {
    background: var(--ic-c-green-dark);
    border-color: var(--ic-c-green-dark);
}

/* LSSI compliance: reject must look as prominent as accept */
.ic-cookies-btn--secondary {
    background: #ffffff;
    border-color: #1f1f1f;
    color: #1f1f1f;
}

.ic-cookies-btn--secondary:hover,
.ic-cookies-btn--secondary:focus {
    background: #1f1f1f;
    color: #ffffff;
}

.ic-cookies-btn--ghost {
    background: transparent;
    border-color: var(--ic-c-border);
    color: var(--ic-c-text);
}

.ic-cookies-btn--ghost:hover,
.ic-cookies-btn--ghost:focus {
    border-color: #1f1f1f;
}

/* ---------- Modal ---------- */
.ic-cookies-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ic-cookies-modal[hidden] {
    display: none !important;
}

.ic-cookies-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.ic-cookies-modal__dialog {
    position: relative;
    background: #ffffff;
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
}

.ic-cookies-modal__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ic-c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ic-cookies-modal__header h2 {
    font-size: 1.15rem;
    margin: 0;
}

.ic-cookies-modal__close {
    appearance: none;
    background: transparent;
    border: 0;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--ic-c-muted);
    padding: 0 0.25rem;
}

.ic-cookies-modal__close:hover {
    color: var(--ic-c-text);
}

.ic-cookies-modal__body {
    padding: 1.25rem;
    overflow-y: auto;
}

.ic-cookies-modal__intro {
    margin: 0 0 1rem 0;
    color: var(--ic-c-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.ic-cookies-modal__footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--ic-c-border);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    background: #fafafa;
}

/* ---------- Category card ---------- */
.ic-cookie-cat {
    border: 1px solid var(--ic-c-border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
}

.ic-cookie-cat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.ic-cookie-cat__head h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--ic-c-text);
}

.ic-cookie-cat__desc {
    margin: 0.4rem 0 0.25rem;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--ic-c-text);
}

.ic-cookie-cat__details {
    margin: 0;
    color: var(--ic-c-muted);
    font-size: 0.8rem;
}

/* ---------- iOS-style switch ---------- */
.ic-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.ic-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.ic-switch__slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    transition: background 160ms ease;
    border-radius: 24px;
}

.ic-switch__slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    transition: transform 160ms ease;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ic-switch input:checked + .ic-switch__slider {
    background: var(--ic-c-green);
}

.ic-switch input:checked + .ic-switch__slider::before {
    transform: translateX(20px);
}

.ic-switch input:focus + .ic-switch__slider {
    outline: 2px solid var(--ic-c-green);
    outline-offset: 2px;
}

.ic-switch--locked .ic-switch__slider {
    background: var(--ic-c-green);
    cursor: not-allowed;
    opacity: 0.7;
}

.ic-switch--locked .ic-switch__slider::before {
    transform: translateX(20px);
}

/* ---------- Footer link ---------- */
.ic-cookies-footer-link {
    text-align: center;
    padding: 0.5rem 0;
    font-size: 0.85rem;
}

.ic-cookies-footer-link a {
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.ic-cookies-footer-link a:hover {
    color: var(--ic-c-green, #76ac4e);
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
    .ic-cookies-banner__inner {
        flex-direction: column;
        align-items: stretch;
    }

    .ic-cookies-banner__actions {
        flex-direction: column;
        width: 100%;
    }

    .ic-cookies-btn {
        width: 100%;
    }

    .ic-cookies-modal__footer {
        flex-direction: column-reverse;
    }

    .ic-cookies-modal__footer .ic-cookies-btn {
        width: 100%;
    }
}

/* ===== Floating reopen button (FAB) — siempre visible ===== */
.ic-cookies-fab {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 9990;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #76ac4e;
    color: #fff;
    border: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
    padding: 0;
}
.ic-cookies-fab:hover,
.ic-cookies-fab:focus {
    background: #5e8a3d;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,.3);
    outline: 0;
}
.ic-cookies-fab:focus-visible {
    outline: 3px solid rgba(118,172,78,.4);
    outline-offset: 3px;
}
.ic-cookies-fab svg { display: block; }

/* Mientras el banner inicial esté visible, ocultar el FAB para no apilar */
body:has(.ic-cookies-banner:not([hidden])) .ic-cookies-fab {
    display: none;
}

@media (max-width: 575.98px) {
    .ic-cookies-fab { width: 44px; height: 44px; left: 14px; bottom: 14px; }
    .ic-cookies-fab svg { width: 22px; height: 22px; }
}
