/* =========================================================
   BF CMP Signal-Based Stylesheet
   ========================================================= */

/* Banner Wrapper */
#consent-banner-wrapper {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 540px;
    margin: 0 auto;
    background: #ffffff;
    color: #2c3e50;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    border: 1px solid #e2e8f0;

    /* Nascondi in modo sicuro calcolando l'altezza dell'elemento stesso */
    transform: translateY(calc(100% + 100px));
    opacity: 0;
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s ease;
    
    /* Evita overflow su schermi verticali corti */
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

#consent-banner-wrapper.is-visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Modal Header */
.bf-consent-header h2 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a202c;
}

.bf-consent-header p {
    margin: 0 0 16px 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #4a5568;
}

/* Category Checkboxes */
.bf-consent-categories {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    background: #f7fafc;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #edf2f7;
}

.bf-category-row label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

.bf-category-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #3182ce;
    cursor: pointer;
}

.bf-category-row input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

/* Action Buttons */
.bf-consent-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.bf-btn {
    flex: 1;
    min-width: 120px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.bf-btn:active {
    transform: scale(0.98);
}

.bf-btn.accept {
    background-color: #2b6cb0;
    color: #ffffff;
}
.bf-btn.accept:hover {
    background-color: #2c5282;
}

.bf-btn.save {
    background-color: #4a5568;
    color: #ffffff;
}
.bf-btn.save:hover {
    background-color: #2d3748;
}

.bf-btn.deny {
    background-color: #edf2f7;
    color: #4a5568;
    border: 1px solid #cbd5e0;
}
.bf-btn.deny:hover {
    background-color: #e2e8f0;
}

/* Footer Links */
.bf-consent-links {
    display: flex;
    gap: 12px;
    justify-content: center;
    font-size: 0.75rem;
}

.bf-consent-links a {
    color: #718096;
    text-decoration: underline;
}

.bf-consent-links a:hover {
    color: #2d3748;
}

/* Floating Manage Button */
.bf-consent-manage-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #1a202c; /* Colore di sfondo (modificabile) */
    color: #ffffff;    /* Colore del testo (modificabile) */
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 999998;
    display: none;
    transition: opacity 0.3s ease, transform 0.2s ease;
}

.bf-consent-manage-btn.is-visible {
    display: inline-block;
}

/* Shortcode Cookie Table (Accordion) */
.bf-cookie-accordion-container {
    margin: 20px 0;
    font-family: inherit;
}

.bf-cookie-accordion {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
}

.bf-cookie-accordion-header {
    padding: 14px 18px;
    font-weight: 600;
    cursor: pointer;
    background: #f7fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
}

.bf-cookie-accordion-header::-webkit-details-marker {
    display: none;
}

.bf-cookie-accordion[open] .bf-accordion-arrow {
    transform: rotate(180deg);
}

.bf-accordion-arrow {
    font-size: 10px;
    color: #a0aec0;
    transition: transform 0.2s ease;
}

.bf-cookie-accordion-content {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
}

.bf-cookie-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.bf-cookie-table th, 
.bf-cookie-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
}

.bf-cookie-table th {
    background-color: #f7fafc;
    color: #4a5568;
    font-weight: 600;
}

/* =========================================================
   MOBILE & STOREFRONT COMPATIBILITY (< 768px)
   ========================================================= */
@media (max-width: 768px) {
    /* Pulsante centrato orizzontalmente e sollevato sopra la footer bar di Storefront */
    .bf-consent-manage-btn {
        bottom: calc(75px + env(safe-area-inset-bottom, 0px));
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        white-space: nowrap;
    }

    #consent-banner-wrapper {
        left: 10px;
        right: 10px;
        padding: 16px;
        bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        max-height: calc(100dvh - 90px);
    }
    
    .bf-consent-actions {
        flex-direction: column;
    }
    
    .bf-cookie-table, 
    .bf-cookie-table tbody, 
    .bf-cookie-table tr, 
    .bf-cookie-table td {
        display: block;
        width: 100%;
    }
    
    .bf-cookie-table thead {
        display: none;
    }
    
    .bf-cookie-table tr {
        margin-bottom: 12px;
        border: 1px solid #edf2f7;
        border-radius: 6px;
        padding: 8px;
    }
    
    .bf-cookie-table td {
        padding: 6px 4px;
        border-bottom: none;
    }
    
    .bf-cookie-table td::before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: inline-block;
        color: #718096;
    }
}

/* Ottimizzazione layout per orientamento Landscape o schermi molto corti */
@media (max-height: 500px) {
    #consent-banner-wrapper {
        padding: 12px 16px;
    }
    .bf-consent-header p {
        margin-bottom: 8px;
    }
    .bf-consent-categories {
        margin-bottom: 10px;
        padding: 8px 12px;
    }
}