/* Ma Boîte à Outils - CSS complet corrigé */

/* Section principale */
.boite-outils-main-section {
  padding: 2rem 0;
  background: var(--bg-main, #fff);
}

/* Container interne */
.boite-outils-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Message non connecté */
.not-logged-in-message {
  max-width: 600px;
  margin: 4rem auto;
  text-align: center;
  padding: 0 1rem;
}

.login-prompt {
  background: var(--bg-card, #fff);
  border-radius: 12px;
  padding: 3rem 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border-left: 6px solid #a76107;
}

.login-prompt h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-main, #333);
}

.login-prompt p {
  font-size: 1.1rem;
  color: var(--text-secondary, #666);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.login-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: inherit;
}

.btn .icon {
  font-size: 1.2rem;
}

.btn-primary {
  background: linear-gradient(135deg, #c97b0d 0%, #a76107 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(167, 97, 7, 0.4);
}

.btn-secondary {
  background: var(--bg-card, #f5f5f5);
  color: var(--text-main, #333);
  border: 2px solid var(--border, #ddd);
}

.btn-secondary:hover {
  background: var(--bg-hover, #e0e0e0);
}

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

.btn-danger:hover {
  background: #e84351;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Grille des cartes */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.card-item {
  background: var(--bg-card, white);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  position: relative;
}

.card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.card-item.color-blue { border-left: 6px solid #3498db; }
.card-item.color-green { border-left: 6px solid #2ecc71; }
.card-item.color-orange { border-left: 6px solid #e67e22; }
.card-item.color-purple { border-left: 6px solid #9b59b6; }
.card-item.color-red { border-left: 6px solid #e74c3c; }
.card-item.color-gray { border-left: 6px solid #95a5a6; }

/* États drag & drop */
.card-item.dragging {
  opacity: 0;
  pointer-events: none;
}

.card-item.drag-over {
  border-top: 3px solid #a76107;
  margin-top: 1rem;
  transition: all 0.2s ease;
}

/* Clone de la carte qui suit la souris */
.card-clone {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  opacity: 0.95;
  transform: scale(1.05);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: none;
  cursor: grabbing;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border, #e0e0e0);
  cursor: move;
  cursor: grab;
  user-select: none;
}

.card-header:active {
  cursor: grabbing;
}

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

.card-icon img {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
}

.card-title-text {
  flex: 1;
}

.card-title-text h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-main, #333);
  font-weight: 600;
}

.card-description {
  color: var(--text-secondary, #666);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.card-links {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.card-links li {
  margin-bottom: 0.5rem;
}

.card-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #a76107;
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.card-links a:hover {
  color: #c97b0d;
  text-decoration: underline;
}

.card-links a::before {
  content: "🔗";
  font-size: 0.9rem;
}

/* Bouton settings dans le header */
.card-settings-menu {
  position: relative;
  margin-left: auto;
}

.card-settings-btn {
  background: none;
  border: 2px solid var(--border, #ddd);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-settings-btn img {
  width: 28px;
  height: 28px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.card-settings-btn:hover {
  background: var(--bg-hover, #f0f0f0);
  border-color: #a76107;
}

.card-settings-btn:hover img {
  opacity: 1;
}

/* Menu dropdown */
.settings-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card, white);
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  min-width: 150px;
  margin-top: 0.25rem;
}

.settings-dropdown.show {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main, #333);
  transition: background 0.2s;
}

.dropdown-item:first-child {
  border-radius: 6px 6px 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 6px 6px;
}

.dropdown-item:hover {
  background: var(--bg-hover, #f0f0f0);
}

.dropdown-delete {
  color: #e74c3c;
}

.dropdown-delete:hover {
  background: #e74c3c;
  color: white;
}

/* État vide */
.empty-state {
  display: none;
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state.show {
  display: block;
}

.empty-state-content {
  max-width: 500px;
  margin: 0 auto;
}

.empty-state-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-main, #333);
}

.empty-state p {
  color: var(--text-secondary, #666);
  font-size: 1rem;
}

/* ===== MODALS ===== */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  overflow: auto;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-card, white);
  border-radius: 12px;
  width: 90%;
  max-width: 1200px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-height: 90vh;
  overflow: auto;
}

.modal-icons-content {
  max-width: 90vw;
  width: 1200px;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border, #e0e0e0);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-main, #333);
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-secondary, #666);
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-hover, #f0f0f0);
  color: var(--text-main, #333);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border, #e0e0e0);
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-main, #333);
}

.char-count {
  float: right;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary, #999);
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-card, white);
  color: var(--text-main, #333);
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: #a76107;
  box-shadow: 0 0 0 3px rgba(167, 97, 7, 0.1);
}

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

hr {
  border: none;
  border-top: 1px solid var(--border, #e0e0e0);
  margin: 1.5rem 0;
}

h4 {
  margin: 0 0 1rem 0;
  color: var(--text-main, #333);
  font-size: 1.1rem;
}

/* Icon selector */
.icon-selector {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-icon-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card, white);
  border: 2px solid var(--border, #ddd);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 1rem;
}

.btn-icon-select:hover {
  border-color: #667eea;
  background: var(--bg-hover, #f5f5f5);
}

#selected-icon-preview {
  font-size: 1.5rem;
  line-height: 1;
}

/* Icons grid - optimisé pour 400+ icônes */
.icons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 0.4rem;
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.5rem;
}

.icon-option {
  padding: 0.5rem;
  border: 2px solid var(--border, #ddd);
  border-radius: 6px;
  background: #f5f5f5;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
}

.icon-option img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.icon-option:hover {
  border-color: #667eea;
  background: var(--bg-hover, #f5f5f5);
  transform: scale(1.05);
  z-index: 10;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.icon-option.selected {
  border-color: #667eea;
  background: #f0f3ff;
  border-width: 3px;
}

/* Links container */
#links-container {
  margin-bottom: 1rem;
}

.link-item {
  margin-bottom: 0.75rem;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--bg-page, #f9f9f9);
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.link-inputs {
  display: flex;
  gap: 0.5rem;
  flex: 1;
}

.link-inputs input {
  flex: 1;
}

.link-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary, #666);
  user-select: none;
}

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

.checkbox-label span {
  white-space: nowrap;
}

/* Boutons de réorganisation */
.link-reorder-buttons {
  display: flex;
  gap: 0.25rem;
}

.btn-move-up,
.btn-move-down {
  padding: 0.4rem 0.6rem;
  background: var(--bg-card, white);
  color: var(--text-main, #333);
  border: 1px solid var(--border, #ddd);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: all 0.2s;
  font-family: inherit;
  font-weight: bold;
}

.btn-move-up:hover,
.btn-move-down:hover {
  background: #a76107;
  color: white;
  border-color: #a76107;
}

.btn-remove-link {
  padding: 0.5rem 0.75rem;
  background: #ff4757;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  font-family: inherit;
  flex-shrink: 0;
}

.btn-remove-link:hover {
  background: #e84351;
}

/* Export/Import sections */
.export-section,
.import-section {
  margin-bottom: 1.5rem;
}

.export-section:last-child,
.import-section:last-child {
  margin-bottom: 0;
}

/* Loading state - SÉLECTEUR SPÉCIFIQUE pour éviter de cibler l'élément HTML */
.icons-grid .loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary, #666);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 1024px) {
  .link-item {
    flex-wrap: wrap;
  }

  .link-inputs {
    flex: 1 1 100%;
  }

  .link-controls {
    flex: 1 1 100%;
    justify-content: space-between;
  }
}

@media (max-width: 768px) {
  .boite-outils-container {
    padding: 0 0.75rem;
  }

  .toolbar {
    gap: 0.75rem;
  }

  .btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
  }

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

  .modal-content {
    width: 95%;
    max-width: 95%;
    max-height: 95vh;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .icons-grid {
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    gap: 0.3rem;
  }

  .modal-icons-content {
    width: 95vw;
    max-width: 95vw;
  }

  .link-item {
    flex-direction: column;
    align-items: stretch;
  }

  .link-inputs {
    flex-direction: column;
  }

  .link-controls {
    justify-content: space-between;
  }

  .btn-remove-link {
    width: auto;
  }
}

@media (max-width: 480px) {
  .boite-outils-main-section {
    padding: 1.5rem 0;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .btn {
    width: 100%;
  }

  .card-item {
    padding: 1rem;
  }

  .card-actions {
    flex-wrap: wrap;
  }

  .card-btn {
    flex: 1 1 45%;
  }

  .card-btn-delete {
    flex: 1 1 100%;
    margin-left: 0;
  }
}

/* ===== DARK THEME ===== */

:root.theme-dark .boite-outils-main-section {
  background: var(--bg-page, #1a1a1a);
}

:root.theme-dark .login-prompt {
  background: var(--bg-card, #2a2a2a);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

:root.theme-dark .card-item {
  background: var(--bg-card, #2a2a2a);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

:root.theme-dark .modal {
  background: rgba(0, 0, 0, 0.8);
}

:root.theme-dark .modal-content {
  background: var(--bg-card, #2a2a2a);
}

:root.theme-dark .modal-header,
:root.theme-dark .modal-footer {
  border-color: var(--border, #3a3a3a);
}

:root.theme-dark .form-control {
  background: var(--bg-page, #1a1a1a);
  border-color: var(--border, #3a3a3a);
  color: var(--text-main, #e0e0e0);
}

:root.theme-dark .form-control:focus {
  border-color: #667eea;
  background: var(--bg-page, #1a1a1a);
}

:root.theme-dark .btn-icon-select {
  background: var(--bg-page, #1a1a1a);
  border-color: var(--border, #3a3a3a);
  color: var(--text-main, #e0e0e0);
}

:root.theme-dark .btn-icon-select:hover {
  background: var(--bg-card, #2a2a2a);
}

:root.theme-dark .icon-option {
  background: var(--bg-page, #1a1a1a);
  border-color: var(--border, #3a3a3a);
}

:root.theme-dark .icon-option:hover {
  background: var(--bg-card, #2a2a2a);
}

:root.theme-dark .icon-option.selected {
  background: #2a2a4a;
  border-color: #667eea;
}

:root.theme-dark .card-settings-btn:hover {
  background: var(--bg-hover, #3a3a3a);
}

:root.theme-dark .settings-dropdown {
  background: var(--bg-card, #2a2a2a);
  border-color: var(--border, #3a3a3a);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

:root.theme-dark .dropdown-item {
  color: var(--text-main, #e0e0e0);
}

:root.theme-dark .dropdown-item:hover {
  background: var(--bg-hover, #3a3a3a);
}

:root.theme-dark .dropdown-delete:hover {
  background: #e74c3c;
  color: white;
}

:root.theme-dark .btn-secondary {
  background: var(--bg-card, #2a2a2a);
  border-color: var(--border, #3a3a3a);
  color: var(--text-main, #e0e0e0);
}

:root.theme-dark .btn-secondary:hover {
  background: var(--bg-hover, #3a3a3a);
}
