/* --- STILE INTEGRATO --- */
:root {
    --primary-dark: #1e1e2f;
    --secondary-dark: #2c2c3a;
    --accent-color: #00e676;
    --text-color: #e0e0e0;
    --border-color: #444;
    --gold-color: #ffc107;
    --blue-btn: #007bff;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: "Heebo", sans-serif; }

body {
    background-color: var(--primary-dark);
    color: var(--text-color);
    padding-bottom: 120px; /* Spazio extra per bottoni mobile */
}
header {
    position: sticky; top: 0; z-index: 1000;
    background-color: #2c2c3a;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.contenitore-catalogo {
    width: 80%; 
    max-width: 1800px;
    margin: 0 auto;
    padding-top: 20px;
}
h1.titolo-catalogo { 
    color: #fff; text-align: center; margin-bottom: 30px; margin-top: 60px;
    text-transform: uppercase; border-bottom: 2px solid var(--border-color); 
    padding-bottom: 15px; padding-top: 40px; 
    font-size: 24px; letter-spacing: 1px;
}
/* Form Ricerca Flottante */
.form_cerca_fisso {
    position: fixed; top: 120px; left: 20px; z-index: 9999;
    background-color: rgba(44, 44, 58, 0.9); backdrop-filter: blur(8px);
    padding: 8px; border-radius: 50px; border: 1px solid #555;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); display: flex; align-items: center;
    transition: all 0.3s ease;
}
.form_cerca_fisso:hover { border-color: var(--gold-color); box-shadow: 0 6px 20px rgba(255, 193, 7, 0.2); }
.input_cerca_fisso {
    background: transparent; border: none; color: #fff; padding: 5px 10px;
    width: 140px; font-size: 14px; outline: none; margin: 0;
}
.btn_cerca_fisso {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: #0070ba url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>') no-repeat center center;
    background-size: 18px; cursor: pointer; transition: transform 0.2s;
}
.btn_cerca_fisso:hover { transform: scale(1.1); }
/* Filtri */
.filter-bar {
    display: flex; justify-content: center; flex-wrap: wrap;
    gap: 10px; margin-bottom: 30px; padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.filter-btn {
    background-color: var(--secondary-dark); color: #aaa;
    border: 1px solid var(--border-color); padding: 10px 20px;
    border-radius: 20px; text-decoration: none; font-weight: bold;
    font-size: 14px; transition: all 0.3s; text-transform: capitalize;
}
.filter-btn:hover, .filter-btn.active {
    background-color: #00bcd4; color: #fff; border-color: #00bcd4;
    box-shadow: 0 0 10px rgba(0, 188, 212, 0.3);
}
/* Mobile Filters */
.mobile-filters { display: none; }
/* Griglia */
.results-grid {
    display: grid; gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
@media (min-width: 1400px) { .results-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1100px) and (max-width: 1399px) { .results-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 800px) and (max-width: 1099px) { .results-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 799px) { .results-grid { grid-template-columns: 1fr; } }
/* Card */
.card {
    background-color: var(--secondary-dark); border: 1px solid var(--border-color);
    border-radius: 12px; overflow: hidden;
    transition: transform 0.2s; display: flex; flex-direction: column; position: relative;
}
.card:hover { transform: translateY(-5px); border-color: #00bcd4; }
.cat-badge {
    position: absolute; top: 7px; right: 5px;
    background-color: rgba(0,0,0,0.7); color: #fff; font-size: 10px;
    padding: 2px 6px; border-radius: 4px; text-transform: uppercase; z-index: 10;
}
.cat-badge {
    text-decoration: underline;
    background-color: #dc3545; color: #fff; font-size: 12px;    
}
.cat-home {
    position: absolute; top: 7px; left: 5px;
    background-color: rgba(0,0,0,0.7); color: #fff; font-size: 10px;
    padding: 2px 6px; border-radius: 4px; text-transform: uppercase; z-index: 10;
}
.cat-home {
    text-decoration: underline;
    background-color: #25acef; color: #fff; font-size: 12px;    
}
.card-img-link { background-color: #fff; display: block; padding: 10px; border-bottom: 1px solid var(--border-color); }
.card-img-top { width: 100%; height: 160px; object-fit: contain; display: block; }
.card-body { padding: 12px; flex: 1; display: flex; flex-direction: column; }
.card-title {text-transform: uppercase; font-size: 15px; font-weight: bold; color: #edbe33; margin-bottom: 1px; line-height: 1.1; height: 40px; overflow: hidden; }

.tech-specs { font-size: 10px; color: #aaa; margin-bottom: 10px; min-height: 20px; display: flex; flex-wrap: wrap; gap: 4px; }
.tech-badge { background: #3a3a50; padding: 2px 6px; border-radius: 8px; color: var(--accent-color); border: 1px solid #444; }

.qta-box { margin-bottom: 5px; font-size: 12px; }
.qta-val-green { color: #28a745; font-weight:bold; }
.qta-val-orange { color: #ffc107; font-weight:bold; }
.qta-val-red { color: #dc3545; font-weight:bold; }

.price-row { margin-top: auto; display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-top: 1px solid #444; padding-top: 10px; }
.price-tag { font-size: 18px; font-weight: bold; color: #00bcd4; }

.btn-group { display: flex; flex-direction: column; gap: 8px; }
.btn-view { background-color: var(--blue-btn); color: white; text-align: center; padding: 8px; border-radius: 6px; text-decoration: none; font-weight: bold; font-size: 13px; transition: 0.3s; }
.btn-view:hover { background-color: #0056b3; }
/* Selettore Quantità */
.qty-action-container { display: flex; gap: 5px; }
.qty-selector { display: flex; align-items: center; background: #1e1e2f; border: 1px solid #444; border-radius: 6px; overflow: hidden; flex: 0 0 90px; }
.qty-btn { background: #3a3a50; color: #fff; border: none; width: 25px; height: 38px; font-weight: bold; cursor: pointer; transition: 0.2s; }
.qty-btn:hover { background: #505070; }
.qty-input { width: 40px; text-align: center; border: none; background: transparent; color: #fff; font-weight: bold; font-size: 14px; height: 38px; margin: 0; padding: 0; -moz-appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.btn-cart-card { flex: 1; background: linear-gradient(135deg, #ffca28, #ffc107); color: white; text-align: center; padding: 0 10px; border-radius: 6px; text-decoration: none; font-weight: bold; font-size: 13px; transition: 0.3s; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; height: 38px; }
.btn-cart-card:hover { filter: brightness(1.1); }
/* --- BOTTONI FISSI --- */
.cart-btn, .cart-btn_vendi, .cart-btn_empty {
    position: fixed !important; right: 20px !important; color: #000 !important;
    padding: 10px 18px !important; border-radius: 50px !important;
    display: flex !important; align-items: center !important; gap: 10px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5) !important; z-index: 99999 !important;
    text-decoration: none !important; font-weight: bold !important; font-size: 15px !important;
    transition: transform 0.3s !important;
}
.cart-btn { top: 120px !important; background: linear-gradient(135deg, #ffca28, #ffc107) !important; }
.cart-btn_vendi { top: 180px !important; background: linear-gradient(135deg, #00e676, #00c853) !important; }
.cart-btn_empty { top: 240px !important; background: linear-gradient(135deg, #ff9800, #f57c00) !important; color: white !important; }
.cart-btn:hover, .cart-btn_vendi:hover, .cart-btn_empty:hover { transform: scale(1.05); }
.cart-count { background: #d32f2f; color: white; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 0.8em; }
.no-results { text-align: center; padding: 50px; color: #aaa; font-size: 18px; grid-column: 1 / -1; }
/* ========================================== */
/* RESPONSIVE MOBILE (< 850px) */
/* ========================================== */
@media screen and (max-width: 850px) {
    .filter-bar { display: none; }
    .mobile-filters { display: block; text-align: center; margin-bottom: 30px; padding: 15px; background-color: #2e2e44; border-radius: 12px; border: 1px solid #444; }
    .mobile-cat-select { background-color: #222236; color: #fff; border: 2px solid #00bcd4; padding: 12px 20px; border-radius: 30px; font-size: 16px; width: 100%; max-width: 350px; outline: none; appearance: none; font-weight: bold; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
    .mobile-filters label { display: block; margin-bottom: 8px; color: var(--gold-color); font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }
    h1.titolo-catalogo { 
    margin-top: 10px;
    }    
    /* Fix Bottoni Flottanti su Mobile */
    .cart-btn, .cart-btn_vendi, .cart-btn_empty {
        width: auto !important; 
        right: 10px !important;
        padding: 8px 12px !important;
        font-size: 12px !important;
        top: auto !important; 
    }
    .cart-btn       { top: 60px !important; }
    .cart-btn_vendi { bottom: 80px !important; }
    .cart-btn_empty { top: 110px !important; }
    /* Fix Ricerca su Mobile */
    .form_cerca_fisso { 
        top: auto; 
        bottom: 20px; 
        left: 20px; 
        background-color: rgba(0, 0, 0, 0.8); 
        border-color: #777;
        width: auto !important; /* Impedisce larghezza 100% */
        max-width: 200px;
    }
    .input_cerca_fisso { width: 110px; font-size: 12px; }
    /* Allarga il contenitore principale al 96% dello schermo */
    .contenitore-catalogo {
        width: 90% !important; 
        padding-top: 10px; /* Un po' meno padding sopra */
    }

    /* (Opzionale) Se vuoi che la griglia usi davvero tutto lo spazio */
    .results-grid {
        gap: 10px; /* Riduce leggermente lo spazio verticale tra le card */
    }
}

/* --- STILE PULSANTE TORNA SU --- */
#btn-back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none; /* Nascosto di default */
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #00e676, #00c853); /* Verde accento */
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 9999; /* Sopra tutto */
    font-size: 24px;
    text-align: center;
    line-height: 50px; /* Centra la freccia verticalmente */
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#btn-back-to-top:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #00c853, #009624);
}

/* ADATTAMENTO MOBILE: Spostalo un po' più in alto se ci sono altri bottoni fissi */
@media screen and (max-width: 850px) {
    #btn-back-to-top {
        bottom: 23px; /* Per non coprire i bottoni del carrello */
        right: 15px;
        width: 45px;
        height: 45px;
        line-height: 45px;
        font-size: 20px;
    }
}