/**
 * Optimus Cookie Pro – Front CSS
 * Copyright (c) 2026 Studio Iceberg. Tutti i diritti riservati.
 */

/* ============================
 * BANNER
 * ============================ */
.optcp-banner {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 999998;
    color: var(--optcp-fg, #fff);
    background: var(--optcp-bg, #1c1c1c);
    background-color: color-mix(in srgb, var(--optcp-bg, #1c1c1c) calc(var(--optcp-bg-opacity, 0.95) * 100%), transparent);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.5;
    /* Alysum-safe hidden state: niente display:none che rompe Alysum a runtime */
    visibility: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.optcp-banner.optcp-visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.optcp-banner.optcp-collapsed {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.optcp-pos-top    { top: 0;    bottom: auto; transform: translateY(-20px); }
.optcp-pos-top.optcp-visible { transform: translateY(0); }
.optcp-pos-bottom { bottom: 0; top: auto; }

.optcp-pos-floating {
    bottom: 24px;
    left: 24px;
    right: 24px;
    max-width: 720px;
    margin: 0 auto;
    border-radius: 12px;
    padding: 20px 24px;
}

.optcp-banner-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.optcp-banner-message {
    flex: 1 1 60%;
    min-width: 280px;
}

.optcp-banner-message p:first-child { margin-top: 0; }
.optcp-banner-message p:last-child  { margin-bottom: 0; }

.optcp-info-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--optcp-fg, #fff);
    text-decoration: underline;
}

.optcp-banner-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.optcp-banner .optcp-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: transparent;
    border: 0;
    color: var(--optcp-fg, #fff);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}

/* ============================
 * PULSANTI
 * ============================ */
.optcp-btn {
    display: inline-block;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s, transform 0.05s;
    background: var(--optcp-btn-bg, #1976d2);
    color: var(--optcp-btn-fg, #fff);
}

.optcp-btn:hover  { filter: brightness(1.08); }
.optcp-btn:active { transform: translateY(1px); }

.optcp-btn-reject,
.optcp-btn-cancel {
    background: var(--optcp-btn-reject-bg, #616161);
    color: var(--optcp-btn-reject-fg, #fff);
}

.optcp-btn-customize {
    background: transparent;
    color: var(--optcp-fg, #fff);
    text-decoration: underline;
    padding-left: 8px;
    padding-right: 8px;
}

.optcp-btn-save {
    background: color-mix(in srgb, var(--optcp-btn-bg, #1976d2) 80%, #000 20%);
}

/* ============================
 * BLOCK-NAVIGATION OVERLAY
 * ============================ */
.optcp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999997;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.optcp-overlay.optcp-active {
    visibility: visible;
    opacity: 1;
}

/* ============================
 * MODALE PERSONALIZZA
 * ============================ */
.optcp-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.optcp-modal.optcp-active {
    visibility: visible;
    opacity: 1;
}

.optcp-modal-box {
    background: #fff;
    color: #222;
    border-radius: 12px;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.optcp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e5e5;
}

.optcp-modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.optcp-modal-close {
    background: transparent;
    border: 0;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    padding: 0 6px;
}

.optcp-modal-body {
    overflow-y: auto;
    padding: 16px 20px;
    flex: 1 1 auto;
}

.optcp-modal-intro {
    font-size: 13px;
    color: #555;
    margin-top: 0;
    margin-bottom: 16px;
}

.optcp-modal-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid #e5e5e5;
    background: #fafafa;
    border-radius: 0 0 12px 12px;
}

/* ============================
 * PURPOSE ROW
 * ============================ */
.optcp-purpose {
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 10px;
}

.optcp-purpose-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.optcp-purpose-name {
    margin: 0;
    font-size: 15px;
}

.optcp-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 99px;
    background: #e0e0e0;
    color: #555;
    margin-left: 8px;
}

.optcp-badge-required {
    background: #cfe8d4;
    color: #1b6e30;
}

.optcp-purpose-description {
    font-size: 13px;
    color: #555;
    margin-top: 8px;
}

.optcp-cookies-details {
    margin-top: 10px;
    font-size: 12px;
}

.optcp-cookies-details summary {
    cursor: pointer;
    padding: 6px 8px;
    background: #f5f5f5;
    border-radius: 6px;
}

.optcp-cookies-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 12px;
}

.optcp-cookies-table th,
.optcp-cookies-table td {
    border: 1px solid #e5e5e5;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.optcp-cookies-table th { background: #fafafa; }
.optcp-cookies-table code {
    font-size: 11px;
    background: #f1f1f1;
    padding: 1px 4px;
    border-radius: 3px;
}

/* ============================
 * SWITCH TOGGLE
 * ============================ */
.optcp-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.optcp-slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: #ccc;
    border-radius: 24px;
    transition: background 0.2s;
}

.optcp-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.optcp-switch input:checked + .optcp-slider {
    background: #1976d2;
}

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

.optcp-switch-locked .optcp-slider {
    background: #4caf50;
    opacity: 0.7;
    cursor: not-allowed;
}

/* ============================
 * FLOATING BUTTON
 * ============================ */
.optcp-float-button {
    position: fixed;
    bottom: 20px;
    z-index: 999996;
    background: var(--optcp-btn-bg, #1976d2);
    color: var(--optcp-btn-fg, #fff);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.optcp-float-button:hover { transform: scale(1.05); }
.optcp-float-left  { left: 20px; }
.optcp-float-right { right: 20px; }

/* ============================
 * BLOCK NAVIGATION
 * ============================ */
body.optcp-block-active {
    overflow: hidden;
}

/* ============================
 * RESPONSIVE
 * ============================ */
@media (max-width: 768px) {
    .optcp-pos-floating {
        bottom: 12px;
        left: 12px;
        right: 12px;
    }
    .optcp-banner-actions {
        width: 100%;
        flex-direction: column;
    }
    .optcp-banner-actions .optcp-btn { width: 100%; }
    .optcp-modal-footer { flex-direction: column-reverse; }
    .optcp-modal-footer .optcp-btn { width: 100%; }
}
