/* ================================
   SECTIONS
   ================================ */

.section {
  margin-bottom: 30px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  background-color: var(--white);
}

.section-header {
  background-color: var(--secondary-color);
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  border-bottom: 1px solid var(--border-color);
}

.section-title {
  font-weight: bold;
  border: 1px dashed transparent;
  padding: 5px;
  font-size: 16px;
  color: var(--text-color);
}

.section-title:hover {
  border: 1px dashed var(--border-color);
  cursor: text;
}

.section-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.section-actions button {
  padding: 6px 12px;
  font-size: 12px;
}

.section-actions label {
  font-size: 12px;
  color: var(--text-color);
}

.section-actions input[type="number"] {
  width: 60px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 3px;
}

.section-content {
  padding: 15px;
}

/* ================================
   TABLEAUX
   ================================ */

table {
  width: 100%;
  border-collapse: collapse;
  position: relative;
  margin: 0;
}

th, td {
  border: 1px solid var(--border-color);
  padding: 8px;
  position: relative;
  min-width: 100px;
  vertical-align: top;
}

th {
  background-color: var(--secondary-color);
  font-weight: bold;
}

th span, td span {
  display: block;
  width: 100%;
  border: 1px dashed transparent;
  padding: 3px;
  min-height: 20px;
  outline: none;
}

th span:hover, td span:hover {
  border: 1px dashed var(--border-color);
  cursor: text;
}

th span:focus, td span:focus {
  border: 1px solid var(--primary-color);
  background-color: rgba(74, 134, 232, 0.05);
}

/* Poignées de redimensionnement */
.resize-handle-col {
  position: absolute;
  top: 0; 
  right: 0;
  width: 5px; 
  height: 100%;
  cursor: col-resize;
  background-color: transparent;
  opacity: 0;
  transition: opacity var(--transition);
}

.resize-handle-col:hover {
  background-color: var(--primary-color);
  opacity: 1;
}

.resize-handle-row {
  position: absolute;
  bottom: 0; 
  left: 0;
  height: 5px; 
  width: 100%;
  cursor: row-resize;
  background-color: transparent;
  opacity: 0;
  transition: opacity var(--transition);
}

.resize-handle-row:hover {
  background-color: var(--primary-color);
  opacity: 1;
}

/* Curseurs pour le drag & drop */
thead th, tbody td {
  cursor: move;
}

/* ================================
   SECTIONS PHOTO
   ================================ */

.photo-drop-zone {
  border: 2px dashed var(--border-color);
  padding: 20px;
  text-align: center;
  border-radius: var(--border-radius);
  background-color: #fafafa;
  transition: background-color var(--transition);
}

.photo-drop-zone:hover {
  background-color: #f0f0f0;
}

.photo-drop-zone p {
  cursor: pointer;
  margin: 0;
  color: #666;
  font-size: 14px;
}

.photo-preview {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.photo-container {
  position: relative;
  display: inline-block;
  border-radius: var(--border-radius);
  overflow: hidden;
  background-color: var(--white);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.photo-container img {
  max-width: 150px;
  max-height: 150px;
  border: 1px solid var(--border-color);
  display: block;
  cursor: zoom-in;
}

.photo-container input[type="text"] {
  display: block;
  margin-top: 5px;
  width: 150px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  font-size: 12px;
}

.delete-photo-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.7);
  color: var(--white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 12px;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-photo-btn:hover {
  background: rgba(255,0,0,0.8);
}

/* ================================
   SECTIONS LAYOUT (MISE EN PAGE)
   ================================ */

.layout-section .section-content {
  background-color: #f9f9f9;
  border: 1px dashed var(--border-color);
  min-height: 50px;
}

/* ================================
   MODALS
   ================================ */

.modal {
  display: none;
  position: fixed;
  top: 0; 
  left: 0;
  width: 100%; 
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--white);
  padding: 20px;
  border-radius: var(--border-radius);
  width: 400px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Modal de prévisualisation d'image */
#preview-modal .modal-content {
  background-color: transparent;
  box-shadow: none;
  padding: 0;
  max-width: 90%;
  max-height: 90%;
  position: relative;
}

#preview-modal img {
  width: 100%;
  height: auto;
  display: block;
  margin: auto;
  border-radius: var(--border-radius);
}

#preview-close {
  position: absolute;
  top: 10px; 
  right: 20px;
  font-size: 30px; 
  color: var(--white);
  cursor: pointer; 
  z-index: 2001;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#preview-close:hover {
  background: rgba(0,0,0,0.8);
}

/* Modal de confirmation */
#confirm-delete-modal .modal-content {
  max-width: 300px;
  text-align: center;
}

/* Modal de mise en forme */
#format-modal .modal-content {
  border: 2px solid var(--primary-color);
  border-radius: 10px;
  padding: 20px;
  width: 500px;
}

#format-modal .modal-content h3 {
  text-align: center;
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 18px;
  color: var(--primary-color);
}

.format-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.format-row label {
  width: 150px;
  margin-right: 10px;
  text-align: right;
  font-weight: bold;
  color: var(--text-color);
}

.format-row select,
.format-row input[type="number"],
.format-row input[type="color"] {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.format-row.checkboxes {
  justify-content: space-between;
  margin-bottom: 15px;
}

.format-row.checkboxes label {
  width: auto;
  margin-right: 15px;
  text-align: left;
  font-weight: normal;
}

.format-modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 25px;
}

.format-modal-actions button {
  border-radius: 5px;
  padding: 10px 20px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
}

.format-modal-actions button#cancel-format-btn {
  background-color: var(--white);
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.format-modal-actions button#cancel-format-btn:hover {
  background-color: var(--hover-color);
}

.format-modal-actions button#apply-format-btn {
  background-color: var(--primary-color);
  color: var(--white);
  border: none;
}

/* ================================
   ZONE DE FICHIERS
   ================================ */

.file-drop-zone {
  border: 2px dashed var(--border-color);
  padding: 20px;
  text-align: center;
  border-radius: var(--border-radius);
  background-color: #fafafa;
  transition: all var(--transition);
}

.file-drop-zone:hover {
  background-color: var(--hover-color);
  border-color: var(--primary-color);
}

.file-drop-zone p {
  cursor: pointer;
  margin: 0;
  color: #666;
}

/* ================================
   FORMULAIRES
   ================================ */

textarea {
  width: 100%;
  height: 200px;
  resize: vertical;
  padding: 8px;
  font-family: monospace;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 12px;
}

input[type="text"], 
input[type="number"], 
select {
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
}

input[type="text"]:focus, 
input[type="number"]:focus, 
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(74, 134, 232, 0.2);
}

/* ================================
   RESPONSIVE COMPONENTS
   ================================ */

@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    padding: 15px;
  }
  
  .format-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .format-row label {
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
  }
  
  .format-row.checkboxes {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .section-actions {
    flex-direction: column;
    gap: 5px;
  }
  
  .section-actions button {
    width: 100%;
  }
  
  .photo-preview {
    justify-content: center;
  }
  
  table {
    font-size: 12px;
  }
  
  th, td {
    min-width: 80px;
    padding: 6px;
  }
}