/* ============================================================
   Mon Académie — Standalone Giri Académie
   Branding Sahara/Maha : tons chauds, or, ivoire, bordeaux
   ============================================================ */

:root {
  --bg-page: #faf6ef;
  --bg-card: #ffffff;
  --bg-elevated: #fffdf8;
  --bg-overlay: rgba(20, 12, 8, 0.55);

  --text-primary: #2a1a10;
  --text-secondary: #6b4d3a;
  --text-muted: #9c8273;

  --accent: #8b1a3c;
  --accent-hover: #6e1230;
  --gold: #c9a14a;
  --gold-light: #e8d29a;

  --border: #e8ddc9;
  --border-strong: #d4c2a0;

  --shadow-sm: 0 1px 3px rgba(75, 45, 20, 0.06);
  --shadow-md: 0 4px 16px rgba(75, 45, 20, 0.08);
  --shadow-lg: 0 12px 40px rgba(75, 45, 20, 0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ============================================================
   LOGIN — fullscreen
   ============================================================ */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(232, 210, 154, 0.35) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 26, 60, 0.08) 0%, transparent 50%),
    var(--bg-page);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px 36px;
  border: 1px solid var(--border);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}
.login-logo img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(201, 161, 74, 0.35));
}
.login-logo h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}
.login-logo p {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.form-field {
  margin-bottom: 18px;
}
.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 161, 74, 0.18);
}

.pw-wrapper { position: relative; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pw-toggle:hover { color: var(--text-secondary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--gold);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: rgba(139, 26, 60, 0.06);
  color: var(--accent);
}
.btn-block { width: 100%; }
.btn-danger {
  background: transparent;
  color: var(--accent);
  border-color: rgba(139, 26, 60, 0.3);
}
.btn-danger:hover {
  background: var(--accent);
  color: #fff;
}

.form-error {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 16px;
}
.form-error[hidden] { display: none; }

/* ============================================================
   APP LAYOUT (dashboard / universe / formation)
   ============================================================ */
body.app-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-header-left img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.app-header-left h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-name {
  font-size: 14px;
  color: var(--text-secondary);
}

.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 32px 64px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { color: var(--text-muted); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
}
.page-header .subtitle {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--text-secondary);
}

/* ============================================================
   GRID + CARDS
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold-light);
}
.card-emoji {
  font-size: 36px;
  line-height: 1;
}
.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-display);
}
.card-meta {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.card-actions {
  display: flex;
  gap: 6px;
  position: absolute;
  top: 12px;
  right: 12px;
  opacity: 0;
  transition: opacity 0.15s;
}
.card:hover .card-actions { opacity: 1; }
.icon-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.icon-btn:hover {
  border-color: var(--gold);
  color: var(--accent);
}
.icon-btn.danger:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* Empty state — accueillant, pas austère */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.empty h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 14px 0 8px;
  color: var(--text-primary);
}
.empty p { margin: 0 0 20px; font-size: 14px; max-width: 420px; margin-left: auto; margin-right: auto; }
.empty .empty-icon { font-size: 48px; line-height: 1; }

/* Empty state — accueil première connexion (dashboard vide) */
.empty-welcome {
  text-align: center;
  padding: 80px 32px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(232, 210, 154, 0.25) 0%, transparent 60%),
    var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.empty-welcome::before {
  content: '';
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
}
.empty-welcome .empty-orb {
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
  filter: drop-shadow(0 8px 24px rgba(201, 161, 74, 0.35));
}
.empty-welcome h3 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text-primary);
}
.empty-welcome p {
  margin: 0 auto 28px;
  max-width: 460px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.empty-welcome .btn {
  font-size: 16px;
  padding: 14px 28px;
}

/* Banner discret pour onboarding en cours */
.welcome-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(232, 210, 154, 0.18) 0%, rgba(255, 253, 248, 1) 100%);
  border: 1px solid var(--gold-light);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}
.welcome-banner .wave {
  font-size: 22px;
  line-height: 1;
}
.welcome-banner-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
}
.welcome-banner-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
}

/* ============================================================
   LIST (modules / lessons)
   ============================================================ */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: border-color 0.15s;
}
.list-item:hover { border-color: var(--gold-light); }
.list-item-main {
  flex: 1;
  min-width: 0;
}
.list-item-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.list-item-meta {
  font-size: 13px;
  color: var(--text-muted);
}
.list-item-actions {
  display: flex;
  gap: 6px;
}

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.section-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-primary);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}
.modal-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--text-primary);
}
.modal-body { padding: 24px 28px; }
.modal-footer {
  padding: 16px 28px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  font-size: 14px;
  animation: slideUp 0.2s ease-out;
}
.toast.success { background: #1a6e3a; }
.toast.error { background: #b91c1c; }

/* ============================================================
   EMOJI / ICON PICKER (light)
   ============================================================ */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin-top: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.emoji-btn {
  font-size: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  transition: all 0.1s;
}
.emoji-btn:hover { background: var(--bg-card); border-color: var(--gold-light); }
.emoji-btn.active { background: var(--gold-light); border-color: var(--gold); }

/* ============================================================
   LOADER
   ============================================================ */
.loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .app-header { padding: 12px 16px; }
  .app-header-left h1 { font-size: 18px; }
  .app-main { padding: 24px 16px 48px; }
  .page-header h2 { font-size: 24px; }
  .login-card { padding: 32px 24px; }
  .grid { grid-template-columns: 1fr; }
}

/* ============================================================
   ÉDITEUR DE LEÇON
   ============================================================ */
.lesson-editor-main { max-width: 960px; }

.lesson-editor {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
  margin-top: 16px;
}

.lesson-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.lesson-title-input {
  flex: 1;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  border: none;
  background: transparent;
  padding: 8px 0;
  outline: none;
}
.lesson-title-input::placeholder { color: var(--text-muted); font-style: italic; }
.lesson-title-input:focus { border-bottom: 2px solid var(--accent); }

.lesson-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.save-status {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.save-status.dirty { color: #b8860b; }
.save-status.saved { color: #2d8659; }

/* Tabs */
.lesson-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-secondary, #faf8f3);
  transition: all 0.2s;
}
.upload-zone-inner { pointer-events: auto; }
.upload-zone.drag-over,
.upload-zone-inner.drag-over {
  border-color: var(--accent);
  background: rgba(139, 26, 60, 0.04);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}
.upload-zone h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--text-primary);
}
.upload-zone p {
  margin: 4px 0;
  color: var(--text-secondary, #666);
  font-size: 14px;
}
.upload-hint {
  margin-top: 16px !important;
  font-size: 12px !important;
  color: var(--text-muted) !important;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}
.link-btn:hover { opacity: 0.8; }

.upload-progress {
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #c2185b);
  width: 0;
  transition: width 0.3s;
}
.progress-text {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-secondary, #666);
  text-align: center;
}

/* Video preview */
.video-preview {
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
}
.video-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.video-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Textarea leçon */
.lesson-textarea {
  font-family: 'Inter', monospace;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  min-height: 320px;
}

/* PDF preview */
.pdf-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-secondary, #faf8f3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.pdf-icon {
  font-size: 36px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.pdf-info {
  flex: 1;
  min-width: 0;
}
.pdf-info strong {
  display: block;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-all;
}
.pdf-info a {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}
.pdf-info a:hover { text-decoration: underline; }

/* Audio preview */
.audio-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-secondary, #faf8f3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.audio-preview audio { flex: 1; }

/* List item cliquable */
.list-item-clickable { cursor: pointer; transition: background 0.15s; }
.list-item-clickable:hover { background: var(--bg-secondary, #faf8f3); }

@media (max-width: 640px) {
  .lesson-editor { padding: 20px; }
  .lesson-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .lesson-header-actions { width: 100%; justify-content: space-between; }
  .lesson-title-input { font-size: 22px; }
  .upload-zone { padding: 28px 16px; }
}
