/* Simple Consent Manager – Frontend Styles (target < 10 kb) */

/* ── CSS isolation: theme-agnostic reset ── */
/* Box-sizing su tutti gli elementi interni */
#scm-banner *,
#scm-banner *::before,
#scm-banner *::after,
#scm-modal *,
#scm-modal *::before,
#scm-modal *::after {
    box-sizing: border-box;
}
/* Reset completo sui bottoni: parte da zero indipendentemente dal tema */
#scm-banner button,
#scm-modal button {
    all: unset;
    box-sizing: border-box;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}
#scm-banner .scm-btn,
#scm-modal .scm-btn {
    display: block;
    width: 100%;
    padding: 13px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .95em;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.2;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    transition: filter .15s;
    text-align: center;
}
#scm-banner .scm-btn-accept { color: #fff; }
#scm-modal .scm-btn-accept  { color: #fff; }

/* ── Banner base ── */
#scm-banner {
    position: fixed;
    z-index: 2147483647;
    box-sizing: border-box;
    width: 100%;
    left: 0;
    background: #ffffff;
    color: #111827;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    box-shadow: 0 -1px 0 rgba(0,0,0,.08), 0 -4px 20px rgba(0,0,0,.08);
}

/* Positions */
#scm-banner.scm-pos--bottom      { bottom: 0; }
#scm-banner.scm-pos--top         { top: 0; box-shadow: 0 2px 16px rgba(0,0,0,.3); }
#scm-banner.scm-pos--bottom-left {
    bottom: 20px;
    left: 20px;
    width: auto;
    max-width: 420px;
    border-radius: 8px;
}
#scm-banner.scm-pos--bottom-right {
    bottom: 20px;
    left: auto;
    right: 20px;
    width: auto;
    max-width: 420px;
    border-radius: 8px;
}
#scm-banner.scm-pos--center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    max-width: 560px;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

/* Overlay for center modal */
#scm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 2147483645;
}

/* ── Banner close (×) button ── */
/* Use #scm-banner selector for specificity > #scm-banner button { all: unset } */
#scm-banner .scm-banner-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    font-size: 1.6em;
    cursor: pointer;
    color: inherit;
    opacity: 0.45;
    line-height: 1;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: opacity .15s, background .15s;
    z-index: 1;
}
#scm-banner .scm-banner-close:hover { opacity: 1; background: rgba(0,0,0,.06); }

/* ── Banner inner layout ── */
.scm-banner-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ── Banner header (logo + lang switcher) ── */
.scm-banner-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.scm-logo {
    height: 52px;
    width: auto;
    flex-shrink: 0;
    object-fit: contain;
}

/* ── Language switcher ── */
.scm-lang-wrap {
    display: flex;
    justify-content: center;
}

.scm-lang-select {
    all: unset;
    box-sizing: border-box;
    display: inline-block;
    padding: 4px 24px 4px 10px;
    border: 1px solid currentColor;
    border-radius: 20px;
    font-size: .8em;
    font-weight: 600;
    opacity: .65;
    cursor: pointer;
    transition: opacity .15s;
    background-color: transparent;
    color: inherit;
    white-space: nowrap;
    /* Native arrow via background image */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    -webkit-appearance: none;
    appearance: none;
}

.scm-lang-select:hover  { opacity: 1; }
.scm-lang-select:focus  { outline: 2px solid currentColor; outline-offset: 2px; opacity: 1; }

/* ── Banner content ── */
.scm-banner-content {
    flex: 1;
    min-width: 0;
}

.scm-banner-title {
    display: block;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.scm-banner-text {
    margin: 0 0 10px;
    font-size: 16px;
    opacity: .88;
}

/* ── Policy links ── */
.scm-policy-links {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.scm-policy-links a {
    font-size: .85em;
    color: #4b5563;
    text-decoration: underline;
    opacity: .8;
}

.scm-policy-links a:hover { opacity: 1; }

/* ── Banner actions (stacked full-width buttons) ── */
.scm-banner-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    width: 200px;
}

/* ── Buttons ── */
.scm-btn {
    display: block;
    width: 100%;
    padding: 12px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .95em;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.2;
    text-align: center;
    transition: filter .15s;
}

.scm-btn:hover  { filter: brightness(1.12); }
.scm-btn:active { filter: brightness(.92); }
.scm-btn:focus  { outline: 3px solid #111827; outline-offset: 2px; }

.scm-btn-accept { background: #111827; color: #fff; }
.scm-btn-prefs  { background: transparent; border: 2px solid #111827; color: #111827; }

/* ── Center modal layout ── */
.scm-banner-inner--modal {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
}

.scm-banner-inner--modal .scm-banner-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.scm-banner-inner--modal .scm-banner-content {
    flex: none;
}

.scm-banner-inner--modal .scm-banner-title {
    font-size: 1.35em;
    font-weight: 700;
    letter-spacing: -.01em;
    margin-bottom: 10px;
}

.scm-banner-inner--modal .scm-banner-text {
    font-size: 1em;
    opacity: .75;
    line-height: 1.6;
}

.scm-banner-inner--modal .scm-banner-actions {
    width: 100%;
}

/* ── Preferences modal ── */
#scm-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483647;
    background: rgba(0,0,0,.6);
    padding: 16px;
    box-sizing: border-box;
}

.scm-modal-inner {
    background: #fff;
    color: #1e293b;
    border-radius: 12px;
    padding: 32px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 16px 48px rgba(0,0,0,.35);
    box-sizing: border-box;
}

.scm-modal-inner h2 {
    margin: 0 0 20px;
    font-size: 1.15em;
}

/* Back button replaces × in preferences modal — flows as block before h2.
   Use #scm-modal prefix for specificity (1,1,0) > #scm-modal button all:unset (1,0,1) */
#scm-modal .scm-modal-close {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 28px;
    background: none;
    border: none;
    font-size: .88em;
    font-weight: 600;
    cursor: pointer;
    color: #64748b;
    letter-spacing: .01em;
    opacity: .75;
    transition: opacity .15s;
    padding: 0;
}

#scm-modal .scm-modal-close:hover { opacity: 1; color: #1e293b; }

/* ── Preference rows ── */
.scm-pref-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid #e2e8f0;
}

.scm-pref-row:last-of-type { border-bottom: none; }

.scm-pref-row--required { opacity: .8; }

.scm-pref-info { flex: 1; }

.scm-pref-info strong { display: block; margin-bottom: 2px; }

.scm-pref-info p {
    margin: 0;
    font-size: .85em;
    color: #475569;
}

/* ── Toggle switch ── */
.scm-toggle {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.scm-toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 24px;
    cursor: pointer;
    transition: background .2s;
}

.scm-toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.scm-toggle input:checked + .scm-toggle-slider              { background: #2563eb; }
.scm-toggle input:checked + .scm-toggle-slider::before      { transform: translateX(22px); }
.scm-toggle input:disabled + .scm-toggle-slider             { opacity: .55; cursor: not-allowed; }
.scm-toggle input:focus   + .scm-toggle-slider              { outline: 3px solid #60a5fa; outline-offset: 2px; }

/* ── Modal footer ── */
.scm-modal-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* Modal buttons full-width */
.scm-modal-footer .scm-btn {
    width: 100%;
}

/* ── Policy modal (Privacy Policy / Cookie Policy) ── */
#scm-policy-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483647;
    background: rgba(0,0,0,.6);
    padding: 16px;
    box-sizing: border-box;
}

#scm-policy-modal *,
#scm-policy-modal *::before,
#scm-policy-modal *::after {
    box-sizing: border-box;
}

#scm-policy-modal button {
    all: unset;
    box-sizing: border-box;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

.scm-policy-modal-inner {
    background: #fff;
    color: #1e293b;
    border-radius: 12px;
    padding: 36px 40px;
    max-width: 720px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 16px 48px rgba(0,0,0,.35);
    font-size: 15px;
    line-height: 1.7;
}

/* Back button — same look as preferences modal */
#scm-policy-modal .scm-modal-close {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 24px;
    background: none;
    border: none;
    font-size: .88em;
    font-weight: 600;
    cursor: pointer;
    color: #64748b;
    opacity: .75;
    transition: opacity .15s;
    padding: 0;
}
#scm-policy-modal .scm-modal-close:hover { opacity: 1; color: #1e293b; }

/* Rich content typography inside the modal */
.scm-policy-modal-inner .scm-policy-content h2 {
    font-size: 1.1em;
    font-weight: 700;
    margin: 28px 0 8px;
    padding-top: 4px;
    border-top: 1px solid #e2e8f0;
    color: #0f172a;
}
.scm-policy-modal-inner .scm-policy-content h2:first-of-type { border-top: none; margin-top: 8px; }
.scm-policy-modal-inner .scm-policy-content h3 {
    font-size: 1em;
    font-weight: 700;
    margin: 20px 0 6px;
    color: #1e293b;
}
.scm-policy-modal-inner .scm-policy-content p { margin: 0 0 10px; }
.scm-policy-modal-inner .scm-policy-content ul {
    margin: 0 0 12px;
    padding-left: 20px;
}
.scm-policy-modal-inner .scm-policy-content li { margin-bottom: 4px; }
.scm-policy-modal-inner .scm-policy-content a {
    color: #2563eb;
    text-decoration: underline;
}
.scm-policy-modal-inner .scm-policy-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88em;
    margin-bottom: 16px;
}
.scm-policy-modal-inner .scm-policy-content th,
.scm-policy-modal-inner .scm-policy-content td {
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    vertical-align: top;
}
.scm-policy-modal-inner .scm-policy-content th { background: #f8fafc; font-weight: 600; }
.scm-policy-modal-inner .scm-policy-content code {
    font-size: .85em;
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 3px;
}
.scm-policy-modal-inner .scm-policy-content hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 24px 0 12px;
}

.scm-policy-loading {
    text-align: center;
    color: #94a3b8;
    padding: 40px 0;
    font-size: .9em;
}

@media (max-width: 700px) {
    .scm-policy-modal-inner {
        padding: 20px;
        max-height: 92vh;
    }
}

/* ── Iframe placeholder ── */
.scm-iframe-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: 2px dashed #cbd5e1;
    border-radius: 6px;
    min-height: 200px;
    padding: 24px;
    box-sizing: border-box;
}

.scm-iframe-inner {
    text-align: center;
    color: #475569;
}

.scm-iframe-inner p { margin: 0 0 12px; }

.scm-iframe-btn {
    padding: 8px 18px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: .9em;
    font-weight: 600;
}

.scm-iframe-btn:hover { background: #1d4ed8; }

/* ── Re-open button ── */
#scm-reopen {
    position: fixed;
    z-index: 2147483646;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    background: #111827;
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
    transition: filter .15s;
}
#scm-reopen:hover { filter: brightness(1.15); }

#scm-reopen.scm-reopen--bottom-right { bottom: 20px; right: 20px; }
#scm-reopen.scm-reopen--bottom-left  { bottom: 20px; left: 20px; }
#scm-reopen.scm-reopen--middle-right { top: 50%; right: 20px; transform: translateY(-50%); }
#scm-reopen.scm-reopen--middle-left  { top: 50%; left: 20px; transform: translateY(-50%); }
#scm-reopen.scm-reopen--hidden       { display: none !important; }

/* ── Responsive ── */
@media (max-width: 700px) {
    /* Floating positions (center / bottom-left / bottom-right):
       centered modal with side margins — same as desktop intent */
    #scm-banner.scm-pos--center,
    #scm-banner.scm-pos--bottom-left,
    #scm-banner.scm-pos--bottom-right {
        left: 16px !important;
        right: 16px !important;
        bottom: auto !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: auto !important;
        max-width: none !important;
        border-radius: 12px !important;
    }

    /* Full-width bar positions (top / bottom):
       keep at their edge, full-width — coherent with desktop */
    #scm-banner.scm-pos--top,
    #scm-banner.scm-pos--bottom {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: none !important;
        border-radius: 0 !important;
    }

    /* Close button: keep circular shape on mobile */
    #scm-banner .scm-banner-close {
        top: 10px;
        right: 10px;
        font-size: 1.6em;
        width: 44px;
        height: 44px;
        padding: 0;
        opacity: 0.6;
    }

    /* Compact vertical layout, extra top padding for × */
    .scm-banner-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-top: 12px;
    }

    /* Hide logo on mobile */
    .scm-banner-header {
        display: none;
    }

    /* Tighter text */
    .scm-banner-title {
        font-size: 15px !important;
        margin-bottom: 4px;
    }

    .scm-banner-text {
        font-size: 13px !important;
        margin-bottom: 4px;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .scm-policy-links {
        gap: 10px;
        margin-top: 2px;
    }

    /* Buttons full-width stacked (cleaner on mobile) */
    .scm-banner-actions {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .scm-banner-actions .scm-btn {
        padding: 12px;
        font-size: 14px;
    }

    .scm-modal-inner {
        padding: 20px;
    }
}
