/**
 * styles.css — Styles du formulaire de gestion des marchandises
 * ==============================================================
 * Utilisé par : index.php
 * Sections :
 * - Variables CSS (thème sombre, safe-area)
 * - Reset et body (flex, fond)
 * - En-tête du site (site-header, logo, nav)
 * - Formulaire déplaçable (form-container, form-header, form-body, champs)
 * - Panneau droit (right-panel, merchandise-list, Modifier/Supprimer)
 * - Boîte de dialogue (app-dialog)
 * - Pied de page (site-footer)
 * - Responsive (mobile)
 */

/* --- Variables CSS (thème sombre, safe-area pour encoches) --- */
:root {
  --bg-page: #0f1419;
  --bg-form: #1a2332;
  --bg-input: #252f3d;
  --border: #2d3a4d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --primary: #58a6ff;
  --primary-hover: #79b8ff;
  --danger: #f85149;
  --danger-hover: #ff6b6b;
  --success: #3fb950;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --header-height: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* --- En-tête du site --- */
.site-header {
  flex-shrink: 0;
  background: linear-gradient(180deg, #1a2332 0%, #141c26 100%);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  padding-top: calc(12px + var(--safe-top));
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.site-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
  transition: color 0.2s;
}

.site-logo:hover {
  color: var(--primary);
}

.site-logo-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.site-nav-list {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav-link {
  padding: 8px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.site-nav-link:hover {
  color: var(--primary);
  background: rgba(88, 166, 255, 0.1);
}

.site-nav-link.is-active {
  color: var(--primary);
  background: rgba(88, 166, 255, 0.15);
}

/* --- Contenu principal --- */
.site-main {
  flex: 1;
  min-height: 0;
}

/* --- Pied de page du site --- */
.site-footer {
  flex-shrink: 0;
  background: linear-gradient(0deg, #141c26 0%, #1a2332 100%);
  border-top: 1px solid var(--border);
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
  margin-top: auto;
}

.site-footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-footer-section {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.site-footer-copyright {
  margin: 0;
}

.site-footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer-links a:hover {
  color: var(--primary);
}

/* --- Mise en page : formulaire à gauche (80 %), liste des marchandises à droite (20 %) --- */
.merchandise-layout {
  display: flex;
  flex-direction: row;
  padding: 16px 20px 24px;
  box-sizing: border-box;
  min-height: calc(100vh - 140px);
  gap: 20px;
  align-items: stretch;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.merchandise-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  margin: 0;
}

.merchandise-main-no-form .merchandise-welcome {
  background: var(--bg-form);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 40px;
  text-align: center;
  box-shadow: var(--shadow);
}

.merchandise-welcome h2 {
  margin: 0 0 12px;
  font-size: 1.4rem;
  color: var(--text);
}

.merchandise-welcome p {
  margin: 0 0 24px;
  color: var(--text-muted);
}

.btn-new-merchandise-link {
  display: inline-block;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
  transition: background 0.2s;
}

.btn-new-merchandise-link:hover {
  background: var(--primary-hover);
}

.merchandise-layout .right-panel {
  flex: 0 0 20%;
  width: 20%;
  max-width: 280px;
  min-width: 200px;
}

/* --- Conteneur du formulaire : intégré dans la colonne (toujours déplaçable) --- */
.form-container {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 32px);
  background: var(--bg-form);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 1;
  overflow: hidden;
  transition: box-shadow 0.2s;
  /* On force la position dans sa colonne pour éviter qu'elle ne recouvre les autres */
  left: 0 !important;
  top: 0 !important;
}

.form-container:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.form-container.dragging {
  cursor: grabbing;
  user-select: none;
}

/* En-tête : sert de poignée pour glisser-déposer le formulaire --- */
.form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-height);
  background: linear-gradient(180deg, #252f3d 0%, #1e2836 100%);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  flex-shrink: 0;
}

.form-header:active {
  cursor: grabbing;
}

.form-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.btn-minimize {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-minimize:hover {
  background: var(--bg-input);
  color: var(--text);
}

/* Indication destination des fichiers (masqué par défaut) --- */
.form-destination {
  display: none;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(37, 47, 61, 0.6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.form-destination .destination-label {
  display: block;
  margin-bottom: 4px;
}

.form-destination code {
  display: block;
  color: var(--primary);
  font-size: 0.85em;
  word-break: break-all;
  overflow-wrap: break-word;
  white-space: normal;
  width: 100%;
  box-sizing: border-box;
  padding: 0;
}

/* Corps du formulaire : zone scrollable --- */
.form-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.field-group {
  margin-bottom: 18px;
}

.field-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

/* Aperçu inline à côté des champs de saisie */
.field-input-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.field-edit-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.field-edit-wrapper > input,
.field-edit-wrapper > textarea,
.field-edit-wrapper > select,
.field-edit-wrapper .triple-select {
  flex: 1;
  min-width: 0;
}

.field-input-preview-selects .field-edit-wrapper {
  flex: 1;
}

/* DIV de lecture : affichage quand le champ est renseigné, masquée en mode édition */
.field-read-view {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.4);
  border-radius: 8px;
  cursor: pointer;
  word-break: break-word;
  line-height: 1.5;
  transition: background 0.2s, border-color 0.2s;
}

.field-read-view:hover {
  background: rgba(88, 166, 255, 0.12);
  border-color: var(--primary);
}

.field-read-view-textarea {
  min-height: 60px;
  white-space: pre-wrap;
}

/* Galerie d'images en mode lecture */
.field-read-view-images {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-read-view-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field-read-view-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Masqué quand vide ou en mode édition */
.field-read-view[hidden],
.field-edit-wrapper[hidden] {
  display: none !important;
}

.field-preview {
  flex-shrink: 0;
  min-width: 140px;
  max-width: 200px;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--primary);
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.3);
  border-radius: 8px;
  word-break: break-word;
  line-height: 1.4;
}

/* État vide (pas de saisie) */
.field-preview:not(.has-value) {
  color: var(--text-muted);
  background: rgba(45, 58, 77, 0.5);
  border-color: var(--border);
}

.field-preview-textarea {
  min-height: 60px;
  align-self: stretch;
}

.field-input-preview-selects {
  flex-wrap: wrap;
}

.field-input-preview-selects .triple-select {
  flex: 1;
  min-width: 200px;
}

.field-input-preview-images {
  flex-direction: column;
  align-items: stretch;
}

.field-input-preview-images .field-preview {
  min-width: auto;
  max-width: none;
}

.required {
  color: var(--danger);
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

/* Champs contenant des informations : bordure et fond légèrement colorés */
input.has-value,
textarea.has-value,
select.has-value {
  border-color: rgba(88, 166, 255, 0.5);
  background: rgba(88, 166, 255, 0.06);
}

.images-zone.has-value {
  border-color: rgba(88, 166, 255, 0.5);
  background: rgba(88, 166, 255, 0.08);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Grille 2 colonnes pour prix + devise (ou contact) --- */
.field-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}

.field-row .field-group.flex-2 { grid-column: 1; }
.field-row .field-group.flex-1 { grid-column: 2; }

/* Triple select : localité (continent, pays, ville) ou catégorie (niveau 1, 2, 3) --- */
.triple-select {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.triple-select select {
  min-width: 0;
}

/* Zone images : zone de dépôt + prévisualisation + bouton Ajouter --- */
.images-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(37, 47, 61, 0.5);
}

.images-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 60px;
  margin-bottom: 12px;
  transition: background 0.2s, border-color 0.2s;
}

.images-preview.drag-over {
  background: rgba(88, 166, 255, 0.1);
  border: 1px dashed var(--primary);
  border-radius: 8px;
}

.preview-item {
  position: relative;
  width: 100px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 4px;
  background: var(--bg-input);
}

.preview-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  display: block;
  border-radius: 6px;
}

/** Champ type associé à l'image (contenu enregistré dans img_typ_N.txt) */
.preview-item-type {
  width: 100%;
  max-width: 92px;
  padding: 4px 6px;
  font-size: 0.75rem;
  color: var(--text);
  background: var(--bg-form);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.preview-item-type::placeholder {
  color: var(--text-muted);
}

.preview-item .btn-remove-img {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: opacity 0.2s, transform 0.2s;
}

.preview-item .btn-remove-img:hover {
  opacity: 1;
  transform: scale(1.1);
}

.images-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Boutons (primaire, secondaire, outline) --- */
.btn {
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #2d3a4d;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.form-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: rgba(30, 40, 54, 0.6);
  flex-shrink: 0;
}

/* --- Colonne liste : panneau droit (20 % de largeur) --- */
.right-panel {
  align-self: stretch;
  min-height: 400px;
  background: var(--bg-form);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Bouton de déploiement de la liste des marchandises */
.merch-list-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-form);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.merch-list-toggle:hover {
  background: var(--bg-input);
  border-color: var(--primary);
  color: var(--primary);
}

.merch-list-count {
  color: var(--text-muted);
  font-weight: 500;
}

.merch-list-toggle-icon {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.merch-list-toggle.expanded .merch-list-toggle-icon {
  transform: rotate(180deg);
}

.merchandise-list-wrap {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.merchandise-list-wrap[hidden] {
  display: none;
}

.right-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #252f3d 0%, #1e2836 100%);
  flex-shrink: 0;
}

.right-panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.right-panel-list {
  flex: 1 1 auto;
  max-height: 50vh;
  overflow-y: auto;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  min-height: 120px;
}

.right-panel-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.merchandise-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.merchandise-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}
.merchandise-item-name:hover {
  color: var(--primary);
  text-decoration: underline;
}

.merchandise-item .btn-edit,
.merchandise-item .btn-delete {
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-weight: 500;
}

.merchandise-item .btn-edit {
  background: var(--primary);
  color: #fff;
}

.merchandise-item .btn-edit:hover {
  background: var(--primary-hover);
}

.merchandise-item .btn-delete {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.merchandise-item .btn-delete:hover {
  background: var(--danger);
  color: #fff;
}

.right-panel-current {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.right-panel-current h3 {
  margin: 0;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.right-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.9rem;
  color: var(--text);
}

.right-panel-placeholder {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.right-panel-content .current-field {
  margin-bottom: 10px;
}

.right-panel-content .current-field-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.right-panel-content .current-field-value {
  word-break: break-word;
}

.right-panel-content .current-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.right-panel-content .current-images img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/** Bloc image + type dans le panneau "Marchandise en cours" */
.right-panel-content .current-image-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.right-panel-content .current-image-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* État réduit : bouton − masque le corps du formulaire --- */
.form-container.minimized .form-body {
  display: none;
}

/* --- Responsive : tablette (768px - 1024px) --- */
@media (max-width: 1024px) {
  .merchandise-layout {
    padding: 12px 16px 20px;
    gap: 16px;
    min-height: auto;
  }

  .merchandise-layout .right-panel {
    min-width: 180px;
  }

  .form-body {
    padding: 16px;
  }

  .field-input-preview {
    gap: 10px;
  }

  .field-preview {
    min-width: 120px;
    max-width: 160px;
  }

  .form-footer {
    padding: 12px 16px;
  }

  .merchandise-item {
    padding: 6px 8px;
    font-size: 0.85rem;
  }

  .merchandise-item .btn-edit,
  .merchandise-item .btn-delete {
    padding: 5px 8px;
    font-size: 0.75rem;
  }
}

@media (max-width: 900px) {
  .merchandise-layout {
    flex-direction: column;
    padding: 12px 16px 20px;
  }

  .merchandise-layout .right-panel {
    flex: none;
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 320px;
  }

  .merchandise-main {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }

  .right-panel-list {
    max-height: 35vh;
  }
}

/* --- Responsive : mobile portrait (≤ 768px) --- */
@media (max-width: 768px) {
  .site-header {
    padding: 10px 14px;
    padding-top: calc(10px + var(--safe-top));
    padding-left: calc(14px + var(--safe-left));
    padding-right: calc(14px + var(--safe-right));
  }

  .site-header-inner {
    gap: 12px;
  }

  .site-logo-text {
    font-size: 1.1rem;
  }

  .site-logo-icon {
    font-size: 1.3rem;
  }

  .site-nav-link {
    padding: 6px 10px;
    font-size: 0.9rem;
  }

  .site-footer {
    padding: 16px;
  }

  .site-footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  .merchandise-layout {
    padding: 10px 12px 16px;
    gap: 12px;
  }

  .form-container {
    max-height: none;
  }

  .form-header h1 {
    font-size: 1rem;
  }

  .form-body {
    padding: 14px;
  }

  .field-input-preview {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .field-preview {
    min-width: auto;
    max-width: none;
  }

  .field-input-preview-selects .triple-select {
    min-width: 100%;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .triple-select {
    grid-template-columns: 1fr;
  }

  .right-panel {
    height: auto;
    min-height: 280px;
  }

  .right-panel-list {
    max-height: 30vh;
    min-height: 100px;
    padding: 8px;
  }

  .right-panel-current h3 {
    font-size: 0.9rem;
    padding: 8px 12px;
  }

  .right-panel-content {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .merch-list-toggle {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .btn {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .form-footer {
    flex-direction: column;
    padding: 12px 14px;
  }

  .form-footer .btn {
    width: 100%;
  }

  .preview-item {
    width: 80px;
  }

  .preview-item img {
    width: 64px;
    height: 64px;
  }

  .images-zone {
    padding: 10px;
  }
}

/* --- Responsive : mobile étroit (≤ 520px) --- */
@media (max-width: 520px) {
  .site-header {
    padding: 8px 12px;
  }

  .site-logo-text {
    display: none;
  }

  .site-logo-icon {
    font-size: 1.5rem;
  }

  .merchandise-layout {
    padding: 8px 10px 12px;
  }

  .form-body {
    padding: 12px;
  }

  .field-group {
    margin-bottom: 14px;
  }

  .field-group label {
    font-size: 0.85rem;
  }

  input[type="text"],
  input[type="number"],
  textarea,
  select {
    padding: 10px;
    font-size: 16px; /* Évite le zoom iOS sur focus */
  }

  .merchandise-item {
    flex-wrap: wrap;
    gap: 6px;
  }

  .merchandise-item-name {
    flex: 1 1 100%;
    white-space: normal;
  }

  .merchandise-item .btn-edit,
  .merchandise-item .btn-delete {
    flex: 1;
  }

  .right-panel-content .current-images img {
    width: 56px;
    height: 56px;
  }

  .app-dialog {
    width: 95%;
    max-height: 85vh;
  }
}

/* --- Mode paysage mobile (éviter hauteur trop faible) --- */
@media (max-height: 500px) and (orientation: landscape) {
  .merchandise-layout {
    min-height: 400px;
  }

  .form-container {
    max-height: 60vh;
  }

  .right-panel-list {
    max-height: 25vh;
  }
}

/* --- Boîte de dialogue appli (remplace alert()) --- */
.app-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

.app-dialog-backdrop[hidden] {
  display: none;
}

.app-dialog {
  background: var(--bg-form);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #252f3d 0%, #1e2836 100%);
}

.app-dialog-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.app-dialog-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.app-dialog-close:hover {
  color: var(--text);
}

.app-dialog-body {
  padding: 16px;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
  overflow-y: auto;
  max-height: 50vh;
}

.app-dialog-footer {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
