
/* ============ VARIABLES CSS ============ */
:root {
  --primary-color: #2196F3;
  --secondary-color: #FF9800;
  --success-color: #4CAF50;
  --danger-color: #F44336;
  --warning-color: #FFC107;
  --info-color: #9C27B0;
  --dark-color: #343a40;
  --light-color: #f8f9fa;
  --sidebar-width: 250px;
  --header-height: 70px;
  --border-radius: 8px;
  --shadow: 0 2px 10px rgba(0,0,0,0.1);
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

/* ============ LAYOUT ============ */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  background: white;
  box-shadow: var(--shadow);
  position: fixed;
  height: 100vh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.logo {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #eee;
}

.logo i {
  font-size: 24px;
  color: var(--primary-color);
}

.logo h2 {
  font-size: 18px;
  font-weight: 600;
}

.nav-menu {
  flex: 1;
  padding: 20px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  color: #666;
  text-decoration: none;
  transition: var(--transition);
  position: relative;
}

.nav-item i {
  width: 24px;
  margin-right: 12px;
  font-size: 18px;
}

.nav-item:hover {
  background: #f8f9fa;
  color: var(--primary-color);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(33, 150, 243, 0.1), transparent);
  color: var(--primary-color);
  border-right: 3px solid var(--primary-color);
}

.badge {
  background: var(--danger-color);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  position: absolute;
  right: 20px;
}

/* ============ MAIN CONTENT ============ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.header {
  background: white;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  height: var(--header-height);
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
}

.subtitle {
  color: #666;
  font-size: 14px;
}

.date-display {
  background: var(--light-color);
  padding: 8px 16px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.stat-info h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 5px;
}

.stat-info p {
  color: #666;
  font-size: 14px;
}

/* ============ VIEWS ============ */
.view-container {
  padding: 0 20px 20px;
}

.view {
  display: none;
}

.view.active-view {
  display: block;
}

.view-header {
  background: white;
  padding: 20px;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  margin-bottom: 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.view-header h2 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============ FILTERS ============ */
.filter-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-weight: 500;
  font-size: 14px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  font-size: 14px;
}

/* ============ BUTTONS ============ */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  font-size: 14px;
}

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

.btn-primary:hover {
  background: #0d8bf2;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

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

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

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

/* ============ TABLES ============ */
.table-container {
  background: white;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

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

thead {
  background: #f8f9fa;
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  font-weight: 600;
  color: #666;
  white-space: nowrap;
}

tr:hover {
  background: #f8f9fa;
}

/* ============ ORDER CARDS ============ */
.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
}

.order-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid;
  transition: var(--transition);
}

.order-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

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

.order-id {
  font-weight: 600;
  color: #333;
  font-size: 16px;
}

.order-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: white;
}

.order-details {
  margin-bottom: 15px;
}

.detail-row {
  display: flex;
  margin-bottom: 8px;
  font-size: 14px;
}

.detail-label {
  width: 80px;
  color: #666;
  flex-shrink: 0;
}

.detail-value {
  flex: 1;
  font-weight: 500;
}

.order-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

/* ============ CRÉNEAUX ============ */
.creneaux-container {
  background: white;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.creneau-section {
  border-bottom: 1px solid #eee;
}

.creneau-header {
  background: #f8f9fa;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.creneau-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.creneau-count {
  background: var(--primary-color);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.creneau-orders {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
}

/* ============ MODALS ============ */
.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;
}

.modal-content {
  background: white;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: white;
}

.close-modal {
  cursor: pointer;
  font-size: 24px;
  color: #666;
  background: none;
  border: none;
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

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

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

/* ============ LOADING ============ */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.9);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

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

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

/* ============ STATUS BADGES ============ */
.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: white;
  display: inline-block;
}

/* ============ EMPTY STATES ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: white;
  border-radius: var(--border-radius);
}

.empty-state i {
  font-size: 48px;
  color: #ddd;
  margin-bottom: 20px;
}

.empty-state h3 {
  margin-bottom: 10px;
  color: #666;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar {
    width: 70px;
  }
  
  .sidebar .logo h2,
  .sidebar .nav-item span,
  .sidebar .user-info span {
    display: none;
  }
  
  .main-content {
    margin-left: 70px;
  }
  
  .header {
    padding: 15px;
  }
  
  .stats-container {
    grid-template-columns: 1fr;
    padding: 15px;
  }
  
  .filter-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .cards-container {
    grid-template-columns: 1fr;
  }
  
  .creneau-orders {
    grid-template-columns: 1fr;
  }
  
  table {
    font-size: 12px;
  }
  
  th, td {
    padding: 8px 10px;
  }
}

@media (max-width: 576px) {
  .view-header {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }
  
  .order-actions {
    flex-direction: column;
  }
  
  .detail-row {
    flex-direction: column;
  }
  
  .detail-label {
    width: 100%;
    margin-bottom: 2px;
    font-size: 12px;
  }
  
  .btn {
    padding: 12px 15px;
    width: 100%;
    justify-content: center;
  }
  
  .modal-content {
    width: 95%;
    margin: 10px;
  }
}

.details-card {
  max-width: 600px;
  width: 95%;
}

.details-card .order-header {
  justify-content: space-between;
  align-items: center;
}

.details-card .close-modal {
  font-size: 22px;
  cursor: pointer;
  color: #999;
}

.details-card .close-modal:hover {
  color: #000;
}

.quantity-badge {
    background: #2196f3;
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: bold;
}

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

.view-header .filters {
    display: flex;
    gap: 10px;
    align-items: center;
}

.table-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px;
    color: #666;
    font-size: 14px;
}

.table-loader i {
    font-size: 18px;
    color: #2196f3;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 15px;
}

.pagination span {
  font-weight: 600;
}

.pagination .btn {
  padding: 6px 10px;
}

#pagination {
  display: none;
}

/* ================== STATS – KPI ================== */

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.stats-kpi-grid .stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stats-kpi-grid .stat-card h3 {
  font-size: 26px;
  margin: 0;
  font-weight: 700;
  color: #222;
}

.stats-kpi-grid .stat-card p {
  margin: 6px 0 0;
  font-size: 14px;
  color: #777;
}

/* ================== STATS – CHARTS ================== */

.stats-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.stats-chart-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}

.stats-chart-card h4 {
  margin: 0 0 10px;
  font-size: 16px;
  color: #333;
}

@media (max-width: 768px) {
  .stats-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 15px;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
}

.stat-content h3 {
  margin: 0;
  font-size: 22px;
  font-weight: bold;
}

.stat-content p {
  margin: 0;
  color: #666;
  font-size: 14px;
}

.stats-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.filter-btn {
  padding: 8px 14px;
  border-radius: 20px;
  border: none;
  background: #eee;
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s;
}

.filter-btn.active {
  background: #2196F3;
  color: #fff;
}

.filter-period {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-period input {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #f5f7fa;
}

.login-card {
  background: #fff;
  padding: 30px;
  border-radius: 12px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  text-align: center;
}

.login-card input {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
}

.login-card button {
  width: 100%;
  padding: 10px;
  background: #2196F3;
  color: #fff;
  border: none;
  border-radius: 6px;
}

#login-error {
  color: red;
  margin-top: 10px;
}

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

