* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --gold: #c49a03;
  --gold-light: #F2BF00;
  --navy: #1a1a2e;
  --navy-2: #16213e;
  --bg: #f4f1eb;
  --card: #ffffff;
  --text: #2d3436;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #e74c3c;
  --danger-dark: #c0392b;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================
   BACKGROUND PARTITION
=========================== */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url('/images/partition.png');
  background-size: cover;
  background-position: center;
  opacity: 0.04;
  z-index: 0;
  pointer-events: none;
}

/* ============================
   HEADER
=========================== */
.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
}

.header-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s;
  flex-shrink: 0;
}

.header-back:hover {
  background: rgba(242, 191, 0, 0.2);
  color: var(--gold-light);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.header-logo {
  height: 40px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}

.header-right {
  margin-left: auto;
}

.doc-count-badge {
  background: rgba(242, 191, 0, 0.15);
  border: 1px solid rgba(242, 191, 0, 0.35);
  color: var(--gold-light);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ============================
   SEARCH
=========================== */
.search-section {
  position: relative;
  z-index: 1;
  padding: 24px 24px 0;
  display: flex;
  justify-content: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  padding: 0 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 50px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.07);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.search-box:focus-within {
  border-color: var(--gold);
  box-shadow: 0 4px 20px rgba(196, 154, 3, 0.15);
}

.search-box .search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

.search-box input,
.search-box input[type="text"] {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 14px 0;
  border: none;
  border-radius: 0;
  background: transparent;
  margin-bottom: 0;
  font-size: 0.97rem;
  color: var(--text);
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  flex-shrink: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.search-box input:not(:placeholder-shown) ~ .search-clear {
  opacity: 1;
}

/* ============================
   DOCUMENT LIST
=========================== */
.doc-section {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 20px 24px 60px;
}

#documentList {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Carte document ── */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.doc-card {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  animation: cardIn 0.35s ease both;
}

.doc-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.12);
  border-color: var(--gold);
}

.doc-card:hover .doc-icon {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
}

.doc-card:hover .doc-icon img {
  filter: brightness(0) invert(1);
}

/* Icône gauche */
.doc-card-left {
  flex-shrink: 0;
}

.doc-icon {
  width: 64px;
  height: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f5ef, #f0ece4);
  border-right: 1px solid var(--border);
  transition: background 0.2s;
  padding: 12px;
}

.doc-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  transition: filter 0.2s;
}

/* Corps */
.doc-card-body {
  flex: 1;
  padding: 14px 16px;
  min-width: 0;
}

.doc-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.meta-item i {
  font-size: 0.72rem;
}

.meta-audio {
  color: #16a34a;
  font-weight: 600;
}

.meta-no-audio {
  color: #94a3b8;
}

.meta-stars {
  font-size: 0.85rem;
  line-height: 1;
}

/* Flèche droite */
.doc-card-right {
  padding: 0 18px;
  flex-shrink: 0;
}

.doc-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color 0.2s, transform 0.2s;
}

.doc-card:hover .doc-arrow {
  color: var(--gold);
  transform: translateX(4px);
}

/* Anciens sélecteurs conservés pour la page admin */
.doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.doc-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  border-color: var(--gold);
}

.doc-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.music-emoji {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.doc-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: color 0.2s, transform 0.2s;
}

.doc-row:hover .doc-arrow {
  color: var(--gold);
  transform: translateX(3px);
}

/* Admin action buttons */
.doc-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.action-btn {
  padding: 7px 14px;
  background: var(--gold);
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}

.action-btn:hover {
  background: var(--gold-light);
  transform: scale(1.04);
}

.action-Supprimer {
  padding: 7px 14px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}

.action-Supprimer:hover {
  background: var(--danger-dark);
  transform: scale(1.04);
}

/* ============================
   EMPTY STATE
=========================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 1.05rem;
}

/* ============================
   WATERMARK
=========================== */
.watermark {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 0;
  pointer-events: none;
  opacity: 0.06;
}

.watermark img {
  width: 260px;
}

/* ============================
   MODAL
=========================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(3px);
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 480px;
  position: relative;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  border-top: 4px solid var(--gold);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content h2 {
  font-size: 1.2rem;
  color: var(--navy);
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 30px;
  height: 30px;
  background: #fee2e2;
  color: #dc2626;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
  transition: background 0.2s;
}

.close:hover {
  background: #fca5a5;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

/* Styles pour les inputs de formulaire (modals, forms) — pas le search */
.modal-content input[type="text"],
.modal-content textarea,
.modal-content input[type="file"],
.form-group input[type="text"],
.form-group textarea,
.form-group input[type="file"] {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: 9px;
  font-size: 0.93rem;
  color: var(--text);
  margin-bottom: 14px;
  transition: border-color 0.2s;
  background: #f8fafc;
}

.modal-content input[type="text"]:focus,
.modal-content textarea:focus,
.form-group input[type="text"]:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--gold);
}

input[type="file"] {
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.modal-content button[type="submit"],
.modal-content button[type="button"] {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
  border: none;
  border-radius: 9px;
  font-size: 0.97rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 4px;
}

.modal-content button[type="submit"]:hover,
.modal-content button[type="button"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(196,154,3,0.35);
}

/* ============================
   MODAL AVIS (reviews)
=========================== */
.modal-wide {
  max-width: 560px;
}

.reviews-modal-list {
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
  margin: 0 -32px -32px;
  padding: 0 0 8px;
}

.reviews-comment-item {
  display: flex;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid #f1f5f9;
}

.reviews-comment-item:last-child { border-bottom: none; }

.reviews-reply-item {
  padding-left: 48px;
  background: #fafaf8;
  border-left: 3px solid #F2BF00;
}

.rev-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a2e, #302b63);
  color: #F2BF00;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rev-body { flex: 1; min-width: 0; }

.rev-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.rev-author { font-weight: 700; font-size: 0.85rem; color: #1e293b; }
.rev-date   { font-size: 0.72rem; color: #94a3b8; }
.rev-stars  { font-size: 0.85rem; }

.rev-text {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.55;
  word-break: break-word;
}

/* Bouton "Voir les avis" sur les cartes */
.see-reviews-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 4px 10px;
  background: rgba(196,154,3,0.1);
  color: #c49a03;
  border: 1px solid rgba(196,154,3,0.3);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.see-reviews-btn:hover {
  background: rgba(196,154,3,0.22);
  color: #a07d02;
}

/* Toggle réponses dans le modal */
.rev-replies-toggle {
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}
.rev-replies-toggle:hover { color: #c49a03; }

/* "En réponse à X" dans le modal */
.rev-reply-to {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  color: #94a3b8;
  margin-bottom: 4px;
}
.rev-reply-to i      { font-size: 0.65rem; }
.rev-reply-to strong { color: #c49a03; font-weight: 700; }

/* Badge officiel */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(196,154,3,0.12);
  color: #c49a03;
  border: 1px solid rgba(196,154,3,0.35);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Avatar doré admin */
.admin-avatar {
  background: linear-gradient(135deg, #c49a03, #F2BF00) !important;
  color: #1a1a2e !important;
  font-size: 1.05rem !important;
}

/* Fond doré pour ligne admin */
.comment-admin {
  background: rgba(242,191,0,0.05);
}

/* ============================
   LOGOUT BTN (admin view bar)
=========================== */
.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.logout-btn:hover { background: #c0392b; }

/* ============================
   RESPONSIVE
=========================== */
@media (max-width: 600px) {
  .page-header { padding: 10px 14px; }
  .header-title { font-size: 0.95rem; }
  .search-section { padding: 14px 14px 0; }
  .doc-section { padding: 14px 14px 30px; }
  .doc-row { padding: 12px 14px; }
  .action-btn, .action-Supprimer { padding: 6px 10px; font-size: 0.76rem; }
}
