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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* LOGIN PAGE */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.login-box h1 {
  font-size: 28px;
  margin-bottom: 8px;
  color: #333;
}

.subtitle {
  color: #666;
  margin-bottom: 30px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
  padding: 1rem;
  background: white;
  border-radius: 6px;
  border: 1px solid #e9ecef;
}

.form-group-inline {
  margin-bottom: 1rem;
  /* Pas de padding/background/border pour checkboxes */
}

.form-group-inline label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
}

.form-group-inline input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #555;
  font-size: 14px;
}

.form-group input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
}

.btn-secondary {
  background: #6c757d;
  color: white;
  width: 100%;
  margin-top: 10px;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-success {
  background: #28a745;
  color: white;
  width: 100%;
  margin-bottom: 10px;
}

.btn-success:hover {
  background: #218838;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
  width: auto;
  display: inline-block;
}

.error-message {
  background: #f8d7da;
  color: #721c24;
  padding: 12px;
  border-radius: 6px;
  margin-top: 15px;
  font-size: 14px;
}

.success-message {
  background: #d4edda;
  color: #155724;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 14px;
}

/* ADMIN LAYOUT */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: #2c3e50;
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.sidebar-header {
  padding: 25px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
  font-size: 22px;
  margin-bottom: 5px;
}

.sidebar-header p {
  font-size: 12px;
  color: #95a5a6;
  margin: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: #ecf0f1;
  text-decoration: none;
  transition: all 0.3s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  border-left-color: #3498db;
}

.nav-item.active {
  background: rgba(255,255,255,0.1);
  border-left-color: #3498db;
  color: white;
}

.nav-item span {
  margin-right: 10px;
  font-size: 18px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.main-content {
  margin-left: 250px;
  flex: 1;
  padding: 30px;
  background: #f5f5f5;
  min-height: 100vh;
}

#content-area {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* SECTION HEADERS */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e9ecef;
}

.section-header h1 {
  font-size: 28px;
  color: #2c3e50;
}

/* CARDS */
.card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}

.card h3 {
  margin-bottom: 10px;
  color: #2c3e50;
}

/* LISTS */
.item-list {
  list-style: none;
}

.item-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  margin-bottom: 10px;
  background: #fafafa;
  transition: all 0.3s;
}

.item-list-item:hover {
  background: #f0f0f0;
  border-color: #dee2e6;
}

.item-info {
  flex: 1;
}

.item-info h4 {
  margin-bottom: 5px;
  color: #2c3e50;
  font-size: 16px;
}

.item-info p {
  color: #6c757d;
  font-size: 13px;
  margin: 0;
}

.item-actions {
  display: flex;
  gap: 8px;
}

/* FORM STYLES */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.form-row.full {
  grid-template-columns: 1fr;
}

textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
}

textarea:focus {
  outline: none;
  border-color: #667eea;
}

select {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

.lang-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  border-bottom: 2px solid #e9ecef;
}

.lang-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #6c757d;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.lang-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
}

.lang-content {
  display: none;
}

.lang-content.active {
  display: block;
}

/* MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none; /* Caché par défaut */
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#media-modal {
  z-index: 1100; /* Au-dessus de la modal principale */
}

.modal.active {
  display: flex; /* Visible quand classe active */
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.modal-dialog {
  background: white;
  border-radius: 8px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto; /* ✅ Scrollable */
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px 20px;
  border-bottom: 1px solid #eee;
}

.modal-content {
  padding: 30px;
  overflow-y: auto;
  flex: 1;
  background: #f8f9fa; /* Fond gris clair pour meilleur contraste */
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  cursor: pointer;
  color: #6c757d;
}

.modal-close:hover {
  color: #333;
}

/* IMAGE UPLOAD */
.image-upload-area {
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 15px;
}

.image-upload-area:hover {
  border-color: #667eea;
  background: #f8f9fa;
}

.image-upload-area input[type="file"] {
  display: none;
}

.image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
}

.image-preview-item {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 6px;
  overflow: hidden;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-item button {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

/* GALLERY PHOTOS */
.photos-list {
  margin-top: 20px;
  border-top: 1px solid #e9ecef;
  padding-top: 20px;
}

.photo-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  margin-bottom: 10px;
}

.photo-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
}

.photo-item input {
  flex: 1;
}

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 25px;
  border-radius: 8px;
  text-align: center;
}

.stat-card h3 {
  font-size: 36px;
  margin-bottom: 5px;
}

.stat-card p {
  opacity: 0.9;
  font-size: 14px;
}

/* MEDIA BROWSER */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.media-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.3s;
}

.media-item:hover {
  border-color: #667eea;
  transform: scale(1.05);
}

.media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-item-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  padding: 8px;
  display: flex;
  gap: 5px;
  justify-content: center;
}

.media-item-actions button {
  background: white;
  color: #333;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

/* LOADING */
.loading {
  text-align: center;
  padding: 40px;
  color: #6c757d;
}

.spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
  }
  
  .main-content {
    margin-left: 200px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   NOUVEAUX STYLES - Photos, Media, Loading
   ============================================ */

/* Loader/Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Photos section */
.photos-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid #e9ecef;
}

.image-upload-area {
  border: 2px dashed #cbd5e0;
  border-radius: 8px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8f9fa;
  margin-bottom: 1.5rem;
}

.image-upload-area:hover {
  border-color: #0066cc;
  background: #e7f3ff;
}

.photos-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.photo-item {
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

/* Media browser */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.media-item {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s;
}

.media-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.media-item-image {
  width: 100%;
  height: 150px;
  overflow: hidden;
  background: #f8f9fa;
}

.media-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-item-info {
  padding: 0.75rem;
}

.media-item-name {
  font-size: 12px;
  color: #495057;
  margin: 0 0 0.5rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-item-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-tiny {
  padding: 0.25rem 0.5rem;
  font-size: 12px;
}

/* Lang tabs */
.lang-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid #e9ecef;
}

.lang-tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  color: #6c757d;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.lang-tab:hover {
  color: #0066cc;
}

.lang-tab.active {
  color: #0066cc;
  border-bottom-color: #0066cc;
}

.lang-content {
  display: none;
}

.lang-content.active {
  display: block;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 3rem;
  color: #6c757d;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #e9ecef;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}


/* IMAGE PICKER */
.image-picker {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #dee2e6;
}

.image-picker label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #495057;
}

.image-picker-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.image-picker-actions button {
  flex: 1;
  padding: 0.5rem 1rem;
  border: 1px solid #ced4da;
  background: white;
  color: #495057; /* Texte gris foncé lisible */
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.image-picker-actions button:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.image-picker-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.image-preview-container {
  margin: 1rem 0;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  padding: 1rem;
}

.image-preview {
  max-width: 100%;
  max-height: 250px;
  border-radius: 6px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.no-image {
  color: #adb5bd;
  font-size: 0.875rem;
  text-align: center;
}

.image-path {
  display: block;
  color: #6c757d;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: white;
  border-radius: 4px;
  border: 1px solid #e9ecef;
  word-break: break-all;
}

.media-item-selectable:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3) !important;
  border: 2px solid #28a745 !important;
}

.media-item-selectable:hover .media-item-name {
  color: #28a745;
  font-weight: 500;
}