/* === Gestion Nommage === */

.page_nommage {
  padding: 10px 16px;
  font-size: 10pt;
}

.header-nommage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.header-nommage h1 {
  font-size: 16pt;
  color: var(--main-bg-color);
  margin: 0;
}

/* Toolbar */
.nommage-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 15px;
  background: #f8f9fa;
  border-bottom: 1px solid #ddd;
}

.nommage-toolbar-left,
.nommage-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nommage-search {
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 10pt;
  width: 200px;
}

.nommage-filter-check {
  font-size: 10pt;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.nommage-filter-select {
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 10pt;
}

/* Buttons */
.nommage-btn {
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10pt;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.nommage-btn:hover { background: #f0f0f0; }
.nommage-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.nommage-btn-create { background: #ede7f6; border-color: #7e57c2; color: #5e35b1; }
.nommage-btn-create:hover { background: #d1c4e9; }

.nommage-btn-convention { background: #e8f0fe; border-color: #4285f4; color: #1a73e8; }
.nommage-btn-convention:hover { background: #d2e3fc; }

.nommage-btn-check { background: #fff3e0; border-color: #fb8c00; color: #e65100; }
.nommage-btn-check:hover { background: #ffe0b2; }

.nommage-btn-apply { background: #e8f5e9; border-color: #43a047; color: #2e7d32; }
.nommage-btn-apply:hover { background: #c8e6c9; }

.nommage-btn-sm {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 9pt;
  background: #fff;
}
.nommage-btn-sm:hover { background: #f0f0f0; }
.nommage-btn-sm:disabled { opacity: 0.5; cursor: not-allowed; }

.nommage-btn-check-sm { color: #e65100; border-color: #fb8c00; }
.nommage-btn-apply-sm { color: #2e7d32; border-color: #43a047; }

.nommage-img-count {
  font-size: 8pt;
  color: #888;
  padding: 2px 4px;
}

/* Date d'analyse IA */
.nommage-analyzed-date {
  display: block;
  font-size: 8pt;
  color: #888;
  margin-top: 3px;
  font-style: italic;
}

.nommage-analyzed-date .fa-triangle-exclamation {
  color: #f57f17;
  margin-right: 3px;
}

/* Cellule date de modification produit */
.nommage-td-tms {
  font-size: 9pt;
  color: #666;
  white-space: nowrap;
}
.nommage-btn-img-sm { color: #5e35b1; border-color: #7e57c2; }

/* Nombre d'images Dolibarr (pastille du bouton Images, chargé en arrière-plan) */
.nommage-btn-img-sm { position: relative; }
.nommage-img-count {
  position: absolute; top: -7px; right: -7px;
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  border-radius: 8px; font-size: 7.5pt; font-weight: 700; line-height: 16px; text-align: center;
  color: #fff; pointer-events: none;
}
.nommage-img-count-ok { background: #2e7d32; }
.nommage-img-count-zero { background: #e65100; }
.nommage-img-pending { color: #bbb; letter-spacing: 1px; }
.nommage-img-ok { color: #2e7d32; }
.nommage-img-none { color: #e65100; font-weight: 600; }
.nommage-images-spin { color: #999; margin-left: 4px; font-size: 8pt; }
.nommage-btn-print-sm { color: #00838f; border-color: #00acc1; }

/* Stats */
.nommage-stats {
  display: flex;
  gap: 15px;
  padding: 8px 15px;
  font-size: 9pt;
  background: #fafafa;
  border-bottom: 1px solid #eee;
}

.nommage-stat {
  padding: 2px 8px;
  border-radius: 10px;
  background: #e0e0e0;
}

/* Progress bar */
.nommage-progress-bar {
  height: 4px;
  background: #e0e0e0;
  overflow: hidden;
}

.nommage-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #fb8c00, #43a047);
  transition: width 0.3s ease;
}

/* Table */
.nommage-table-wrapper {
  overflow-x: auto;
}

.nommage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10pt;
}

.nommage-table thead th {
  padding: 8px 10px;
  border-bottom: 2px solid #ddd;
  font-weight: 600;
  font-size: 9pt;
  white-space: nowrap;
}

.nommage-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.nommage-table tbody tr:hover { background: #f0f7ff !important; }

.nommage-th-check,
.nommage-td-check { width: 30px; text-align: center; }

.nommage-ref { font-weight: 600; color: var(--main-bg-color, #333); }

.nommage-td-desc { max-width: 250px; }
.nommage-desc-text { color: #666; font-size: 9pt; }

.nommage-td-remarques { max-width: 200px; font-size: 9pt; color: #555; }

.nommage-td-actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
}

.nommage-selected-row { background: #e3f2fd !important; }

/* Suggestion inline */
.nommage-suggestion {
  margin-top: 3px;
  padding: 2px 6px;
  background: #e8f5e9;
  border-left: 3px solid #43a047;
  border-radius: 2px;
  font-size: 9pt;
  color: #2e7d32;
}

/* Badge statut */
.nommage-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 9pt;
  font-weight: 500;
  white-space: nowrap;
}

.nommage-status-pending { background: #e0e0e0; color: #616161; }
.nommage-status-checking { background: #fff3e0; color: #e65100; }
.nommage-status-conforme { background: #e8f5e9; color: #2e7d32; }
.nommage-status-presque_conforme { background: #fff8e1; color: #f57f17; }
.nommage-status-ameliorable { background: #e0f7fa; color: #00838f; }
.nommage-status-non_conforme { background: #fce4ec; color: #c62828; }
.nommage-status-locked { background: #eceff1; color: #455a64; }
.nommage-status-error { background: #ffebee; color: #b71c1c; }

/* Bouton verrouillage */
.nommage-btn-locked {
  background: #455a64 !important;
  color: #fff !important;
  border-color: #37474f !important;
}
.nommage-btn-locked:hover {
  background: #37474f !important;
}

/* Pagination */
.nommage-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 15px;
  background: #f8f9fa;
  border-top: 1px solid #ddd;
}

.nommage-pagination-info {
  font-size: 10pt;
  color: #555;
  margin: 0 8px;
}

/* Extrafields sub-row */
.nommage-extrafields-row td {
  padding: 0 10px 8px 10px !important;
  background: #fafafa;
  border-bottom: 2px solid #ddd;
}

.nommage-extrafields-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9pt;
}

.nommage-extrafields-table tr:not(:last-child) td {
  border-bottom: 1px solid #eee;
}

.nommage-extrafields-table td {
  padding: 4px 8px;
  vertical-align: top;
}

.nommage-ef-label {
  font-weight: 600;
  color: #555;
  white-space: nowrap;
  width: 150px;
}

.nommage-ef-value {
  color: #333;
}

.nommage-ef-separator td {
  font-weight: 700;
  font-size: 9pt;
  color: #333;
  background: #e8eaf6;
  padding: 5px 8px;
  border-bottom: 2px solid #c5cae9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nommage-ef-suggestion {
  color: #2e7d32;
}

/* Modal buttons */
.nommage-modal-convention .modal-button,
.nommage-modal-detail .modal-button,
.nommage-modal-create .modal-button,
.nommage-modal-success .modal-button,
.nommage-modal-cron .modal-button {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 0;
}

/* Modal cron settings */
.nommage-modal-cron {
  max-width: 600px;
  width: 90%;
}

/* Empty */
.nommage-empty {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 11pt;
}

/* Édition des suggestions IA dans la modal détail */
.nommage-edit-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 10pt;
  box-sizing: border-box;
  font-family: inherit;
}

.nommage-edit-input:focus {
  border-color: #43a047;
  outline: none;
  box-shadow: 0 0 0 2px rgba(67, 160, 71, 0.15);
}

textarea.nommage-edit-input {
  resize: vertical;
}

.nommage-diff-cell {
  background: #fff8e1 !important;
}

/* Click-to-edit : affichage en vue, devient éditable au clic */
.nommage-clik-edit {
  display: inline-block;
  padding: 4px 8px;
  cursor: pointer;
  border: 1px dashed #ccc;
  border-radius: 4px;
  background: #fafafa;
  min-width: 80px;
  font-size: 10pt;
  color: #333;
  transition: border-color 0.15s, background 0.15s;
}

.nommage-clik-edit:hover {
  border-color: #43a047;
  background: #e8f5e9;
}

.nommage-clik-edit .fa-pencil {
  color: #888;
  font-size: 8pt;
  margin-left: 6px;
}

.nommage-clik-edit:hover .fa-pencil {
  color: #43a047;
}

/* Multi-checkbox pour les extrafields type checkbox */
.nommage-edit-checklist {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px;
  background: #fff;
}

.nommage-edit-checkbox {
  display: block;
  font-size: 9pt;
  padding: 2px 4px;
  cursor: pointer;
  user-select: none;
}

.nommage-edit-checkbox:hover {
  background: #f5f5f5;
}

.nommage-edit-checkbox input {
  margin-right: 6px;
  vertical-align: middle;
}

/* Modal convention */
.nommage-modal-convention {
  max-width: 700px;
  width: 90%;
}

.nommage-convention-help {
  font-size: 9pt;
  color: #666;
  margin-bottom: 10px;
}

.nommage-convention-textarea {
  width: 100%;
  font-family: monospace;
  font-size: 10pt;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  box-sizing: border-box;
}

/* Modal detail */
.nommage-modal-detail {
  max-width: 1100px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
}

.nommage-detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
}

.nommage-detail-table th,
.nommage-detail-table td {
  padding: 8px 12px;
  border: 1px solid #ddd;
  text-align: left;
  vertical-align: top;
}

.nommage-detail-table th {
  background: #f5f5f5;
  font-size: 10pt;
}

.nommage-detail-desc {
  max-width: 350px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 9pt;
}

.nommage-diff {
  background: #e8f5e9 !important;
  font-weight: 600;
}

.nommage-detail-remarques {
  padding: 10px;
  background: #f5f5f5;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 10pt;
}

.nommage-detail-remarques p { margin: 5px 0 0 0; color: #555; }

.nommage-detail-raw {
  padding: 10px;
  background: #263238;
  color: #e0e0e0;
  border-radius: 4px;
  font-size: 9pt;
  margin-bottom: 10px;
}

.nommage-detail-raw pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 5px 0 0 0;
}

/* Modal création par EAN */
.nommage-modal-create {
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.nommage-create-step { margin-bottom: 12px; }
.nommage-create-step label { display: block; margin-bottom: 5px; font-size: 10pt; }

.nommage-create-ean-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nommage-create-ean-input {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 11pt;
  width: 250px;
  font-family: monospace;
}

.nommage-create-alert {
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 10pt;
}

.nommage-create-alert-error { background: #fce4ec; color: #c62828; border: 1px solid #ef9a9a; }
.nommage-create-alert-barcode { margin-left: 10px; white-space: nowrap; }
.nommage-create-alert-ok { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; display: flex; align-items: center; flex-wrap: wrap; }
.nommage-create-alert-info { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; white-space: pre-wrap; }

.nommage-create-form { margin-top: 15px; }
.nommage-create-form h4 {
  font-size: 10pt;
  color: #555;
  margin: 15px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid #ddd;
}

.nommage-create-table {
  width: 100%;
  border-collapse: collapse;
}

.nommage-create-table td {
  padding: 4px 6px;
  vertical-align: top;
}

.nommage-create-field-label {
  font-weight: 600;
  font-size: 9pt;
  color: #555;
  white-space: nowrap;
  width: 140px;
  padding-top: 8px !important;
}

.nommage-create-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 10pt;
  box-sizing: border-box;
}

.nommage-create-input:focus {
  border-color: #7e57c2;
  outline: none;
  box-shadow: 0 0 0 2px rgba(126, 87, 194, 0.15);
}

textarea.nommage-create-input {
  resize: vertical;
  font-family: inherit;
}

select.nommage-create-input {
  width: auto;
  min-width: 150px;
}

.nommage-modal-success {
  max-width: 450px;
  text-align: center;
}

.nommage-modal-success .modal-body p {
  margin: 8px 0;
  font-size: 11pt;
}

.nommage-create-cat-hint {
  display: block;
  font-size: 8pt;
  color: #888;
  margin-top: 2px;
  margin-left: 10px;
}

/* Images web */
.nommage-create-images-section h4 {
  display: flex;
  align-items: center;
}

.nommage-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.nommage-image-card {
  border: 2px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fafafa;
}
.nommage-image-card:hover { border-color: #999; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.nommage-image-selected { border-color: #43a047 !important; box-shadow: 0 0 0 2px rgba(67, 160, 71, 0.3) !important; }
.nommage-image-verified { border-color: #a5d6a7; }
.nommage-image-rejected { opacity: 0.5; }

.nommage-image-thumb {
  position: relative;
  width: 100%;
  height: 120px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.nommage-image-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.nommage-image-check {
  position: absolute;
  top: 4px;
  right: 4px;
  color: #43a047;
  font-size: 18px;
  text-shadow: 0 0 3px #fff;
}

/* Loupe : agrandit l'image dans la visionneuse standard (le clic sur la carte, lui, sélectionne) */
.nommage-image-thumb .nommage-image-zoom {
  position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; padding: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; border: none;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; cursor: zoom-in; opacity: .85;
}
.nommage-image-thumb .nommage-image-zoom:hover { opacity: 1; background: rgba(0, 0, 0, .75); }

.nommage-image-info {
  padding: 4px 6px;
  border-top: 1px solid #eee;
}

.nommage-image-title {
  display: block;
  font-size: 8pt;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nommage-image-badge {
  display: inline-block;
  font-size: 7pt;
  padding: 1px 5px;
  border-radius: 8px;
  margin-top: 2px;
}
.nommage-image-badge-ok { background: #e8f5e9; color: #2e7d32; }
.nommage-image-badge-warn { background: #fff3e0; color: #e65100; }
.nommage-image-badge-unknown { background: #e0e0e0; color: #616161; }

/* === Responsive tablette + mobile ===
   La table est déjà dans un conteneur à défilement horizontal propre
   (.nommage-table-wrapper { overflow-x: auto }, réglage existant, inchangé
   ici) : les colonnes en trop sont réellement atteignables par glissement
   latéral. Le seul contenu qui échappait réellement à l'écran (et au
   overflow-x:hidden global ≤992px de main.css) est la barre de statistiques
   KPI, en flex-nowrap : elle passe à la ligne ci-dessous. */
@media (max-width: 992px) {
  .nommage-toolbar { flex-direction: column; align-items: stretch; }
  .nommage-toolbar-left, .nommage-toolbar-right { justify-content: flex-start; }
  .nommage-search { flex: 1; min-width: 140px; }

  .nommage-stats {
    flex-wrap: wrap;
  }

  /* Indicateur de défilement (ombre) sur la table, dense et non convertie
     en cartes ici : sous-lignes d'extrafields et diffs de suggestion
     rendraient une carte illisible. */
  .nommage-table-wrapper {
    box-shadow: inset -12px 0 10px -10px rgba(0, 0, 0, 0.25);
  }
}

/* Popup Images : images actuelles du produit avant la recherche web (v3.59.2) */
.nommage-create-alert-warn { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.nommage-img-section-title { font-size: 10pt; font-weight: 600; color: #555; text-align: left; margin: 6px 0 8px; }
.nommage-img-actuelles { margin-bottom: 12px; }
.nommage-image-actuelle { display: block; text-decoration: none; color: inherit; }
.nommage-image-noapercu { display: flex; align-items: center; justify-content: center; gap: 6px; height: 100%; color: #999; font-size: 9pt; }
.nommage-image-taille { font-size: 8pt; color: #888; }
.nommage-img-lancer { text-align: center; margin: 10px 0; }
.nommage-btn-img-web { color: #5e35b1; border-color: #7e57c2; }
