/* Variables de couleurs pour le mode clair */
:root {
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --secondary-color: #2ecc71;
    --secondary-hover: #27ae60;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --warning-color: #f39c12;
    --warning-hover: #e67e22;
    --info-color: #1abc9c;
    --info-hover: #16a085;
    
    --bg-color: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-color: #333333;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --table-header-bg: #f1f3f5;
    --table-stripe: #f9f9f9;
    --card-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    --success-bg: rgba(46, 204, 113, 0.15);
    --danger-bg: rgba(231, 76, 60, 0.15);
    --warning-bg: rgba(243, 156, 18, 0.15);
    --info-bg: rgba(26, 188, 156, 0.15);
    
    --chart-color-1: #3498db;
    --chart-color-2: #2ecc71;
    --chart-color-3: #e74c3c;
    --chart-color-4: #f39c12;
    --chart-color-5: #9b59b6;
    --chart-grid: rgba(0, 0, 0, 0.1);
}

/* Variables de couleurs pour le mode sombre */
[data-theme="dark"] {
    --primary-color: #4dabf7;
    --primary-hover: #339af0;
    --secondary-color: #51cf66;
    --secondary-hover: #40c057;
    --danger-color: #ff6b6b;
    --danger-hover: #fa5252;
    --warning-color: #fcc419;
    --warning-hover: #fab005;
    --info-color: #38d9a9;
    --info-hover: #20c997;
    
    --bg-color: #121212;
    --bg-secondary: #1e1e1e;
    --text-color: #e9ecef;
    --text-muted: #adb5bd;
    --border-color: #343a40;
    --table-header-bg: #2c2c2c;
    --table-stripe: #1a1a1a;
    --card-bg: #2c2c2c;
    --shadow-color: rgba(0, 0, 0, 0.5);
    
    --success-bg: rgba(81, 207, 102, 0.15);
    --danger-bg: rgba(255, 107, 107, 0.15);
    --warning-bg: rgba(252, 196, 25, 0.15);
    --info-bg: rgba(56, 217, 169, 0.15);
    
    --chart-color-1: #4dabf7;
    --chart-color-2: #51cf66;
    --chart-color-3: #ff6b6b;
    --chart-color-4: #fcc419;
    --chart-color-5: #cc5de8;
    --chart-grid: rgba(255, 255, 255, 0.1);
}

/* Variables pour le mode industriel (contraste élevé) */
[data-theme="industrial"] {
    --primary-color: #007acc;
    --primary-hover: #005999;
    --secondary-color: #00994d;
    --secondary-hover: #006633;
    --danger-color: #cc0000;
    --danger-hover: #990000;
    --warning-color: #e69500;
    --warning-hover: #b37400;
    --info-color: #0099cc;
    --info-hover: #007399;
    
    --bg-color: #f0f0f0;
    --bg-secondary: #d9d9d9;
    --text-color: #262626;
    --text-muted: #595959;
    --border-color: #8c8c8c;
    --table-header-bg: #bfbfbf;
    --table-stripe: #e6e6e6;
    --card-bg: #f0f0f0;
    --shadow-color: rgba(0, 0, 0, 0.25);
}

/* Styles pour le sélecteur de thème */
.theme-switcher {
    position: fixed;
    top: 80px;
    right: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 2px 8px var(--shadow-color);
    z-index: 1000;
    transition: all 0.3s ease;
}

.theme-switcher h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: var(--text-color);
}

.theme-options {
    display: flex;
    gap: 8px;
}

.theme-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-option.light {
    background-color: #ffffff;
    box-shadow: inset 0 0 0 15px #f8f9fa;
}

.theme-option.dark {
    background-color: #121212;
    box-shadow: inset 0 0 0 15px #2c2c2c;
}

.theme-option.industrial {
    background-color: #f0f0f0;
    box-shadow: inset 0 0 0 15px #d9d9d9;
}

.theme-option.active {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.theme-toggle {
    position: fixed;
    top: 70px;
    right: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow-color);
    z-index: 1001;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Transition douce entre les thèmes */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
    background-color: var(--bg-color);
    color: var(--text-color);
}

h1 { color: var(--text-color); margin-bottom: 25px; }

.theme-toggle {
  position: fixed;                                                                                                                                                                                                                         
  top: 20px;
  right: 20px;
  z-index: 100;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-top: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  overflow: hidden;
  border-radius: 8px;
}

th, td { 
  border: 1px solid var(--border-color); 
  padding: 12px; 
  text-align: center; 
}

th { 
  background: var(--header-bg); 
  position: sticky;
  top: 0;
  cursor: pointer;
}

th:hover {
  background: var(--primary-color);
  color: white;
}

tr:nth-child(even) {
  background-color: rgba(0,0,0,0.03);
}

input[type="number"], input[type="date"], select, input[type="text"] { 
  width: 100%; 
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-color);
}

.btn { 
  padding: 10px 20px; 
  margin-top: 10px; 
  background: var(--primary-color); 
  color: white; 
  border: none; 
  cursor: pointer; 
  border-radius: 4px;
  transition: background 0.3s ease;
}

.btn:hover { background: var(--primary-hover); }

.actions button { 
  margin: 0 5px;
  border: none;
  background: none;
  font-size: 1.2em;
  cursor: pointer;
}

#search { 
  margin: 20px 0; 
  padding: 12px; 
  width: 100%;
  border-radius: 25px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#totalValue { 
  margin-top: 20px; 
  font-weight: bold; 
  font-size: 1.2em;
  padding: 15px;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.print-btn { background: var(--success-color); }

/* Styles pour les formulaires côte à côte */
.form-container {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

#addForm, #removeForm {
  flex: 1;
  min-width: 300px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(0,0,0,0.1);
  transition: background 0.3s ease;
}

/* Style pour les boutons de sélection de mode de prix */
.price-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.price-toggle label {
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.price-toggle label:hover {
  background-color: rgba(0,0,0,0.05);
}

/* Système de carte pour le tableau de bord */
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.card-value {
  font-size: 2em;
  font-weight: bold;
  margin: 10px 0;
}

.card-title {
  color: var(--primary-color);
  font-size: 0.9em;
  text-transform: uppercase;
  margin-bottom: 15px;
}

/* Filtres avancés */
.filters {
  padding: 15px;
  background: var(--card-bg);
  border-radius: 8px;
  margin-bottom: 20px;
  display: none;
  flex-wrap: wrap;
  gap: 15px;
}

.filter-column {
  flex: 1;
  min-width: 200px;
}

/* Ajustements pour responsive */
@media (max-width: 768px) {
  .form-container {
    flex-direction: column;
  }
  
  #addForm, #removeForm {
    width: 100%;
  }
  
  .dashboard {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  /* Amélioration pour le tableau sur mobile */
  table, thead, tbody, th, td, tr {
    display: block;
  }
  
  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  tr {
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
    border-radius: 8px;
    background-color: var(--card-bg);
  }
  
  td {
    border: none;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    padding-left: 50%;
    text-align: right;
  }
  
  td:before {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: bold;
    text-align: left;
  }
  
  /* Étiquettes pour chaque cellule */
  #stockTable td:nth-of-type(1):before { content: "Matériau:"; }
  #stockTable td:nth-of-type(2):before { content: "Format:"; }
  #stockTable td:nth-of-type(3):before { content: "RAL/Finition:"; }
  #stockTable td:nth-of-type(4):before { content: "Quantité:"; }
  #stockTable td:nth-of-type(5):before { content: "Poids/unité:"; }
  #stockTable td:nth-of-type(6):before { content: "Poids total:"; }
  #stockTable td:nth-of-type(7):before { content: "Prix/tôle:"; }
  #stockTable td:nth-of-type(8):before { content: "Prix/m²:"; }
  #stockTable td:nth-of-type(9):before { content: "Prix/kg:"; }
  #stockTable td:nth-of-type(10):before { content: "Surface:"; }
  #stockTable td:nth-of-type(11):before { content: "Date entrée:"; }
  #stockTable td:nth-of-type(12):before { content: "Fournisseur:"; }
  #stockTable td:nth-of-type(13):before { content: "Actions:"; }
  
  #historyTable td:nth-of-type(1):before { content: "Date:"; }
  #historyTable td:nth-of-type(2):before { content: "Matériau:"; }
  #historyTable td:nth-of-type(3):before { content: "Format:"; }
  #historyTable td:nth-of-type(4):before { content: "RAL/Finition:"; }
  #historyTable td:nth-of-type(5):before { content: "Quantité:"; }
  #historyTable td:nth-of-type(6):before { content: "Référence client:"; }
  
  /* Ajustements pour les filtres */
  .filters {
    flex-direction: column;
  }
  
  .filter-column {
    width: 100%;
  }
  
  /* Ajustements pour les graphiques */
  .charts-container {
    flex-direction: column;
  }
  
  .chart-box {
    width: 100%;
  }
  
  /* Ajustements pour le bouton de thème */
  .theme-toggle {
    width: 35px;
    height: 35px;
    top: 10px;
    right: 10px;
  }
  
  /* Ajustement pour les notifications */
  #syncNotification {
    width: calc(100% - 40px);
    right: 20px;
    bottom: 20px;
  }
}

/* Ajustements pour très petits écrans */
@media (max-width: 480px) {
  body {
    padding: 10px;
  }
  
  h1 {
    font-size: 1.5em;
  }
  
  .card-value {
    font-size: 1.5em;
  }
}

/* Style pour les alertes de stock bas */
.low-stock {
  background-color: rgba(220, 53, 69, 0.1);
}

.low-stock td {
  color: var(--danger-color);
}

/* Conteneur pour graphiques */
.charts-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 20px 0;
}

.chart-box {
  flex: 1;
  min-width: 300px;
  background: var(--card-bg);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Notification de synchronisation améliorée */
#syncNotification {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--success-color);
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  z-index: 1000;
  animation: fadeIn 0.5s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Spinner de chargement */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
  margin-right: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Style pour les modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
}

.modal-content {
  position: relative;
  background: var(--card-bg);
  max-width: 600px;
  margin: 100px auto;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--text-color);
}

/* Status indicator */
.status-indicator {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 10px;
}

.status-online {
  background-color: var(--success-color);
}

.status-offline {
  background-color: var(--danger-color);
}

/* Toast message */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 20px;
  background: var(--success-color);
  color: white;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  display: none;
  z-index: 1000;
}

/* Améliorer la réactivité des tableaux */
@media screen and (max-width: 768px) {
    table.responsive {
        width: 100%;
        border: 0;
    }
    
    table.responsive thead {
        display: none;
    }
    
    table.responsive tr {
        margin-bottom: 20px;
        display: block;
        border: 1px solid var(--border-color);
        border-radius: 5px;
        background-color: var(--card-bg);
        box-shadow: 0 2px 5px var(--shadow-color);
    }
    
    table.responsive td {
        display: block;
        text-align: right;
        padding: 12px 15px;
        position: relative;
        border-bottom: 1px solid var(--border-color);
    }
    
    table.responsive td:last-child {
        border-bottom: 0;
    }
    
    table.responsive td:before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        top: 12px;
        font-weight: bold;
        text-align: left;
        color: var(--text-muted);
    }
    
    table.responsive .action-buttons {
        display: flex;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    table.responsive .action-buttons button {
        margin: 0;
    }
}

/* Indicateur de statut de connexion */
.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 10px;
    position: relative;
}

.status-indicator:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    animation-duration: 1.5s;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
}

.status-online {
    background-color: var(--secondary-color);
}

.status-online:before {
    animation-name: pulse-green;
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
}

.status-offline {
    background-color: var(--danger-color);
}

.status-offline:before {
    animation-name: pulse-red;
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(46, 204, 113, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

/* Styles pour les notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 350px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    display: flex;
    padding: 15px;
    border-radius: 5px;
    background-color: var(--card-bg);
    box-shadow: 0 4px 12px var(--shadow-color);
    margin-bottom: 10px;
    animation: slide-in 0.3s ease-out;
    position: relative;
    overflow: hidden;
    border-left: 4px solid transparent;
}

.notification-success {
    border-left-color: var(--secondary-color);
}

.notification-error {
    border-left-color: var(--danger-color);
}

.notification-warning,
.notification-stock_alert {
    border-left-color: var(--warning-color);
}

.notification-info {
    border-left-color: var(--info-color);
}

.notification-icon {
    margin-right: 15px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
}

.notification-success .notification-icon {
    color: var(--secondary-color);
}

.notification-error .notification-icon {
    color: var(--danger-color);
}

.notification-warning .notification-icon,
.notification-stock_alert .notification-icon {
    color: var(--warning-color);
}

.notification-info .notification-icon {
    color: var(--info-color);
}

.notification-content {
    flex: 1;
    color: var(--text-color);
}

.notification-close {
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 5px;
}

.notification-close:hover {
    color: var(--text-color);
}

.notification.fade-out {
    animation: fade-out 0.3s ease-out forwards;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fade-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Styles pour l'historique des notifications */
.notification-history {
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    padding: 10px;
    border-radius: 5px;
    background-color: var(--bg-secondary);
    border-left: 4px solid transparent;
}

.history-success {
    border-left-color: var(--secondary-color);
}

.history-error {
    border-left-color: var(--danger-color);
}

.history-warning,
.history-stock_alert {
    border-left-color: var(--warning-color);
}

.history-info {
    border-left-color: var(--info-color);
}

.history-icon {
    margin-right: 10px;
}

.history-success .history-icon {
    color: var(--secondary-color);
}

.history-error .history-icon {
    color: var(--danger-color);
}

.history-warning .history-icon,
.history-stock_alert .history-icon {
    color: var(--warning-color);
}

.history-info .history-icon {
    color: var(--info-color);
}

.history-content {
    flex: 1;
}

.history-message {
    margin-bottom: 5px;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}