/* Variables CSS pour style Excel professionnel */
:root {
  --primary-color: #c8102e;
  --primary-hover: #a10c22;
  --excel-blue: #0078d4;
  --excel-blue-hover: #106ebe;
  --excel-green: #107c10;
  --excel-border: #d1d1d1;
  --excel-header-bg: #f2f2f2;
  --excel-selected: #cce8ff;
  --excel-selected-border: #0078d4;
  --excel-hover: #f5f5f5;
  --text-color: #323130;
  --white: #ffffff;
  --shadow-light: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-medium: 0 2px 8px rgba(0, 0, 0, 0.12);
  --border-radius: 4px;
  --transition: all 0.15s ease;
}

/* Reset et base */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 11px;
  line-height: 1.3;
  background-color: #f8f9fa;
  padding: 8px;
  color: var(--text-color);
  margin: 0;
  overflow-x: auto;
  overflow-y: auto;
  padding-bottom: 30px;
}

/* Typography compacte avec espacement amélioré */
h2, h3 {
  color: var(--primary-color);
  font-weight: 600;
  margin: 8px 0 12px 0;
  font-size: 14px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}

h4 {
  font-size: 12px;
  font-weight: 600;
  margin: 0;
  color: var(--text-color);
}

/* Logo compact */
.logo {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  vertical-align: middle;
  object-fit: contain;
}

/* Barres d'actions compactes avec meilleur espacement */
.action-bar {
  background: var(--white);
  border: 1px solid var(--excel-border);
  border-radius: var(--border-radius);
  padding: 8px 10px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-light);
  min-height: 36px;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.action-group::after {
  content: '';
  width: 1px;
  height: 20px;
  background: var(--excel-border);
  margin-left: 8px;
}

.action-group:last-child::after {
  display: none;
}

/* Boutons compacts avec espacement icônes amélioré */
.btn-compact {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: var(--white);
  color: var(--text-color);
  border: 1px solid var(--excel-border);
  border-radius: 2px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 400;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  min-height: 24px;
  line-height: 1;
  user-select: none;
}

.btn-compact:hover {
  background: var(--excel-hover);
  border-color: #c7c7c7;
  transform: translateY(-1px);
}

.btn-compact:active {
  background: #e5e5e5;
  border-color: #ababab;
  transform: translateY(0);
}

.btn-compact:focus {
  outline: 1px solid var(--excel-blue);
  outline-offset: -1px;
}

/* Icônes avec espacement amélioré */
.btn-compact i {
  font-size: 9px;
  min-width: 10px;
  text-align: center;
}

/* Variants de boutons */
.btn-compact.btn-primary {
  background: var(--primary-color);
  color: var(--white);
  border-color: var(--primary-color);
}

.btn-compact.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-compact.btn-success {
  background: var(--excel-green);
  color: var(--white);
  border-color: var(--excel-green);
}

.btn-compact.btn-success:hover {
  background: #0e6e0e;
}

.btn-compact.btn-info {
  background: var(--excel-blue);
  color: var(--white);
  border-color: var(--excel-blue);
}

.btn-compact.btn-info:hover {
  background: var(--excel-blue-hover);
}

.btn-compact.btn-warning {
  background: #ffc107;
  color: #212529;
  border-color: #ffc107;
}

.btn-compact.btn-warning:hover {
  background: #e0a800;
}

.btn-compact.btn-danger {
  background: #dc3545;
  color: var(--white);
  border-color: #dc3545;
}

.btn-compact.btn-danger:hover {
  background: #c82333;
}

.btn-compact.btn-secondary {
  background: #6c757d;
  color: var(--white);
  border-color: #6c757d;
}

.btn-compact.btn-secondary:hover {
  background: #5a6268;
}

.btn-compact:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-compact:disabled:hover {
  background: var(--white);
  border-color: var(--excel-border);
  transform: none;
}

/* Dropdowns compacts avec espacement amélioré */
.dropdown-compact {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  background: var(--white);
  border: 1px solid var(--excel-border);
  padding: 4px 20px 4px 8px;
  font-size: 10px;
  border-radius: 2px;
  cursor: pointer;
  min-width: 100px;
  text-align: left;
  position: relative;
  line-height: 16px;
  height: 24px;
  display: flex;
  align-items: center;
  transition: var(--transition);
  user-select: none;
  gap: 5px;
}

.dropdown-toggle:hover {
  background: var(--excel-hover);
  border-color: #c7c7c7;
}

.dropdown-toggle::after {
  content: '';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 3px solid var(--text-color);
  transition: var(--transition);
}

.dropdown-toggle.active::after {
  transform: translateY(-50%) rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--white);
  border: 1px solid var(--excel-border);
  border-radius: 2px;
  box-shadow: var(--shadow-medium);
  z-index: 1000;
  min-width: 150px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  animation: fadeIn 0.15s ease;
  margin-top: 2px;
}

.dropdown-menu.show {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 10px;
  color: var(--text-color);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  line-height: 1.2;
  transition: var(--transition);
  user-select: none;
}

.dropdown-item:hover:not(.disabled) {
  background: var(--excel-hover);
}

.dropdown-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown-item i {
  width: 12px;
  font-size: 9px;
  text-align: center;
  flex-shrink: 0;
}

/* Cartes compactes pour tableaux avec espacement amélioré */
.card {
  background: var(--white);
  border: 1px solid var(--excel-border);
  border-radius: var(--border-radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-medium);
}

.card-header {
  padding: 8px 12px;
  background: var(--excel-header-bg);
  border-bottom: 1px solid var(--excel-border);
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 32px;
  gap: 10px;
}

.card-header h4 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-body {
  padding: 8px;
}

/* Indicateur de tableau actif avec espacement */
.table-indicator {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--excel-green);
  display: none;
  box-shadow: 0 0 4px rgba(16, 124, 16, 0.5);
}

.card.table-active {
  border-color: var(--excel-blue);
  box-shadow: 0 0 8px rgba(0, 123, 255, 0.3);
}

.card.table-active .table-indicator {
  display: block;
}

/* Indicateurs d'affichage avec espacement */
.display-mode-indicator {
  font-size: 9px;
  color: #666;
  margin-right: 20px;
}

/* Tables style Excel ultra-compactes */
table.dataTable {
  width: auto;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 9px;
  border: 1px solid var(--excel-border);
  background: var(--white);
  table-layout: auto;
}

table.dataTable thead {
  background: var(--excel-header-bg);
  color: var(--text-color);
  border-bottom: 2px solid var(--excel-border);
}

table.dataTable thead th {
  padding: 3px 6px;
  font-weight: 600;
  text-align: left;
  border-right: 1px solid var(--excel-border);
  border-bottom: 1px solid var(--excel-border);
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
  position: relative;
  user-select: none;
  cursor: default;
  height: 20px;
  vertical-align: middle;
  line-height: 1.1;
  white-space: nowrap;
  min-width: max-content;
  font-size: 8px;
  transition: var(--transition);
}

table.dataTable thead th:last-child {
  border-right: none;
}

table.dataTable thead th:hover {
  background: linear-gradient(180deg, #f0f0f0 0%, #e6e6e6 100%);
}

table.dataTable thead th:active {
  background: linear-gradient(180deg, #d4e7fd 0%, #c2dafe 100%);
}

table.dataTable tbody td {
  padding: 2px 6px;
  border-right: 1px solid var(--excel-border);
  border-bottom: 1px solid var(--excel-border);
  vertical-align: middle;
  height: 18px;
  cursor: cell;
  position: relative;
  line-height: 1.1;
  white-space: nowrap;
  min-width: max-content;
  font-size: 8px;
  transition: var(--transition);
}

table.dataTable tbody td:last-child {
  border-right: none;
}

table.dataTable tbody tr:hover {
  background: var(--excel-hover);
}

table.dataTable tbody td:hover {
  background: var(--excel-selected);
}

table.dataTable tbody td:focus {
  outline: 2px solid var(--excel-selected-border);
  outline-offset: -2px;
  background: var(--excel-selected);
}

/* Sélection de lignes et colonnes */
tr.selected-row > td {
  background: #b8daff !important;
  color: black;
}

td.selected-column, th.selected-column {
  background: #d1ecf1 !important;
}

th.selected-column {
  background: var(--excel-blue) !important;
  color: white !important;
}

th.selected-column::after {
  content: '✓';
  margin-left: 6px;
  font-weight: bold;
  font-size: 8px;
}

/* Cellules éditables */
.editable-cell {
  cursor: pointer;
}

.editable-cell:hover {
  background: #e3f2fd !important;
}

.editing-cell {
  background: #e3f2fd !important;
  border: 2px solid #2196f3 !important;
}

.modified-cell {
  background: #fff3cd !important;
  color: #856404 !important;
  font-weight: bold;
}

.cell-editor {
  width: 100%;
  border: none;
  padding: 2px;
  font-size: 8px;
  background: transparent;
  outline: none;
  text-align: center;
  font-family: inherit;
}

/* Icône de suppression avec espacement amélioré */
.fa-trash {
  color: #dc3545;
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
  padding: 4px;
  border-radius: 3px;
  margin-left: 8px;
}

.fa-trash:hover {
  color: #fff;
  background: #dc3545;
  transform: scale(1.1);
}

/* Barre de statut avec espacement amélioré */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  color: #f7fafc;
  padding: 4px 10px;
  font-size: 8px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.15);
  height: 26px;
  font-weight: 500;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.status-item span:first-child {
  margin-right: 2px;
}

.status-badge {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
  font-size: 8px;
  border: 1px solid rgba(255, 193, 7, 0.3);
  margin-left: 2px;
}

/* Inputs compacts avec espacement amélioré */
input[type="text"], 
input[type="number"], 
input[type="file"],
select {
  font-family: inherit;
  font-size: 9px;
  padding: 2px 4px;
  border: 1px solid var(--excel-border);
  border-radius: 2px;
  background: var(--white);
  color: var(--text-color);
  height: 22px;
  line-height: 1.1;
  transition: var(--transition);
  margin: 2px;
}

input[type="text"]:focus, 
input[type="number"]:focus,
input[type="file"]:focus,
select:focus {
  outline: 1px solid var(--excel-blue);
  outline-offset: -1px;
  border-color: var(--excel-blue);
}

/* Selects avec flèche custom et espacement */
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  padding-right: 18px;
}

/* Labels avec espacement */
label {
  margin-right: 6px;
  margin-bottom: 3px;
  display: inline-block;
  font-weight: 500;
}

/* Espacement pour les éléments de contrôle des tables DataTables */
.dataTables_wrapper .dataTables_length {
  margin-bottom: 8px;
}

.dataTables_wrapper .dataTables_filter {
  margin-bottom: 8px;
}

.dataTables_wrapper .dataTables_info {
  margin-top: 8px;
  padding-top: 4px;
}

.dataTables_wrapper .dataTables_paginate {
  margin-top: 8px;
  padding-top: 4px;
}

/* Scrollbars compactes style Excel */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border: 1px solid #a8a8a8;
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

::-webkit-scrollbar-corner {
  background: #f1f1f1;
}

/* Responsive pour petits écrans avec espacement maintenu */
@media (max-width: 768px) {
  body {
    font-size: 10px;
    padding: 6px;
  }
  
  .action-bar {
    padding: 6px 8px;
    gap: 6px;
  }
  
  .action-group {
    gap: 4px;
  }
  
  .btn-compact {
    padding: 3px 6px;
    font-size: 9px;
    min-height: 22px;
    gap: 4px;
  }
  
  .dropdown-toggle {
    min-width: 80px;
    font-size: 9px;
    height: 22px;
    padding: 3px 16px 3px 6px;
  }
  
  .dropdown-item {
    padding: 4px 8px;
    gap: 6px;
  }
  
  table.dataTable {
    font-size: 8px;
  }
  
  table.dataTable thead th {
    font-size: 7px;
    height: 18px;
    padding: 2px 4px;
  }
  
  table.dataTable tbody td {
    font-size: 7px;
    height: 16px;
    padding: 1px 4px;
  }
  
  .status-bar {
    font-size: 7px;
    height: 22px;
    gap: 10px;
    padding: 3px 8px;
  }
  
  .status-item {
    gap: 3px;
  }
  
  .status-badge {
    font-size: 7px;
    padding: 1px 3px;
  }
}

/* Animations subtiles */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.btn-compact:active {
  animation: pulse 0.15s ease;
}

/* États de focus améliorés pour l'accessibilité */
.btn-compact:focus-visible,
.dropdown-toggle:focus-visible {
  outline: 2px solid var(--excel-blue);
  outline-offset: 2px;
}

/* Masquage des éléments non utilisés en mode compact */
.dataTables_length,
.dataTables_filter {
  font-size: 9px;
}

.dataTables_info,
.dataTables_paginate {
  font-size: 8px;
}

/* Optimisations pour la performance */
.card,
.btn-compact,
.dropdown-toggle {
  will-change: transform;
  backface-visibility: hidden;
}