/**
 * Styles principaux de l'application
 * Gestion de Commandes
 */

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

:root {
    /* Couleurs principales */
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    
    /* Couleurs secondaires */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    /* Couleurs de fond */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-dark: #1e293b;
    
    /* Couleurs de texte */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    
    /* Bordures */
    --border-color: #e2e8f0;
    --border-radius: 8px;
    
    /* Ombres */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* =====================================================
   PAGE DE LOGIN
   ===================================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-card {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: var(--text-primary);
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    margin-bottom: 20px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    resize: vertical;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-login {
    width: 100%;
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-login:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-login:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

.error-message {
    padding: 12px;
    background-color: #fee2e2;
    color: var(--danger);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.login-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.test-credentials {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.test-credentials code {
    background-color: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* =====================================================
   HEADER
   ===================================================== */
.header {
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    max-width: 1600px;
    margin: 0 auto;
}

.header-left h1 {
    font-size: 24px;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
}

.btn-logout {
    padding: 8px 16px;
    background-color: var(--danger);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.btn-analytics {
    padding: 8px 16px;
    background-color: #8b5cf6;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    margin-right: 12px;
}

.btn-analytics:hover {
    background-color: #7c3aed;
    transform: translateY(-1px);
}

.btn-users {
    padding: 8px 16px;
    background-color: #10b981;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    margin-right: 12px;
}

.btn-users:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

.btn-back {
    padding: 8px 16px;
    background-color: #64748b;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    margin-right: 12px;
}

.btn-back:hover {
    background-color: #475569;
    transform: translateY(-1px);
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

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

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

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

.badge-non_traite {
    background-color: #fef3c7;
    color: #92400e;
}

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

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content {
    padding: 32px;
    max-width: 1600px;
    margin: 0 auto;
}

.container {
    width: 100%;
}

/* =====================================================
   STATS SECTION
   ===================================================== */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.stat-icon {
    font-size: 40px;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* =====================================================
   ORDERS SECTION
   ===================================================== */
.orders-section {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.btn-refresh {
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Filtres et recherche */
.filters-section {
    margin-bottom: 20px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.search-box {
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: center;
}

.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    background-color: white;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-reset-filters {
    padding: 10px 16px;
    background-color: #64748b;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-reset-filters:hover {
    background-color: #475569;
}

/* =====================================================
   LOADING & ERROR
   ===================================================== */
.loading-spinner {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-container {
    text-align: center;
    padding: 40px 20px;
    color: var(--danger);
}

/* =====================================================
   TABLE
   ===================================================== */
.table-container {
    overflow-x: auto;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.orders-table thead {
    background-color: var(--bg-secondary);
}

.orders-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

/* Colonnes élargies pour meilleure lisibilité */
.orders-table th.col-statut {
    min-width: 140px;
}

.orders-table th.col-livreur {
    min-width: 200px;
}

.orders-table th.col-notes {
    min-width: 300px;
    width: 350px;
}

.orders-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.orders-table tbody tr {
    transition: var(--transition);
}

.orders-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

/* Ligne des commandes traitées - fond vert clair */
.orders-table tbody tr.order-completed {
    background-color: #d1fae5;
}

.orders-table tbody tr.order-completed:hover {
    background-color: #a7f3d0;
}

/* Colonne Date/Heure */
.order-datetime {
    white-space: nowrap;
    font-size: 13px;
}

.order-date {
    font-weight: 600;
    color: var(--text-primary);
}

.order-time {
    color: var(--text-secondary);
    font-size: 12px;
}

.orders-table select,
.orders-table textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}

.orders-table select:focus,
.orders-table textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.orders-table textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    width: 100%;
    min-width: 280px;
}

/* Style pour la colonne Dernière modification */
.last-modified {
    font-style: italic;
    color: var(--text-secondary);
}

.last-modified .order-date {
    color: #6366f1;
    font-weight: 500;
}

.last-modified .order-time {
    color: #818cf8;
}

.btn-save {
    padding: 6px 12px;
    background-color: var(--success);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-save:hover {
    background-color: #059669;
}

.btn-save:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

.btn-comment {
    padding: 6px 12px;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-comment:hover {
    background-color: #2563eb;
}

.btn-comment:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

.btn-pdf {
    padding: 6px 12px;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-pdf:hover {
    background-color: #dc2626;
}

.btn-pdf:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

.btn-edit {
    padding: 6px 12px;
    background-color: #06b6d4; /* Cyan */
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-edit:hover {
    background-color: #0891b2;
    transform: scale(1.05);
}

.btn-edit:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

.btn-reset {
    padding: 6px 12px;
    background-color: #f97316; /* Orange */
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-reset:hover {
    background-color: #ea580c;
    transform: scale(1.05);
}

.btn-reset:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1200px) {
    .header-content {
        padding: 16px 20px;
    }
    
    .main-content {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 16px;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .stats-section {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .btn-refresh {
        width: 100%;
    }
    
    .orders-table {
        font-size: 12px;
    }
    
    .orders-table th,
    .orders-table td {
        padding: 8px;
    }
}

/* =====================================================
   UTILITAIRES
   ===================================================== */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* =====================================================
   DAILY STATISTICS
   ===================================================== */
.daily-stats-section {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-top: 32px;
}

.daily-stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.daily-stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--border-radius);
    padding: 20px;
    color: white;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

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

.daily-stat-date {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.daily-stat-amount {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.daily-stat-count {
    font-size: 14px;
    opacity: 0.85;
}

.daily-stat-count strong {
    font-weight: 600;
}

/* =====================================================
   ANALYTICS PAGE
   ===================================================== */

/* Filtres de période */
.analytics-filters {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.analytics-filters h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.period-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.period-btn {
    padding: 10px 20px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.custom-dates {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* KPI Cards */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    color: white;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.kpi-icon {
    font-size: 48px;
    opacity: 0.9;
}

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1;
}

.kpi-label {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 500;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-container {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.chart-container h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.chart-container canvas {
    max-height: 300px;
}

/* Top Products */
.top-products-section {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 32px;
}

.top-products-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.top-products-list {
    display: grid;
    gap: 12px;
}

.product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.product-item:hover {
    background-color: #e2e8f0;
    transform: translateX(5px);
}

.product-rank {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 40px;
}

.product-info {
    flex: 1;
    margin: 0 16px;
}

.product-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.product-count {
    font-size: 13px;
    color: var(--text-secondary);
}

.product-amount {
    font-size: 16px;
    font-weight: 600;
    color: var(--success);
}

/* =====================================================
   USERS PAGE
   ===================================================== */

.users-header {
    margin-bottom: 24px;
}

.btn-create-user {
    padding: 12px 24px;
    background-color: var(--success);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-create-user:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

.users-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.users-filters .filter-select {
    flex: 0 0 200px;
}

.users-filters .search-input {
    flex: 1;
    min-width: 300px;
}

.users-section {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    min-height: 400px;
}

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

.users-table thead {
    background-color: var(--bg-secondary);
}

.users-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.users-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.users-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.btn-edit {
    padding: 6px 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    margin-right: 8px;
    transition: var(--transition);
}

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

.btn-delete {
    padding: 6px 12px;
    background-color: var(--danger);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-delete:hover {
    background-color: #dc2626;
}

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

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

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

.modal-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.modal form {
    padding: 24px;
}

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

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

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

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 12px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-cancel {
    padding: 10px 20px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-cancel:hover {
    background-color: #e2e8f0;
}

.btn-submit {
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-submit:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

/* Message container */
.message-container {
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 24px;
    font-weight: 500;
}

.message-container.success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.message-container.error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* Responsive */
@media (max-width: 768px) {
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .kpi-section {
        grid-template-columns: 1fr;
    }
    
    .period-buttons {
        flex-direction: column;
    }
    
    .period-btn {
        width: 100%;
    }
    
    .users-filters {
        flex-direction: column;
    }
    
    .users-filters .filter-select,
    .users-filters .search-input {
        width: 100%;
        flex: none;
    }
    
    .users-table {
        font-size: 13px;
    }
    
    .users-table th,
    .users-table td {
        padding: 8px;
    }
}

/* ============================================
   MODAL DES NOTES
   ============================================ */

.modal-notes {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Info commande */
.notes-order-info {
    background: #f0f9ff;
    border-left: 4px solid #3b82f6;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.order-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.order-info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.order-info-item strong {
    color: #1e40af;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.order-info-item span {
    color: #1f2937;
    font-size: 16px;
    font-weight: 500;
}

/* Liste des notes */
.notes-list {
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.notes-count {
    background: #f3f4f6;
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-weight: 600;
    color: #4b5563;
    text-align: center;
}

/* Note individuelle */
.note-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.2s;
}

.note-item:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.note-item.deletable {
    border-left-color: #10b981;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.note-author {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.note-number {
    background: #3b82f6;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.note-author strong {
    color: #1f2937;
    font-size: 15px;
}

.note-role {
    font-size: 11px;
    padding: 3px 10px;
}

.note-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #6b7280;
}

.note-date,
.note-time {
    white-space: nowrap;
}

.btn-delete-note {
    background: #ef4444;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-delete-note:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.note-content {
    color: #374151;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 10px;
    background: #f9fafb;
    border-radius: 6px;
}

/* Formulaire nouvelle note */
.notes-form {
    background: #f0fdf4;
    border: 2px dashed #10b981;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.notes-form h3 {
    color: #059669;
    margin-bottom: 15px;
    font-size: 16px;
}

.notes-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.notes-form textarea:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.notes-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

#noteCharCount {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.btn-primary {
    background: #10b981;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Messages vides et erreurs */
.empty-notes {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.empty-notes p {
    font-size: 16px;
    margin: 0;
}

.error-message {
    text-align: center;
    padding: 40px 20px;
}

.error-message p {
    color: #ef4444;
    font-size: 16px;
    margin-bottom: 15px;
}

.btn-retry {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-retry:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    background: #10b981;
    color: white;
}

.notification-error {
    background: #ef4444;
    color: white;
}

/* Responsive modal notes */
@media (max-width: 768px) {
    .modal-notes {
        max-width: 95%;
        margin: 20px auto;
    }
    
    .order-info-grid {
        grid-template-columns: 1fr;
    }
    
    .note-header {
        flex-direction: column;
        align-items: start;
    }
    
    .note-meta {
        width: 100%;
        justify-content: space-between;
    }
    
    .notes-form-footer {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .btn-primary {
        width: 100%;
    }
}

/* ============================================
   COMMANDES LIVRÉES (delivered_at défini)
   ============================================ */

/* Ligne de commande livrée - fond jaune */
.orders-table tbody tr.delivered {
    background-color: #fef3c7 !important;
}

.orders-table tbody tr.delivered:hover {
    background-color: #fde68a !important;
}

/* Badge "LIVRÉ" dans la colonne statut */
.status-delivered {
    background-color: #f59e0b;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

/* Icône dans la première colonne pour les commandes livrées */
.orders-table tbody tr.delivered td:first-child::before {
    content: '✅ ';
    font-size: 14px;
    margin-right: 5px;
}

/* =====================================================
   COMMANDES LOGISTIQUE
   ===================================================== */

/* Commandes assignées au LOGISTICIEN (BLEU) - En attente de répartition */
.orders-table tbody tr.assigned-to-logistic {
    background-color: #dbeafe !important;
}

.orders-table tbody tr.assigned-to-logistic:hover {
    background-color: #bfdbfe !important;
}

.orders-table tbody tr.assigned-to-logistic td:first-child::before {
    content: '🔵 ';
    font-size: 14px;
    margin-right: 5px;
}

/* Commandes réparties par logisticien (VERT) */
.orders-table tbody tr.assigned-by-logistic {
    background-color: #d1fae5 !important;
}

.orders-table tbody tr.assigned-by-logistic:hover {
    background-color: #a7f3d0 !important;
}

.orders-table tbody tr.assigned-by-logistic td:first-child::before {
    content: '🟢 ';
    font-size: 14px;
    margin-right: 5px;
}

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    flex-wrap: wrap;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 14px;
}

.pagination-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-pagination {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-pagination:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-pagination:disabled {
    background: var(--border-color);
    color: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

.pagination-pages {
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
}

.pagination-pages strong {
    color: var(--text-primary);
}

.per-page-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.per-page-select:hover {
    border-color: var(--primary-color);
}

.per-page-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.pagination-controls label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .pagination-controls {
        justify-content: center;
    }
    
    .pagination-info {
        text-align: center;
    }
}


/* =====================================================================
   NOUVELLES FONCTIONNALITÉS — Livraison
   ===================================================================== */

/* Badge Partenaire */
.badge-partenaire {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

/* ── Bouton Frais de livraison ──────────────────────────────────────── */
.btn-frais {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-frais:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(16,185,129,.35);
}
.btn-frais-done {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}
.btn-frais-done:hover {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    box-shadow: 0 3px 8px rgba(99,102,241,.35);
}

/* ── Bouton Notes (Partenaire) ─────────────────────────────────────── */
.btn-notes-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-notes-only:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(245,158,11,.35);
}

/* ── Bouton Affectation boutiques ──────────────────────────────────── */
.btn-boutiques {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-boutiques:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(245,158,11,.35);
}

/* ── Modal Frais ───────────────────────────────────────────────────── */
.modal-frais {
    max-width: 480px;
    width: 95%;
}
.frais-info-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.frais-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border, #e2e8f0);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    transition: border-color 0.2s;
}
.frais-input:focus {
    outline: none;
    border-color: #10b981;
}

/* ── Modal Boutiques ───────────────────────────────────────────────── */
.modal-boutiques {
    max-width: 520px;
    width: 95%;
}
.boutiques-checklist {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px 2px;
}
.boutique-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-size: 0.9rem;
}
.boutique-checkbox-item:hover {
    background: #eff6ff;
    border-color: #6366f1;
}
.boutique-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #6366f1;
    cursor: pointer;
}

/* ── Section Analytics Frais ───────────────────────────────────────── */
.frais-analytics-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 2px solid var(--border, #e2e8f0);
}
.frais-analytics-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary, #1e293b);
}
.kpi-frais {
    border-left: 4px solid #10b981 !important;
}
.frais-table-section {
    margin-top: 24px;
}
.frais-table-section h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary, #1e293b);
}

/* ── Flash message ─────────────────────────────────────────────────── */
.flash-message {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 12px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.92rem;
    box-shadow: 0 6px 20px rgba(0,0,0,.15);
    z-index: 9999;
    transition: opacity 0.4s ease;
}
.flash-success {
    background: #10b981;
    color: #fff;
}
.flash-error {
    background: #ef4444;
    color: #fff;
}

/* Période indépendante section frais */
.frais-period-filter {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: 10px;
    border: 1px solid var(--border, #e2e8f0);
}
.frais-custom-dates {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Bouton affectation livreurs (logisticien) */
.btn-livreurs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-livreurs:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(59,130,246,.35);
}

/* Bouton affectation pays */
.btn-pays {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-pays:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(16,185,129,.35);
}
