/*
 * CSS per il frontend del plugin Amazon Offerte.
 */
.amazon-offerte-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.amazon-offerte-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
}

.amazon-offerte-card:hover {
    transform: translateY(-5px);
}

.amazon-offerte-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.amazon-offerte-image-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 Aspect Ratio */
    overflow: hidden;
    background-color: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.amazon-offerte-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease-in-out;
}

.amazon-offerte-card:hover .amazon-offerte-image {
    transform: scale(1.05);
}

/* Stili per la versione compatta (in-articolo) */
.amazon-offerte-card-compact {
    flex-direction: row !important;
    max-width: 500px;
    margin: 15px auto;
    border: 1px solid #e5e5e5;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-radius: 6px;
}

.amazon-offerte-card-compact .amazon-offerte-link {
    flex-direction: row;
    width: 100%;
}

.amazon-offerte-card-compact .amazon-offerte-image-wrap {
    width: 120px;
    min-width: 120px;
    padding-bottom: 0;
    height: 120px;
}

.amazon-offerte-card-compact .amazon-offerte-content {
    padding: 8px 12px;
    justify-content: center;
}

.amazon-offerte-card-compact .amazon-offerte-title {
    font-size: 0.95em;
    margin-bottom: 5px;
    min-height: auto;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.amazon-offerte-card-compact .amazon-offerte-prices {
    margin-bottom: 5px;
}

.amazon-offerte-card-compact .amazon-offerte-current-price {
    font-size: 1.1em;
}

.amazon-offerte-card-compact .amazon-offerte-button {
    padding: 5px 10px;
    font-size: 0.85em;
    width: auto;
    display: inline-block;
}

.amazon-offerte-badge {
    position: absolute;
    top: 10px;
    padding: 5px 10px;
    border-radius: 3px;
    color: #fff;
    font-size: 0.8em;
    font-weight: bold;
    z-index: 10;
}

.discount-badge {
    background-color: #e74c3c;
    left: 10px;
}

.prime-badge {
    background-color: #FF9900;
    right: 10px;
}

.amazon-offerte-content {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.amazon-offerte-title {
    font-size: 1.1em;
    margin-top: 0;
    margin-bottom: 10px;
    line-height: 1.4;
    min-height: 40px; /* Per mantenere l'altezza consistente */
}

.amazon-offerte-prices {
    margin-bottom: 10px;
}

.amazon-offerte-old-price {
    text-decoration: line-through;
    color: #888;
    font-size: 0.9em;
    margin-right: 8px;
}

.amazon-offerte-current-price {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
}

.amazon-offerte-rating {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.amazon-offerte-rating .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: #FFD700; /* Gold color for stars */
}

.amazon-offerte-reviews {
    font-size: 0.9em;
    color: #666;
    margin-left: 5px;
}

.amazon-offerte-lowest-price {
    font-size: 0.85em;
    color: #555;
    margin-top: 5px;
    margin-bottom: 10px;
}

.amazon-offerte-button {
    display: block;
    width: 100%;
    padding: 10px 15px;
    background-color: #FFD700; /* Giallo Oro */
    color: #000; /* Testo nero per contrasto con il giallo */
    text-align: center;
    border: none;
    border-radius: 5px;
    font-size: 1.1em;
    font-weight: bold; /* Grassetto */
    text-decoration: underline; /* Sottolineato */
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    margin-top: auto; /* Spinge il pulsante in fondo */
}

.amazon-offerte-button:hover {
    background-color: #e68a00;
}

/* Stili per mobile */
@media (max-width: 768px) {
    .amazon-offerte-container {
        grid-template-columns: 1fr;
    }
}

/* Stili per la Top Offer Bar */
.amazon-offerte-top-bar {
    background-color: #28a745; /* Verde simile a Fotonerd */
    color: #fff;
    padding: 0 15px;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    z-index: 99999;
    overflow: hidden;
    height: 70px;
    line-height: 1.2;
    box-sizing: border-box;
    width: 100%;
}

.amazon-offerte-top-bar::-webkit-scrollbar {
    height: 4px;
}

.amazon-offerte-top-bar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
}

.offer-slider-wrapper {
    display: flex;
    align-items: center;
    height: 100%;
    width: 100%;
    transition: transform 0.6s cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

.amazon-offerte-top-bar .offer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(5px, 2vw, 15px);
    flex-shrink: 0;
    padding: 0 5px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.amazon-offerte-top-bar .offer-image {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background-color: #fff;
    padding: 3px;
    border-radius: 4px;
}

.amazon-offerte-top-bar .offer-text {
    margin: 0;
    max-width: clamp(150px, 40vw, 600px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(0.8em, 1.2vw, 0.95em);
    flex-grow: 1;
}

.amazon-offerte-top-bar .offer-price {
    font-size: clamp(1em, 1.5vw, 1.2em);
    white-space: nowrap;
    font-weight: 800;
}

.amazon-offerte-top-bar .offer-discount-badge {
    background-color: #1e7e34; /* Verde più scuro per il badge */
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9em;
    white-space: nowrap;
}

.amazon-offerte-top-bar .offer-button {
    background-color: #1e7e34; /* Verde più scuro per il pulsante */
    color: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    text-decoration: none;
    transition: background-color 0.3s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1; /* Forza il testo al centro verticale */
}

.amazon-offerte-top-bar .offer-button:hover {
    background-color: #155724;
}

/* Stili per i blocchi in-articolo */
.amazon-offerte-in-article-block {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.amazon-offerte-in-article-block .block-header {
    background-color: #28a745;
    color: #fff;
    padding: 8px 15px;
    border-radius: 8px 8px 0 0;
    margin: -15px -15px 15px -15px;
    font-weight: bold;
    width: calc(100% + 30px);
    text-align: center;
}

.amazon-offerte-in-article-block .block-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    background-color: #f8f8f8;
    padding: 5px;
    border-radius: 5px;
    flex-shrink: 0;
}

.amazon-offerte-in-article-block .block-details {
    flex-grow: 1;
}

.amazon-offerte-in-article-block .block-title {
    font-size: 1.1em;
    font-weight: bold;
    margin: 0 0 5px 0;
}

.amazon-offerte-in-article-block .block-price-info {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.amazon-offerte-in-article-block .block-current-price {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
}

.amazon-offerte-in-article-block .block-old-price {
    text-decoration: line-through;
    color: #888;
    font-size: 0.9em;
}

.amazon-offerte-in-article-block .block-discount-badge {
    background-color: #28a745;
    color: #fff;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.8em;
    font-weight: bold;
}

.amazon-offerte-in-article-block .block-button {
    display: inline-block;
    padding: 8px 15px;
    background-color: #FFD700; /* Giallo Oro */
    color: #000; /* Testo nero */
    text-decoration: underline; /* Sottolineato */
    font-weight: bold; /* Grassetto */
    border-radius: 5px;
    transition: background-color 0.3s ease;
    margin-top: 10px;
}

.amazon-offerte-in-article-block .block-button:hover {
    background-color: #e68a00;
}

@media (max-width: 1024px) {
    .amazon-offerte-top-bar {
        display: none !important;
    }
    .amazon-offerte-top-bar .amazon-offerte-plugin-logo {
        display: none !important;
    }
    .amazon-offerte-top-bar .offer-content {
        gap: 6px;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding: 0 10px;
    }
    .amazon-offerte-top-bar .offer-image {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }
    .amazon-offerte-top-bar .offer-text {
        max-width: 140px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.9em;
        color: #ffffff !important;
    }
    .amazon-offerte-top-bar .offer-price {
        font-size: 1em;
        font-weight: 800;
        color: #ffffff !important;
        margin: 0 5px;
    }
    .amazon-offerte-top-bar .offer-discount-badge {
        display: none; /* Nascondiamo lo sconto su mobile molto piccolo per far stare il pulsante */
    }
    .amazon-offerte-top-bar .offer-button {
        padding: 5px 10px;
        font-size: 0.8em;
        border-radius: 15px;
        margin-left: 5px;
        background-color: #1e7e34 !important;
        color: #ffffff !important;
        font-weight: bold;
    }

    .amazon-offerte-in-article-block {
        flex-direction: column;
        text-align: center;
        max-width: 100%;
    }
    .amazon-offerte-in-article-block .block-image {
        margin-bottom: 10px;
    }
}

/* Ottimizzazione specifica per schermi piccolissimi (iPhone SE etc) */
@media (max-width: 380px) {
    .amazon-offerte-top-bar .offer-text {
        max-width: 80px;
    }
    .amazon-offerte-top-bar .amazon-offerte-plugin-logo {
        display: none; /* Nascondiamo il logo secondario se lo spazio è critico */
    }
}

/* Stili per il logo del plugin nella Top Bar */
.amazon-offerte-top-bar .amazon-offerte-plugin-logo {
    height: 30px; /* Altezza del logo nella top bar */
    margin-right: 10px;
    object-fit: contain;
}

/* Stile per i link generati dall'AI all'interno dell'articolo */
.amazon-offerte-ai-cta {
    font-weight: bold !important;
    text-decoration: underline !important;
    color: #000 !important;
    background-color: #FFD700 !important;
    padding: 5px 10px;
    border-radius: 4px;
    display: inline-block;
    margin: 10px 0;
}

/* Stili per il logo del plugin nelle schede prodotto */
.amazon-offerte-card .amazon-offerte-plugin-logo-card {
    max-width: 80px; /* Larghezza massima del logo nella card */
    max-height: 40px; /* Altezza massima del logo nella card */
    margin-bottom: 10px;
    object-fit: contain;
}

/* Stili Comuni per le Card Amazon (Article & Narrow) */
.amazon-offerte-card-link-wrapper {
    display: flex;
    text-decoration: none;
    color: inherit;
    height: 100%;
    background: #fff;
}

.amazon-offerte-card-img-box {
    position: relative;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-right: 1px solid #f0f0f0;
}

.amazon-offerte-card-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.amazon-offerte-card-discount-badge {
    position: absolute;
    top: 0;
    left: 0;
    background: #e74c3c !important;
    color: #fff !important;
    padding: 8px 12px !important;
    font-size: 1.1em !important;
    font-weight: 900 !important;
    border-radius: 0 0 8px 0 !important;
    z-index: 99 !important;
    display: block !important;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2) !important;
}

.amazon-offerte-card-info {
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.amazon-offerte-card-meta {
    margin-bottom: 5px;
    display: flex;
    gap: 8px;
    font-size: 0.7em;
    text-transform: uppercase;
    font-weight: 700;
}

.amazon-offerte-card-meta .brand { color: #FF9900; }
.amazon-offerte-card-meta .category { color: #888; }

.amazon-offerte-card-title {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 700;
    color: #111;
}

.amazon-offerte-card-price-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.amazon-offerte-card-price-line .prices {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.amazon-offerte-card-price-line .current {
    font-size: 2em;
    font-weight: 800;
    color: #000;
}

.amazon-offerte-card-price-line .old {
    text-decoration: line-through;
    color: #999;
    font-size: 1.2em;
}

.amazon-offerte-card-price-line .prime-icon {
    background: #FF9900;
    color: #fff;
    padding: 2px 6px;
    font-size: 0.75em;
    font-weight: 700;
    border-radius: 3px;
}

.amazon-offerte-card-extra {
    margin-bottom: 10px;
    font-size: 0.85em;
}

.amazon-offerte-card-description {
    margin-top: 10px;
    font-size: 0.9em;
    line-height: 1.4;
    color: #444;
    display: block !important;
    max-height: 4.2em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.amazon-offerte-card-extra .rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
}

.amazon-offerte-card-extra .rating .dashicons {
    color: #FFA41C;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.amazon-offerte-card-extra .rating .count { color: #007185; }

.amazon-offerte-card-extra .lowest {
    color: #555;
    background: #f8f8f8;
    padding: 3px 6px;
    border-radius: 4px;
    display: inline-block;
}

.amazon-offerte-card-btn-box { margin-top: auto; }

.cta-btn {
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    background: #FFD700 !important;
    color: #000 !important;
    padding: 10px !important;
    font-weight: 800 !important;
    font-size: 1.1em !important;
    text-decoration: underline !important;
    border-radius: 8px !important;
    transition: background 0.2s !important;
    border: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 40px;
}

/* Forziamo il testo del pulsante se sparisse */
.cta-btn:empty::before {
    content: "Vedi offerta" !important;
}

.cta-btn:hover {
    background: #e6c200;
}

/* 1. Box Fine Articolo (Integrato) */
.amazon-offerte-article-footer-box {
    margin: 40px 0;
    padding: 20px;
    background: #fcfcfc;
    border: 1px solid #eee;
    border-radius: 12px;
    clear: both;
}

.amazon-offerte-footer-box-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #FF9900;
    padding-bottom: 8px;
}

.amazon-offerte-footer-logo { height: 24px; margin-right: 12px; }
.amazon-offerte-footer-box-title { margin: 0; font-size: 1.2em; font-weight: 800; }

.amazon-offerte-footer-track-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.amazon-offerte-footer-track-viewport { overflow: hidden; width: 100%; }
.amazon-offerte-footer-track { display: flex; transition: transform 0.4s ease; }

.amazon-offerte-large-card {
    flex: 0 0 100% !important;
    width: 100% !important;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    margin: 0 !important;
}

.amazon-offerte-large-card .amazon-offerte-card-inner { 
    width: 100% !important;
}

.amazon-offerte-large-card .amazon-offerte-card-link {
    display: flex !important;
    flex-direction: row !important;
    text-decoration: none !important;
    color: inherit !important;
    width: 100% !important;
    min-height: 250px;
}

.amazon-offerte-large-card .amazon-offerte-card-img-box {
    width: 220px !important;
    min-width: 220px !important;
    height: 220px !important;
    position: relative;
    border-right: 1px solid #eee;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background: #fff;
}

.amazon-offerte-large-card .amazon-offerte-card-info {
    flex-grow: 1;
    padding: 15px 20px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-width: 0;
}

.amazon-offerte-large-card .amazon-offerte-card-description {
    margin: 10px 0 !important;
    font-size: 0.9em !important;
    line-height: 1.4 !important;
    color: #444 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.amazon-offerte-footer-nav {
    background: #fff;
    border: 1px solid #FF9900;
    border-radius: 50%;
    width: 30px; /* Più piccole */
    height: 30px; /* Più piccole */
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: absolute;
    z-index: 100;
    font-size: 18px; /* Più piccole */
    color: #FF9900;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.amazon-offerte-footer-nav:hover {
    background: #FF9900;
    color: #fff;
}

.amazon-offerte-footer-prev { left: 5px; top: 50%; transform: translateY(-50%); }
.amazon-offerte-footer-next { right: 5px; top: 50%; transform: translateY(-50%); }

.amazon-offerte-article-footer-box .amazon-offerte-footer-track-wrap {
    position: relative;
    padding: 0 40px; /* Spazio per le frecce esterne */
}

.amazon-offerte-article-footer-box .amazon-offerte-footer-nav {
    top: 50%;
    transform: translateY(-50%);
}

.amazon-offerte-article-footer-box .amazon-offerte-footer-prev { left: 0; }
.amazon-offerte-article-footer-box .amazon-offerte-footer-next { right: 0; }

/* 2. Narrow Footer Box (Fisso) */
.amazon-offerte-narrow-footer-box {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    width: 320px !important;
    background: #fff !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3) !important;
    z-index: 2147483647 !important; /* Massimo valore possibile per stare sopra tutto */
    overflow: hidden !important;
    border: 2px solid #FF9900 !important;
    display: block !important; /* Forza visibilità */
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
}

/* Nascondiamo solo se esplicitamente rimosso o con stile inline da JS */
.amazon-offerte-narrow-footer-box[style*="display: none"] {
    display: none !important;
}

.amazon-offerte-narrow-header {
    background: #232f3e;
    color: #fff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.amazon-offerte-narrow-logo { height: 18px; margin-right: 8px; }
.amazon-offerte-narrow-title { font-size: 0.9em; font-weight: 700; flex-grow: 1; }
.amazon-offerte-narrow-close { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }

.amazon-offerte-narrow-viewport { 
    overflow: hidden; 
    width: 100%; 
    background: #fff;
}
.amazon-offerte-narrow-track { 
    display: flex; 
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); 
}

.amazon-offerte-narrow-card {
    flex: 0 0 100%;
    width: 100%;
    background: #fff;
}

.amazon-offerte-narrow-card .amazon-offerte-card-inner {
    padding: 0;
}

.amazon-offerte-narrow-card .amazon-offerte-card-link {
    flex-direction: column;
}

.amazon-offerte-narrow-card .amazon-offerte-card-img-box {
    width: 100% !important;
    height: 180px !important;
    border-right: none;
    border-bottom: 1px solid #f0f0f0;
    display: flex !important;
}

.amazon-offerte-narrow-card .amazon-offerte-card-img {
    max-height: 160px !important;
    object-fit: contain !important;
}

.amazon-offerte-narrow-footer-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    gap: 10px;
}

.amazon-offerte-narrow-cta-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

.amazon-offerte-narrow-cta-container .cta-btn {
    width: 100%;
    padding: 8px 12px !important;
    font-size: 0.95em !important;
    margin: 0 !important;
    cursor: pointer;
    display: block !important;
    text-align: center;
}

.amazon-offerte-narrow-nav {
    background: #fff;
    border: 1px solid #FF9900;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px;
    border-radius: 50% !important;
    cursor: pointer;
    font-size: 20px;
    color: #FF9900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 0;
    line-height: 1;
    transition: all 0.2s;
}

/* Nascondiamo il pulsante originale nel box stretto perché lo sposteremo nelle frecce */
.amazon-offerte-narrow-card .amazon-offerte-card-btn-box {
    display: none !important;
}

@media (max-width: 1024px) {
    .amazon-offerte-large-card .amazon-offerte-card-link-wrapper { flex-direction: column; }
    .amazon-offerte-large-card .amazon-offerte-card-img-box { width: 100%; height: 180px; border-right: none; }
    .amazon-offerte-narrow-footer-box { display: none !important; }
}
