/* Reset et Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Couleurs Agir Ensemble - Thème principal */
    --primary: #EC4899;
    --primary-dark: #BE185D;
    --primary-light: #FCE7F3;

    /* Couleurs système */
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Anciennes variables pour compatibilité */
    --pink-primary: #EC4899;
    --pink-dark: #BE185D;
    --pink-light: #FCE7F3;
    --purple-dark: #3B2F4A;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.6;
}

/* Page de connexion */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-page-pink {
    background: linear-gradient(135deg, var(--pink-primary) 0%, var(--pink-dark) 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-header {
    background: var(--primary);
    color: white;
    padding: 30px;
    text-align: center;
}

.login-header-pink {
    background: linear-gradient(135deg, var(--pink-primary) 0%, var(--pink-dark) 100%);
}

.login-header h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.login-subtitle {
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 500;
}

.login-form {
    padding: 30px;
}

.login-footer {
    padding: 20px 30px;
    background: var(--light);
    text-align: center;
    color: var(--secondary);
}

.btn-pink {
    background: var(--pink-primary) !important;
}

.btn-pink:hover {
    background: var(--pink-dark) !important;
}

/* Header */
.main-header {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 3px solid var(--primary);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary);
}

.logo-text {
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-image {
    height: 45px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}

.logo-icon {
    font-size: 1.5rem;
}

.login-logo {
    width: auto;
    height: 100px;
    max-width: 200px;
    margin-bottom: 20px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.main-nav {
    display: flex;
    gap: 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: var(--dark);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-link:hover {
    background: var(--light);
    color: var(--primary);
}

.nav-logout {
    color: var(--danger);
}

.nav-logout:hover {
    background: #fef2f2;
}

/* Menu déroulant */
.nav-dropdown {
    position: relative;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    justify-content: flex-start;
}

.dropdown-arrow {
    font-size: 0.7em;
    margin-left: 4px;
    transition: transform 0.2s;
}

.dropdown-menu.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    padding: 8px 0;
    margin-top: 8px;
    display: none !important;
    z-index: 1000;
}

.dropdown-menu.active {
    display: block !important;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--dark);
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: var(--light);
    color: var(--primary);
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 3px;
    background: var(--dark);
    border-radius: 2px;
    transition: 0.3s;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h1 {
    font-size: 2rem;
    color: var(--dark);
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.3rem;
    color: var(--dark);
}

.card-body {
    padding: 20px;
}

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

.stat-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-card.alert {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

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

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--dark);
}

.stat-label {
    color: var(--secondary);
    font-size: 0.9rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--light);
    font-weight: 600;
    color: var(--dark);
}

.table tbody tr:hover {
    background: var(--light);
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.text-muted {
    color: var(--secondary);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-secondary:hover {
    background: #475569;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-large {
    padding: 14px 28px;
    font-size: 1.1rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.category-filter {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    min-width: 200px;
}

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

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

/* Search Bar */
.search-bar {
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--dark);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 20px;
}

/* Sale Grid */
.sale-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Sale Filters */
.sale-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.sale-filters .search-input {
    flex: 1;
    min-width: 200px;
}

.sale-filters .category-filter {
    min-width: 180px;
}

/* Products List */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
    margin-top: 15px;
}

.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--light);
    border-radius: 8px;
    transition: all 0.2s;
}

.product-item:hover {
    background: #e2e8f0;
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    color: var(--dark);
}

.product-category {
    font-size: 0.8rem;
    color: var(--secondary);
    margin: 2px 0;
}

.product-price {
    color: var(--primary);
    font-weight: 600;
    margin: 4px 0;
}

.product-stock {
    font-size: 0.85rem;
    color: var(--secondary);
}

/* Cart */
.cart-items {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 15px;
    align-items: center;
    padding: 12px;
    background: var(--light);
    border-radius: 8px;
    margin-bottom: 10px;
}

.cart-item-info {
    min-width: 0;
}

.cart-item-name {
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-price {
    font-size: 0.85rem;
    color: var(--secondary);
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-quantity {
    width: 60px;
    text-align: center;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.cart-item-subtotal {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--light);
    border-radius: 8px;
    margin-bottom: 20px;
}

.total-label {
    font-size: 1.2rem;
    font-weight: 600;
}

.total-amount {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.cart-actions {
    display: flex;
    gap: 10px;
}

.cart-actions .btn {
    flex: 1;
}

/* Sale Info */
.sale-info {
    background: var(--light);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.sale-info p {
    margin-bottom: 8px;
}

/* Ranking medals */
.rank-medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: bold;
    color: white;
    font-size: 0.9rem;
}

.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.4);
}

.rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #A8A8A8);
    box-shadow: 0 2px 4px rgba(192, 192, 192, 0.4);
}

.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #B8722F);
    box-shadow: 0 2px 4px rgba(205, 127, 50, 0.4);
}

.rank-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--light);
    color: var(--secondary);
    font-weight: 600;
}

/* Responsive */
@media (max-width: 1024px) {
    .sale-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
    
    .main-nav {
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 10px;
        box-shadow: var(--shadow);
        display: none;
    }
    
    .main-nav.active {
        display: flex;
    }
    
    .nav-link {
        width: 100%;
        padding: 12px 16px;
    }

    .nav-dropdown {
        width: 100%;
    }

    .dropdown-toggle {
        width: 100%;
    }

    .dropdown-toggle .dropdown-arrow {
        margin-left: auto;
    }

    .dropdown-menu {
        position: static;
        box-shadow: none;
        border-left: 2px solid var(--primary);
        margin: 0 0 10px 20px;
        padding: 0;
        background: transparent;
        display: none;
    }

    .dropdown-menu.active {
        display: block;
    }

    .dropdown-item {
        padding: 8px 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .hide-mobile {
        display: none !important;
    }
    
    .mobile-only {
        display: block;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
    }
    
    .cart-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .cart-item-controls {
        justify-content: center;
    }
    
    .cart-item-subtotal {
        text-align: center;
    }
    
    .cart-actions {
        flex-direction: column;
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none;
    }
}

/* Product Photos */
.product-photo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
    margin-right: 12px;
    flex-shrink: 0;
    background: white;
    padding: 4px;
}

.product-photo-placeholder {
    width: 60px;
    height: 60px;
    background: var(--light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 12px;
    flex-shrink: 0;
}

.product-item {
    display: flex;
    align-items: center;
    gap: 0;
}

.badge-secondary {
    background: #e2e8f0;
    color: #475569;
}

/* Lightbox pour affichage des images en grand */
.lightbox {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.85) !important;
    z-index: 9999 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 40px !important;
    animation: fadeIn 0.3s ease;
}

.lightbox.active {
    display: flex !important;
}

.lightbox-content {
    position: relative !important;
    width: 500px !important;
    height: 500px !important;
    max-width: 500px !important;
    max-height: 500px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    animation: zoomIn 0.3s ease;
}

.lightbox-image {
    width: 100% !important;
    height: 100% !important;
    max-width: 500px !important;
    max-height: 500px !important;
    object-fit: contain !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7) !important;
    background: white !important;
    padding: 15px !important;
}

.lightbox-close {
    position: absolute !important;
    top: -45px !important;
    right: 0 !important;
    background: white !important;
    color: var(--dark) !important;
    border: none !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    font-size: 26px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    line-height: 1 !important;
    z-index: 10000 !important;
}

.lightbox-close:hover {
    background: var(--primary) !important;
    color: white !important;
    transform: rotate(90deg) scale(1.1) !important;
}

/* Images cliquables */
img.clickable-image {
    cursor: zoom-in !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
}

img.clickable-image:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3) !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Responsive lightbox */
@media (max-width: 768px) {
    .lightbox {
        padding: 20px !important;
    }

    .lightbox-content {
        width: 90vw !important;
        height: 90vw !important;
        max-width: 400px !important;
        max-height: 400px !important;
    }

    .lightbox-image {
        max-width: 100% !important;
        max-height: 100% !important;
        padding: 10px !important;
    }

    .lightbox-close {
        top: -35px !important;
        right: 0 !important;
    }
}