/* ═══════════════════════════════════════════════════════════════
   Vidéothèque MTC & Spiritualité — Thème Zen
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:          #f4f0e8;
  --bg-alt:      #ede8dc;
  --surface:     #ffffff;
  --border:      #d4cfc3;
  --text:        #2c2c2c;
  --text-muted:  #7a7468;
  --accent:      #5a8a5a;
  --accent-dark: #3d6b3d;
  --gold:        #c8a84b;
  --shadow:      rgba(0,0,0,.08);
  --radius:      10px;
  --font:        'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #2c3e2d 0%, #3d5c3e 60%, #5a8a5a 100%);
  color: #fff;
  padding: 1.5rem 2rem;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  position: relative;
}

header::after {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin-top: 1rem;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 300;
  letter-spacing: .15em;
  text-transform: uppercase;
}

header p.subtitle {
  font-size: .85rem;
  opacity: .7;
  letter-spacing: .1em;
  margin-top: .3rem;
}

/* ── Onglets principaux ──────────────────────────────────────── */
.main-tabs {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 1rem .5rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

.main-tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: .6rem 2rem;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .2s;
  font-family: var(--font);
  letter-spacing: .05em;
}

.main-tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.main-tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(90,138,90,.35);
}

.tab-count {
  display: inline-block;
  background: rgba(255,255,255,.3);
  border-radius: 12px;
  padding: .05rem .5rem;
  font-size: .8rem;
  margin-left: .4rem;
}

.main-tab-btn:not(.active) .tab-count {
  background: var(--bg-alt);
  color: var(--text-muted);
}

/* ── Sections ────────────────────────────────────────────────── */
.section-panel {
  display: none;
  padding: 1.5rem 2rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
}

.section-panel.active { display: block; }

/* ── Sous-onglets Spiritualité ───────────────────────────────── */
.sub-tabs {
  display: flex;
  gap: .8rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.sub-tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem 1.4rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-muted);
  transition: all .2s;
  font-family: var(--font);
}

.sub-tab-btn:hover { border-color: var(--gold); color: #8a6a1a; }

.sub-tab-btn.active {
  background: linear-gradient(135deg, #8a6a1a, var(--gold));
  border-color: var(--gold);
  color: #fff;
  box-shadow: 0 2px 8px rgba(200,168,75,.35);
}

/* ── Section title ───────────────────────────────────────────── */
.section-title {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .6rem;
}

.section-title strong {
  color: var(--text);
  font-size: 1.1rem;
}

/* ── Grille de cards ─────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.1rem .9rem;
  box-shadow: 0 1px 4px var(--shadow);
  border-left: 5px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: box-shadow .2s, transform .15s;
  position: relative;
}

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

.card-header {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}

.card-index {
  font-size: .72rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-radius: 4px;
  padding: .1rem .4rem;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: .1rem;
  font-weight: 600;
  letter-spacing: .03em;
}

.card-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .78rem;
  color: var(--text-muted);
}

.card-type {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: capitalize;
  color: #fff;
  letter-spacing: .03em;
}

.card-duree {
  display: flex;
  align-items: center;
  gap: .25rem;
}

/* ── Boutons d'action ────────────────────────────────────────── */
.card-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .78rem;
  font-family: var(--font);
  font-weight: 600;
  transition: all .18s;
  text-decoration: none;
  letter-spacing: .03em;
}

.btn-play {
  background: var(--accent);
  color: #fff;
}
.btn-play:hover { background: var(--accent-dark); }

.btn-resume {
  background: #c07a3a;
  color: #fff;
}
.btn-resume:hover { background: #a0622a; }

.btn-pdf {
  background: #7a5a9e;
  color: #fff;
}
.btn-pdf:hover { background: #624880; }

/* ── Modal vidéo ─────────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

#modal-overlay.open { display: flex; }

#modal-box {
  background: #111;
  border-radius: 12px;
  max-width: 900px;
  width: 94%;
  padding: 0;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  overflow: hidden;
}

#modal-header {
  background: linear-gradient(135deg, #2c3e2d, #3d5c3e);
  padding: .8rem 1.2rem .8rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

#modal-title {
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  flex: 1;
}

#modal-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
#modal-close:hover { background: rgba(255,255,255,.3); }

#modal-video {
  width: 100%;
  max-height: 70vh;
  display: block;
  background: #000;
}

/* ── Loading ─────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: .95rem;
}

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: .8rem;
}

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

/* ── Bouton édition sur card ─────────────────────────────────── */
.btn-edit {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .8rem;
  color: var(--text-muted);
  transition: all .18s;
  padding: 0;
}
.btn-edit:hover {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Bouton Ajouter flottant ─────────────────────────────────── */
#btn-add {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(90,138,90,.5);
  transition: all .2s;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
#btn-add:hover {
  background: var(--accent-dark);
  transform: scale(1.08);
}

/* ── Modal formulaire ────────────────────────────────────────── */
#form-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#form-overlay.open { display: flex; }

#form-box {
  background: var(--surface);
  border-radius: 12px;
  width: 500px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.3);
  overflow: hidden;
}

#form-header {
  background: linear-gradient(135deg, #2c3e2d, #4a7a4a);
  color: #fff;
  padding: .9rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#form-title { font-size: .95rem; font-weight: 600; }

#form-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#form-close:hover { background: rgba(255,255,255,.3); }

#form-body {
  padding: 1.2rem 1.4rem;
  overflow-y: auto;
  flex: 1;
}

.form-row {
  margin-bottom: .85rem;
}
.form-row label {
  display: block;
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: .28rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.form-row small { font-weight: 400; opacity: .75; }
.form-row input,
.form-row select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .45rem .7rem;
  font-size: .88rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}
.form-row input:focus,
.form-row select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
  background: #fff;
}

#form-actions {
  display: flex;
  align-items: center;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn-save {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .5rem 1.4rem;
  cursor: pointer;
  font-size: .88rem;
  font-family: var(--font);
  font-weight: 600;
}
.btn-save:hover { background: var(--accent-dark); }

.btn-cancel {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem 1rem;
  cursor: pointer;
  font-size: .88rem;
  font-family: var(--font);
}
.btn-cancel:hover { border-color: var(--text-muted); }

.btn-delete {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .5rem 1rem;
  cursor: pointer;
  font-size: .88rem;
  font-family: var(--font);
}
.btn-delete:hover { background: #a93226; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .section-panel { padding: 1rem 1rem 2rem; }
  .cards-grid { grid-template-columns: 1fr; }
  header h1 { font-size: 1.3rem; }
  .main-tabs { gap: .5rem; }
  .main-tab-btn { padding: .5rem 1.2rem; font-size: .88rem; }
}
