* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: 'Open Sans', 'Segoe UI', sans-serif;
  background-color: #ffffff;
  color: #232323;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
}

h1 {
  font-size: 3rem;
  margin-bottom: 2rem;
  font-weight: 700;
}

h2 {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 3rem 0 1.5rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 1.5px solid #232323;
}

h3 {
  font-size: 0.95rem;
}

h4 {
  font-size: 0.9rem;
  font-weight: 600;
}

a {
  color: #232323;
  text-decoration: underline;
  transition: color 0.2s;
}

a:hover {
  color: #bd1e0c;
}

p {
  color: #666666;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

/* Main container */
.container.spectacles-manager {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 50px;
  background-color: #ffffff;
}

/* Alert messages */
.alert {
  margin-bottom: 2rem;
  padding: 1.5rem;
  border-left: 4px solid;
}

.alert-success {
  background-color: #f0f8f5;
  color: #3dc475;
  border-left-color: #27ae60;
}

.alert-error {
  background-color: #fef5f5;
  color: #bd1e0c;
  border-left-color: #bd1e0c;
}

/* Stats section - minimal version */
.spectacles-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
}

.stat-card {
  padding: 1.5rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  display: block;
  background-color: transparent;
  border: 1px solid #e0e0e0;
  border-radius: 0;
}

.stat-card:hover {
  border-color: #232323;
}

.stat-card h3 {
  font-size: 0.8rem;
  color: #666666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.stat-card .count {
  font-size: 3rem;
  font-weight: 700;
  color: #232323;
  margin: 0;
}

/* Sections */
.spectacles-sections {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  margin-top: 3rem;
}

/* Desktop layout: afficher les 3 sections en colonnes sur écrans larges */
@media (min-width: 1025px) {
  .spectacles-sections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-top: 2rem;
    align-items: start;
  }

  /* Donner un léger padding aux sections pour les distinguer, sans casser le style existant */
  .spectacle-section {
    padding: 1rem;
  }
  /* Placer explicitement les sections V1/V2/V3 dans les colonnes 1/2/3
     et forcer leur démarrage sur la même ligne (grid-row: 1). Utiliser les
     IDs est plus robuste que nth-of-type si des <hr> ou d'autres éléments
     sont présents dans le flux. */
  .spectacles-sections > #v1-bruts {
    grid-column: 1 / 2;
    grid-row: 1;
  }
  .spectacles-sections > #v2-correction {
    grid-column: 2 / 3;
    grid-row: 1;
  }
  .spectacles-sections > #v3-valides {
    grid-column: 3 / 4;
    grid-row: 1;
  }
  /* Faire en sorte que les <hr> enfants occupent toute la largeur de la grille
     afin qu'ils ne créent pas de cellules vides et que les colonnes commencent
     toutes au même niveau. */
  .spectacles-sections > hr {
    grid-column: 1 / -1;
    width: 100%;
    margin: 0.5rem 0;
    border: none;
    border-top: 1px solid #e0e0e0;
  }
}

.spectacle-section {
  background: transparent;
  border: none;
  padding: 0;
}

.spectacle-section h2 {
  margin-top: 0;
}

/* List */
.spectacle-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid #e0e0e0;
}

.spectacle-item {
  /* Place actions on top (full-width row) and info below so info gets
     the maximum horizontal space. This frees the right column and keeps
     buttons readable. */
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "actions"
    "info";
  gap: 0.75rem 2rem;
  align-items: start;
  padding: 1.5rem 0;
  border-bottom: 1px solid #e0e0e0;
}

.spectacle-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.spectacle-actions {
  grid-area: actions;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
}

.spectacle-info {
  grid-area: info;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.title-row h4 {
  margin: 0;
  flex: 1;
  min-width: 250px;
}

/* Place the selection checkbox on the top-right of each spectacle-item and make it visible/clickable */
.spectacle-item { position: relative; }

/* Topline inside spectacle-actions: place select button on its own row */
.spectacle-actions-topline { width: 100%; margin-bottom: 0.5rem; display:flex; justify-content:flex-end; }
.spectacle-actions-topline .btn-select {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem; /* same as others */
  font-size: 0.78rem;
  line-height: 1;
  background: transparent;
  border: 1px solid black;
  color: #232323;
  text-decoration: none;
  cursor: pointer;

}
.spectacle-actions-topline .btn-select input[type="checkbox"] {
  width: 18px; height: 18px; margin: 0; accent-color: #3c7f72; cursor: pointer;
}

/* Ensure btn-select doesn't get forced to full width by generic .btn rules */
.spectacle-actions .btn-select {
  width: auto !important;
  min-width: 7.5rem !important;
  padding: 0.35rem 0.6rem !important;
  border: 1px solid #e0e0e0 !important;
}

/* Temporary visual aid to confirm the button is styled (remove later) */
.spectacle-actions .btn-select { box-shadow: none !important; }

/* Small helper styles for select-all button and counter */
.v2-bulk-actions .btn-select-all { padding: 0.35rem 0.6rem; font-size: 0.875rem; }
.v2-bulk-actions #selection-count { color: #333; font-size: 0.95rem; }

.title-row h4 a {
  text-decoration: none;
  color: #232323;
  font-size: 20px;
}

.title-row h4 a:hover {
  text-decoration: underline;
  color: #bd1e0c;
}

/* Badges */
.status-badge,
.version-badge,
.events-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
  border-radius: 0;
  background-color: #f5f5f5;
  color: #666666;
  white-space: nowrap;
}

.version-badge {
  background-color: #FFE900;
  color: #333333;
}

.status-badge.status-draft {
  background-color: #fef5f5;
  color: #bd1e0c;
}

.status-badge.status-public {
  background-color: #f0f8f5;
  color: #3dc475;
}

.events-badge {
  background-color: #f5f5f5;
  color: #666666;
}

/* Company */
.company {
  color: #666666;
  font-size: 0.9rem;
  margin: 0.5rem 0 0 0;
}

/* Meta information */
.meta-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #f0f0f0;
}

.meta {
  font-size: 0.85rem;
  color: #999999;
  margin: 0;
}

/* Completion bar */
.completion-bar-container {
  width: 100px;
  height: 4px;
  background: #e9ecef;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.completion-bar {
  height: 100%;
  background: #232323;
  border-radius: 2px;
}

.completion-text {
  font-size: 0.8rem;
  color: #999999;
  margin: 0.35rem 0 0 0;
}

/* Status indicator - minimal */
.status-indicator {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator.status-error {
  background: #bd1e0c;
}

.status-indicator.status-ok {
  background: #3dc475;
}

/* Error badge */
.error-badge {
  display: inline-block;
  background: transparent;
  color: #bd1e0c;
  padding: 0;
  font-size: 0.8rem;
  margin: 0.5rem 0;
  font-weight: 600;
}

/* Actions section */
.spectacle-actions {
  display: flex;
  gap: 0.75rem;
  flex-direction: row;
  align-items: flex-end;
  white-space: nowrap;
  justify-content: flex-start;
}

/* Buttons */
.btn, 
.btn-edit, 
.btn-download, 
.btn-transfer {
  padding: 0.6rem 1rem;
  border: 1px solid #232323;
  background: transparent;
  color: #232323;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s;
  border-radius: 0;
  text-align: center;
  display: inline-block;
}

.btn:hover, 
.btn-edit:hover, 
.btn-download:hover {
  background-color: #232323;
  color: white;
}

.btn-transfer {
  background-color: #232323;
  color: white;
  border-color: #232323;
}

.btn-transfer:hover {
  background-color: #bd1e0c;
  border-color: #bd1e0c;
}

/* Toggle/details */
.history-toggle,
.logs-toggle,
.fields-summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: #666666;
  text-decoration: underline;
  user-select: none;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.history-toggle:hover,
.logs-toggle:hover,
.fields-summary:hover {
  color: #bd1e0c;
}

.history-content,
.logs-content {
  margin-top: 1rem;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 0;
  overflow-x: auto;
}

.history-content pre {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #333;
  font-family: 'Courier New', monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Tables */
.modification-history-table, 
.history-content table, 
.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: white;
  border-radius: 0;
  overflow: hidden;
}

.modification-history-table thead th, 
.history-content table thead th, 
.events-table thead th {
  background-color: #f5f5f5;
  color: #333;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid #e0e0e0;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.4px;
}

.modification-history-table tbody td, 
.history-content table tbody td, 
.events-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e0e0e0;
  color: #333;
  vertical-align: top;
}

.modification-timestamp {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #999999;
}

/* ===== LOGS TABLE - Horizontal 4 Column Format ===== */
.logs-table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  border-radius: 0;
  overflow: visible;
}

.logs-table thead {
  display: none;
}

.logs-table tbody {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.logs-table tbody tr {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(110px, 180px) minmax(110px, 180px) minmax(220px, 1fr);
  gap: 2rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid #e0e0e0;
  align-items: start;
}

.logs-table tbody tr:last-child {
  border-bottom: none;
}

.logs-table tbody td {
  padding: 0;
  border: none;
  color: #333;
  vertical-align: top;
  font-size: 0.9rem;
}

.log-timestamp {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: #999999;
  font-weight: 500;
}

.log-user {
  font-weight: 600;
  color: #333;
}

.log-action {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.3px;
  color: #333;
}

.log-details {
  color: #333;
  word-break: break-word;
}

/* Details elements */
details {
  margin: 0;
}

details > summary {
  cursor: pointer;
  outline: none;
}

.logs-dropdown,
.history-dropdown,
.fields-details {
  margin: 1rem 0;
}

.changed-fields-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0 0;
}

.changed-field {
  padding: 0.75rem;
  background: white;
  border: 1px solid #e0e0e0;
  margin-bottom: 0.5rem;
  border-radius: 0;
}

.changed-field strong {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.field-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  font-size: 0.8rem;
}

.field-values > div {
  display: flex;
  flex-direction: column;
}

.field-values > div::before {
  content: attr(data-label);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.3px;
  margin-bottom: 0.35rem;
  color: #999;
}

code {
  background-color: #f5f5f5;
  padding: 0.35rem 0.5rem;
  border-radius: 0;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #333;
  display: block;
  word-break: break-all;
  white-space: normal;
}

.old-value {
  color: #bd1e0c;
}

.new-value {
  color: #3dc475;
}

.empty {
  color: #999;
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 0;
}

/* Pour plus petit écran */
@media (max-width: 1024px) {
  .container.spectacles-manager {
    padding: 50px 40px;
  }

  h1 {
    font-size: 2.5rem;
  }

  .spectacle-item {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .spectacle-actions {
    align-items: flex-start;
  }

  .logs-table tbody tr {
    grid-template-columns: minmax(100px, 160px) minmax(100px, 160px) minmax(90px, 140px) minmax(180px, 1fr);
    gap: 1.5rem;
  }
}

.logs-dropdown {
  width: 100%;
  display: block;
  box-sizing: border-box;
}

.logs-dropdown .logs-content,
.logs-dropdown .logs-table {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.log-details {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.log-timestamp, .log-user, .log-action {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Au besoin peut-etre que je pourrais regarder cette page sur mon téléphone */

@media (max-width: 768px) {
  .container.spectacles-manager {
    padding: 40px 30px;
  }

  h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
  }

  .spectacles-stats {
    gap: 1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .spectacle-item {
    padding: 1rem 0;
  }

  .title-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .field-values {
    grid-template-columns: 1fr;
  }

  .modification-history-table, 
  .history-content table, 
  .events-table {
    font-size: 0.75rem;
  }

  .modification-history-table tbody td, 
  .history-content table tbody td, 
  .events-table tbody td {
    padding: 0.5rem;
  }

  .logs-table tbody tr {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

@media (max-width: 480px) {
  .container.spectacles-manager {
    padding: 30px 20px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .spectacles-stats {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-card .count {
    font-size: 2rem;
  }

  .btn, 
  .btn-edit, 
  .btn-download, 
  .btn-transfer {
    width: 100%;
  }

  .spectacle-actions {
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  /* Allow action buttons to wrap to multiple lines when space is constrained */
  .spectacle-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  .spectacle-actions .btn,
  .spectacle-actions .btn-edit,
  .spectacle-actions .btn-download,
  .spectacle-actions .btn-transfer,
  .spectacle-actions .btn-select {
    flex: 0 0 auto; /* don't stretch; keep natural size */
    min-width: 7.5rem; /* allows them to wrap into multiple rows */
  }
}

.spectacle-actions .btn,
.spectacle-actions .btn-edit,
.spectacle-actions .btn-download,
.spectacle-actions .btn-transfer {
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
  min-width: 0;
}

.spectacle-actions .btn > span,
.spectacle-actions .btn-edit > span,
.spectacle-actions .btn-download > span,
.spectacle-actions .btn-transfer > span {
  display: inline-block;
  max-width: 9rem; 
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spectacles-sections {

  min-width: 0;
}

.spectacles-sections * {
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  box-sizing: border-box; 
  min-width: 0;
}

.spectacles-sections img,
.spectacles-sections video,
.spectacles-sections iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

.spectacles-sections .spectacle-actions,
.spectacles-sections .status-badge,
.spectacles-sections .version-badge,
.spectacles-sections .events-badge {
  white-space: normal;
}

.spectacles-sections .title-row h4 {
  min-width: 0;
}

@media (min-width: 1025px) {
  .spectacles-sections .title-row h4 {
    min-width: 250px; 
  }
}

