/* ===== VARIABLES ===== */
:root {
    --primary-color: #4a00e0;
    --secondary-color: #8e2de2;
    --accent-color: #00c6ff;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --gray-light: #e9ecef;
    --gray-medium: #6c757d;
    --gray-dark: #343a40;
    --sidebar-width: 250px;
    --header-height: 80px;
    --border-radius: 12px;
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 25px 50px rgba(74, 0, 224, 0.15);
    --focus-ring: 0 0 0 4px rgba(74, 0, 224, 0.3);
}

/* ===== RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-color);
    color: var(--dark-color);
    line-height: 1.6;
}

/* ===== CONTENEUR PRINCIPAL ===== */
.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* ===== EN-TÊTE ===== */
header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 15px;
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.2rem);
    color: var(--dark-color);
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* ===== BOUTONS ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: white;
    color: var(--dark-color);
    border: 2px solid transparent;
    line-height: 1.2;
    text-decoration: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-medium);
    color: white;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background: var(--gray-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.3);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover,
.btn-danger:focus {
    background: #b02a37;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.3);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* ===== STATISTIQUES ===== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.05);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray-medium);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark-color);
    line-height: 1.2;
}

/* ===== GRILLE DES PRODUITS ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.product-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

.product-image {
    height: 200px;
    background: var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-info h3 {
    margin-bottom: 10px;
    font-size: 1.3rem;
    color: var(--dark-color);
    font-weight: 600;
    line-height: 1.3;
}

.product-info .price {
    font-weight: 700;
    color: var(--success-color);
    font-size: 1.5rem;
    margin: 8px 0;
}

.product-info .stock {
    font-size: 0.95rem;
    color: var(--gray-medium);
    margin-bottom: 15px;
}

.product-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
}

.product-actions .btn {
    flex: 1;
    padding: 10px 0;
}

.no-products {
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: var(--gray-medium);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    grid-column: 1 / -1;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    margin: 30px auto;
    padding: 30px 25px;
    width: 95%;
    max-width: 800px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    position: relative;
    border: 1px solid var(--gray-light);
}

.close {
    position: absolute;
    right: 25px;
    top: 20px;
    font-size: 32px;
    font-weight: 700;
    cursor: pointer;
    color: var(--gray-medium);
    line-height: 1;
    transition: var(--transition);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover,
.close:focus {
    color: var(--dark-color);
    background: var(--gray-light);
}

.close:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

#modalTitle {
    font-size: 1.8rem;
    color: var(--dark-color);
    margin-bottom: 25px;
    padding-right: 40px;
    font-weight: 600;
}

/* ===== FORMULAIRE ===== */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.95rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-light);
    border-radius: calc(var(--border-radius) / 1.5);
    font-size: 1rem;
    transition: var(--transition);
    background: white;
    color: var(--dark-color);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(74, 0, 224, 0.15);
}

small {
    display: block;
    margin-top: 6px;
    color: var(--gray-medium);
    font-size: 0.85rem;
}

/* ===== GESTION DES IMAGES ===== */
.image-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 15px 0;
}

.image-item {
    position: relative;
    width: 100px;
    height: 100px;
    border: 2px solid var(--gray-light);
    border-radius: 8px;
    overflow: hidden;
    background: var(--gray-light);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-item .remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border: 2px solid white;
}

.image-item .remove-image:hover,
.image-item .remove-image:focus {
    background: #b02a37;
    transform: scale(1.1);
}

.image-item .main-badge {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: var(--success-color);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    border: 1px solid white;
}

.image-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}

.preview-item {
    width: 100px;
    height: 100px;
    border: 2px solid var(--gray-light);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: var(--gray-light);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .main-checkbox {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(255, 255, 255, 0.9);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--dark-color);
    border: 1px solid var(--primary-color);
}

.preview-item .main-checkbox input {
    width: auto;
    margin-right: 4px;
    accent-color: var(--primary-color);
}

/* ===== ACTIONS DU FORMULAIRE ===== */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.form-actions .btn {
    min-width: 120px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .container {
        padding: 0 15px;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .btn {
        width: 100%;
    }

    .product-actions {
        flex-direction: column;
        gap: 8px;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 15px;
        padding: 20px 15px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .close {
        top: 10px;
        right: 15px;
    }
}

/* ===== ACCESSIBILITÉ ===== */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.error-message {
    background: #f8d7da;
    border: 2px solid var(--danger-color);
    color: #721c24;
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-weight: 500;
}