/* =============================================== */
/* NUOVO STILE ELEGANTE - v2.1 CORRETTO            */
/* =============================================== */

/* --- 1. Import del Font e Variabili Globali --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --font-primary: 'Inter', sans-serif;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-primary: #212529;      /* Nero */
    --text-secondary: #6c757d;
    --accent-color: #212529;      /* <-- MODIFICATO: Nero come colore primario */
    --accent-color-hover: #495057; /* <-- MODIFICATO: Grigio scuro per hover */
    --danger-color: #ee7504;
    --border-color: #dee2e6;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* --- 2. Stili Generali e Reset --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background-color: var(--background-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 3rem auto; /* Aumentato lo spazio verticale */
    padding: 20px;
}

/* --- 3. Header (Home Page e Pagina Collezione) --- */
.home-header {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

/* NUOVO: Regole specifiche per allineare l'header di Collezione */
.page-header {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-left: 24px;  /* <-- Questo allinea tutto col testo dell'articolo */
    padding-right: 24px;
}

.main-title-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.home-header h1, .main-title-area h1 {
    font-size: 2.25rem; /* 36px */
    font-weight: 700;
    margin: 0; /* Rimuove i margini per non sfalsare le righe */
}

/* --- 4. Card della Collezione (Home Page) --- */
#collections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

.collection-card {
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.collection-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.06), 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-content {
    padding: 24px;
    flex-grow: 1;
}

.card-content h3 {
    font-size: 1.25rem; /* 20px */
    font-weight: 600;
    margin-bottom: 8px;
}

.card-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.card-actions {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* --- 5. Pulsanti --- */
.btn-main, .btn-secondary, .btn-apply, .btn-add, .btn-add-lg, .card-actions button {
    padding: 10px 15px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-primary);
    transition: all 0.2s ease-in-out;
    font-size: 0.9rem;
}

.btn-main, .btn-apply {
    background-color: var(--accent-color);
    color: white;
}
.btn-main:hover, .btn-apply:hover {
    background-color: var(--accent-color-hover);
}

.btn-secondary {
    background-color: #e9ecef;
    color: var(--text-primary);
    border-color: #dee2e6;
}
.btn-secondary:hover {
    background-color: #ced4da;
}

.btn-add, .btn-download-row {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    flex-shrink: 0;
    /* NUOVO: Usiamo flexbox per centrare perfettamente l'icona */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Stile specifico per l'icona SVG */
.btn-download-row svg {
    font-size: 1.5rem;
    width: 18px;
    height: 18px;
    stroke: currentColor; /* Il colore sarà lo stesso del testo (bianco) */
}

/* Stile per il '+' per non farlo troppo grande */
.btn-add {
    font-size: 1.5rem;
    font-weight: 400;
}
.btn-download-row:hover {
    background-color: #5a6268;
}

.card-actions .btn-view {
    flex-grow: 1;
    background-color: var(--accent-color);
    color: white;
}
.card-actions .btn-view:hover {
    background-color: var(--accent-color-hover);
}

.card-actions .btn-delete {
    background-color: transparent;
    color: var(--text-secondary);
    padding: 10px;
}
.card-actions .btn-delete:hover {
    background-color: #f1f3f5;
    color: var(--danger-color);
}


/* --- 6. Stili Pagina Collezione --- */
.filter-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-area select, .search-bar {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: white;
    font-family: var(--font-primary);
    font-size: 0.9rem;
}

.article-item {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 30px;
}

/* CORREZIONE: Selettore .article-header ripristinato */
.article-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 1rem;
}

.article-header h2 {
    font-size: 1.5rem; /* 24px */
    font-weight: 600;
}

.article-header h2 .style-id {
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 12px;
}

/* CORREZIONE: Regola per il layout verticale delle righe */
.color-variants-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
/* --- NUOVA REGOLA DA INSERIRE QUI --- */
.color-variant-row {
    display: flex;
    align-items: center; /* Centra verticalmente testo, immagini e bottoni */
    gap: 15px;
    width: 100%;
}
/* ----------------------------------- */
.color-variant-row .color-label {
    width: 45px; /* Spazio fisso per la sigla colore */
    flex-shrink: 0;
    font-weight: 600;
}

.image-box-container {
    display: flex;
    gap: 15px;
    flex-grow: 1;
    overflow-x: auto;
    padding-bottom: 10px;
}

.image-box {
    position: relative;
    flex-shrink: 0;
    width: 150px;
    aspect-ratio: 1 / 1;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #adb5bd;
    font-weight: 600;
    background-color: #f8f9fa;
    transition: all 0.2s ease-in-out;
}

.image-box.drag-over {
    border-color: var(--accent-color);
    background-color: #fff5f0;
    transform: scale(1.03);
}

.image-box img.preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.image-box .btn-remove-box {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    background-color: var(--danger-color);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    line-height: 24px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease-in-out;
    z-index: 10;
}

.image-box:hover .btn-remove-box {
    opacity: 1;
    transform: scale(1);
}

/* --- 7. Stili per il Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-background);
    padding: 30px 40px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #adb5bd;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 1rem;
}
.row-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;   /* <-- LA CHIAVE: Spinge tutto il blocco a destra */
    flex-shrink: 0;      /* Assicura che i bottoni non si restringano mai */
    align-items: center; /* Mantiene le icone centrate verticalmente */
}
/* Stile per l'indicatore di caricamento (loader) */
.image-box .loader {
    width: 30px;
    height: 30px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-color, #212529); /* Usa nero o arancione */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Stile per il pulsante di download della singola immagine (NUOVA VERSIONE) */
.image-box .btn-download-image {
    position: absolute;
    bottom: 0; /* Allineato in basso */
    left: 0;
    right: 0;
    width: 100%; /* Larghezza totale */
    height: 33.33%; /* Altezza un terzo del box */
    background-color: rgba(0, 0, 0, 0.6); /* Sfondo nero semi-trasparente */
    border-radius: 0 0 8px 8px; /* Arrotonda solo gli angoli inferiori */
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: all 0.2s ease-in-out;
    transform: translateY(10px); /* Parte da leggermente più in basso */
    z-index: 10;
    cursor: pointer;
}

/* Mostra il pulsante quando il mouse è sopra il box */
.image-box:hover .btn-download-image {
    opacity: 1;
    transform: translateY(0); /* Sale nella sua posizione finale */
}

/* Stile per l'icona SVG all'interno del pulsante */
.image-box .btn-download-image svg {
    width: 24px;
    height: 24px;
    stroke: white;
}