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

/* ===== VARIABLES CSS (définies dans themes.css) ===== */
/* Les variables sont définies dans themes.css et appliquées via classes .theme-light et .theme-dark */

/* ===== BASE ===== */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== LAYOUT ===== */
.header {
  padding: 50px 40px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
  transition: background-color 0.3s ease, border-color 0.3s ease;
  position: relative;
}

.header__title {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0;
  background: linear-gradient(135deg, var(--title-gradient-start, #1D1D1F) 0%, var(--title-gradient-end, #6E6E73) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  text-rendering: optimizeLegibility;
  line-height: 1.1;
}

.header__title::before {
  content: 'Portail Web Interne';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, var(--title-gradient-start, #1D1D1F) 0%, var(--title-gradient-end, #6E6E73) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: blur(20px);
  opacity: 0.3;
  z-index: -1;
}

.header__actions {
  display: flex;
  gap: 12px;
  align-items: center;
  position: absolute;
  top: 20px;
  right: 40px;
}

.main {
  padding: 40px;
  max-width: 1600px;
  margin: 0 auto;
  transition: background-color 0.3s ease;
}

.footer {
  padding: 20px 40px;
  text-align: center;
  border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.footer__text {
  font-size: 0.875rem;
  opacity: 0.7;
  transition: color 0.3s ease;
}

/* ===== GRID DES TUILES ===== */
.tiles-container {
  display: block;
}

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

/* Responsive breakpoints */
@media (min-width: 1024px) {
  .tiles-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1023px) and (min-width: 768px) {
  .tiles-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
  }
}

@media (max-width: 767px) {
  .tiles-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
  }
  
  .main {
    padding: 20px;
  }
  
  .header {
    padding: 40px 20px 30px;
  }
  
  .header__title {
    font-size: 2rem;
  }
  
  .header__actions {
    top: 16px;
    right: 20px;
    gap: 8px;
  }
  
  .theme-toggle,
  .edit-button,
  .refresh-button,
  .export-button,
  .import-button {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  
  .header__actions {
    top: 16px;
    right: 20px;
    gap: 8px;
  }
  
  .refresh-button,
  .export-button,
  .import-button {
    gap: 4px;
  }
}

/* ===== TUILES ===== */
.tile {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
  aspect-ratio: 16 / 9;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background: var(--tile-bg, #f0f0f0);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1;
  pointer-events: none;
}

.tile:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.tile:hover::before {
  opacity: 1;
}

.tile:active {
  transform: translateY(-4px) scale(1.01);
  transition: all 0.2s ease;
}

.tile--editing {
  cursor: move;
}

.tile--editing:hover {
  transform: none;
}

.tile--drag-over {
  border: 2px dashed var(--primary-color, #007AFF);
  background-color: rgba(0, 122, 255, 0.1);
  transform: scale(1.05);
}

.tile--editing.tile--drag-over {
  border-color: var(--primary-color, #007AFF);
}

.tile__link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.tile__image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--tile-placeholder-bg, #e0e0e0);
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.tile:hover .tile__image {
  transform: scale(1.05);
}

.tile__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.7));
  z-index: 1;
  transition: background 0.4s ease;
}

.tile:hover .tile__overlay {
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.6));
}

.tile__content {
  position: relative;
  z-index: 2;
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform 0.4s ease;
}

.tile:hover .tile__content {
  transform: translateY(-4px);
}

.tile__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #F5F5F7;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  margin-bottom: 8px;
  transition: transform 0.4s ease, text-shadow 0.4s ease;
}

.tile:hover .tile__title {
  transform: translateY(-2px);
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(0, 0, 0, 0.4);
}

.tile__description {
  font-size: 0.9rem;
  color: rgba(245, 245, 247, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Contrôles d'édition */
.tile__controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: none;
  gap: 8px;
  z-index: 10;
}

.tile--editing .tile__controls {
  display: flex;
}

.tile__control-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background-color 0.2s ease;
}

.tile__control-button:hover {
  background: rgba(255, 255, 255, 1);
}

.tile__control-button--edit {
  color: #007AFF;
}

.tile__control-button--delete {
  color: #FF3B30;
}

/* Indicateur de statut */
.tile__status {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  display: none;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
}

.tile__status--offline {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #FF3B30 0%, #D70015 100%);
  color: white;
  border: 2px solid #FF3B30;
  animation: pulse-offline 2s ease-in-out infinite;
}

@keyframes pulse-offline {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.02);
  }
}

.tile__status-icon {
  font-size: 1rem;
  line-height: 1;
}

.tile__status-text {
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 0.75rem;
}

/* ===== BOUTONS ===== */
.button {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.button--primary {
  background: var(--button-primary-bg, #007AFF);
  color: white;
}

.button--primary:hover {
  background: var(--button-primary-hover, #0051D5);
}

.button--secondary {
  background: var(--button-secondary-bg, rgba(0, 0, 0, 0.1));
  color: var(--text-color, #1D1D1F);
}

.button--secondary:hover {
  background: var(--button-secondary-hover, rgba(0, 0, 0, 0.15));
}

.button--danger {
  background: #FF3B30;
  color: white;
}

.button--danger:hover {
  background: #D70015;
}

.theme-toggle,
.edit-button,
.refresh-button,
.export-button,
.import-button,
.add-tile-button,
.save-button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--button-secondary-bg, rgba(0, 0, 0, 0.1));
  color: var(--text-color, #1D1D1F);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: inherit;
}

.theme-toggle:hover,
.edit-button:hover,
.refresh-button:hover,
.export-button:hover,
.import-button:hover,
.add-tile-button:hover,
.save-button:hover {
  background: var(--button-secondary-hover, rgba(0, 0, 0, 0.15));
}

.theme-toggle:disabled,
.refresh-button:disabled,
.export-button:disabled,
.import-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.refresh-button,
.export-button,
.import-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.add-tile-button {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto 20px;
  padding: 16px 32px;
}

.add-tile-button__icon {
  font-size: 1.5rem;
  font-weight: 300;
}

.save-button {
  display: block;
  margin: 20px auto;
  padding: 16px 32px;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal__content {
  position: relative;
  background: var(--modal-bg, #FFFFFF);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  transition: background-color 0.3s ease;
}

.modal__content--small {
  max-width: 400px;
}

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-color, #1D1D1F);
  transition: color 0.2s ease;
}

.modal__close:hover {
  color: var(--text-color-hover, #000000);
}

.modal__title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 24px;
  transition: color 0.3s ease;
}

.modal__message {
  margin-bottom: 24px;
  transition: color 0.3s ease;
}

/* ===== FORMULAIRE ===== */
.tile-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.3s ease;
}

.required {
  color: #FF3B30;
}

.form-input,
.form-textarea,
.form-select {
  padding: 12px;
  border: 1px solid var(--input-border, rgba(0, 0, 0, 0.2));
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s ease, background-color 0.3s ease, color 0.3s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--input-focus-border, #007AFF);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-image-options {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.form-file {
  padding: 8px;
  font-size: 0.9rem;
}

.form-separator {
  font-size: 0.9rem;
  opacity: 0.6;
}

.form-error {
  color: #FF3B30;
  font-size: 0.875rem;
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

.form-hint {
  font-size: 0.875rem;
  opacity: 0.7;
  margin-top: 4px;
  transition: color 0.3s ease;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 16px 24px;
  background: var(--toast-bg, #1D1D1F);
  color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== UTILITIES ===== */
.hidden {
  display: none !important;
}

.editing-mode .tile__link {
  pointer-events: none;
}

.editing-mode .tile {
  cursor: move;
}

/* Catégories */
.category-group {
  margin-bottom: 32px;
}

.category-title {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 16px;
  transition: color 0.3s ease;
}
