/* ============================================================
   CONTENT OS — Styles
   Responsive : mobile first, sidebar sur desktop
   ============================================================ */

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

:root {
  --blue:    #2563eb;
  --blue-bg: #eff6ff;
  --blue-bd: #bfdbfe;
  --blue-tx: #1d4ed8;
  --purple:    #7c3aed;
  --purple-bg: #f5f3ff;
  --purple-bd: #ddd6fe;
  --purple-tx: #6d28d9;
  --green:    #16a34a;
  --green-bg: #f0fdf4;
  --amber:    #d97706;
  --amber-bg: #fffbeb;
  --red-tx:   #dc2626;
  --surface:  #ffffff;
  --surface-1:#f8fafc;
  --surface-2:#f1f5f9;
  --border:   #e2e8f0;
  --border-2: #cbd5e1;
  --text:     #0f172a;
  --text-2:   #475569;
  --text-3:   #94a3b8;
  --radius:   8px;
  --shadow:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue-bg: #1e3a5f; --blue-bd: #1d4ed8; --blue-tx: #93c5fd;
    --purple-bg: #2e1065; --purple-bd: #6d28d9; --purple-tx: #c4b5fd;
    --green-bg: #052e16;
    --amber-bg: #451a03;
    --surface:  #1e293b;
    --surface-1:#0f172a;
    --surface-2:#1e293b;
    --border:   #334155;
    --border-2: #475569;
    --text:     #f1f5f9;
    --text-2:   #94a3b8;
    --text-3:   #64748b;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--surface-1);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ——— LAYOUT ——— */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Desktop : sidebar + main */
@media (min-width: 768px) {
  .app { flex-direction: row; }
}

/* ——— SIDEBAR ——— */

.sidebar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0;
  flex-shrink: 0;
  z-index: 10;
}

@media (min-width: 768px) {
  .sidebar {
    width: 240px;
    border-bottom: none;
    border-right: 1px solid var(--border);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

.sidebar-logo {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-title { font-size: 16px; font-weight: 600; }
.sidebar-logo-sub   { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* Mobile : navigation horizontale en bas */
.mobile-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  font-size: 10px;
  color: var(--text-3);
  cursor: pointer;
  border: none;
  background: none;
  gap: 3px;
}

.mobile-nav-item svg { width: 22px; height: 22px; stroke-width: 1.5; }
.mobile-nav-item.active { color: var(--blue); }
.mobile-nav-item.active.diane { color: var(--purple); }

@media (min-width: 768px) {
  .mobile-nav { display: none; }
}

/* Desktop nav */
.desktop-nav { display: none; }

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    flex: 1;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 1rem;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
}

.nav-item svg { width: 18px; height: 18px; stroke-width: 1.5; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-1); color: var(--text); }
.nav-item.active { color: var(--blue); font-weight: 500; background: var(--blue-bg); }
.nav-item.active.diane { color: var(--purple); background: var(--purple-bg); }

/* ——— PROFILE SWITCHER ——— */

.profile-switcher {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.profile-switcher-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  padding: 0 2px;
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  margin-bottom: 5px;
  transition: all 0.12s;
  text-align: left;
  color: var(--text);
}

.profile-btn:hover { background: var(--surface-1); }
.profile-btn.active-blue   { border-color: var(--blue);   background: var(--blue-bg); }
.profile-btn.active-purple { border-color: var(--purple); background: var(--purple-bg); }

.profile-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}

.av-blue   { background: var(--blue);   color: #fff; }
.av-purple { background: var(--purple); color: #fff; }

.profile-name { font-size: 13px; font-weight: 500; }
.profile-sub  { font-size: 11px; color: var(--text-3); }

/* Mobile profile switcher - compact en haut */
.mobile-profile-bar {
  display: flex;
  gap: 6px;
  padding: 8px 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

@media (min-width: 768px) {
  .mobile-profile-bar { display: none; }
}

.mobile-profile-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  color: var(--text-2);
  flex-shrink: 0;
}

.mobile-profile-chip.active-blue   { border-color: var(--blue);   background: var(--blue-bg);   color: var(--blue-tx); }
.mobile-profile-chip.active-purple { border-color: var(--purple); background: var(--purple-bg); color: var(--purple-tx); }

/* ——— MAIN ——— */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: 70px; /* espace pour la nav mobile */
}

@media (min-width: 768px) {
  .main { padding-bottom: 0; }
}

/* ——— TOPBAR ——— */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-size: 15px; font-weight: 600; }

.profile-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.pill-blue   { background: var(--blue-bg);   color: var(--blue-tx);   border: 1px solid var(--blue-bd); }
.pill-purple { background: var(--purple-bg); color: var(--purple-tx); border: 1px solid var(--purple-bd); }

/* ——— BOUTONS ——— */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-1); }
.btn:active { transform: scale(0.98); }

.btn-blue {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-blue:hover { background: #1d4ed8; }

.btn-purple {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}
.btn-purple:hover { background: #6d28d9; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

/* ——— CONTENU ——— */

.content {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .content { padding: 1.5rem; }
}

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

/* ——— CARDS ——— */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.card + .card { margin-top: 10px; }

/* ——— SEMAINE ——— */

.theme-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 1rem;
  font-weight: 500;
}

.badge-blue   { background: var(--blue-bg);   color: var(--blue-tx);   border: 1px solid var(--blue-bd); }
.badge-purple { background: var(--purple-bg); color: var(--purple-tx); border: 1px solid var(--purple-bd); }

.week-grid { display: grid; gap: 10px; }

.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.day-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}

.day-card.done-blue   { border-left: 3px solid var(--blue); }
.day-card.done-purple { border-left: 3px solid var(--purple); }

.day-card.generating { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.55} }

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}

.day-label { font-size: 14px; font-weight: 600; }

.day-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
}

.tag-tofu    { background: var(--blue-bg);   color: var(--blue-tx); }
.tag-mofu    { background: var(--amber-bg);  color: var(--amber); }
.tag-bofu    { background: var(--green-bg);  color: var(--green); }
.tag-large   { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.tag-premium { background: var(--purple-bg); color: var(--purple-tx); }

.day-format { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }

.day-hook {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  font-style: italic;
}

.generating-msg {
  font-size: 12px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ——— STATUTS ——— */

.status-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  display: inline-block;
}

.status-genere   { background: var(--surface-2); color: var(--text-2); }
.status-tourne   { background: var(--amber-bg);  color: var(--amber); }
.status-publie   { background: var(--green-bg);  color: var(--green); }

/* ——— SPINNER ——— */

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.sp-blue   { border: 2px solid var(--blue-bd);   border-top-color: var(--blue); }
.sp-purple { border: 2px solid var(--purple-bd); border-top-color: var(--purple); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ——— EMPTY STATE ——— */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-icon {
  width: 48px; height: 48px;
  color: var(--text-3);
  margin: 0 auto 1rem;
}

.empty-state p { color: var(--text-2); font-size: 14px; margin-bottom: 1.5rem; }

/* ——— BRAIN / BIBLIO ——— */

.brain-grid { display: grid; gap: 10px; }

.brain-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.brain-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.brain-title svg { width: 16px; height: 16px; stroke-width: 1.5; color: var(--text-3); }

.brain-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  white-space: pre-line;
}

/* ——— PERFORMANCES ——— */

.stats-form { display: grid; gap: 12px; }

.form-group { display: grid; gap: 4px; }

.form-group label {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.12s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

/* ——— MODAL ——— */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 50;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 768px) {
  .modal-overlay { align-items: center; padding: 1rem; }
}

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

.modal {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
}

@media (min-width: 768px) {
  .modal {
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
  }
}

/* Drag handle mobile */
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

@media (min-width: 768px) {
  .modal-handle { display: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title { font-size: 15px; font-weight: 600; }

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 22px;
  line-height: 1;
  padding: 2px;
  border-radius: 4px;
}

.close-btn:hover { color: var(--text); background: var(--surface-2); }

.modal-section { margin-bottom: 1rem; }

.modal-section label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  display: block;
  margin-bottom: 4px;
}

.modal-section p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  white-space: pre-wrap;
}

.modal-divider { height: 1px; background: var(--border); margin: 1rem 0; }

.sub-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ——— TOASTS ——— */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease;
  max-width: 280px;
}

.toast-success { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.toast-error   { background: #fef2f2; color: var(--red-tx); border: 1px solid #fecaca; }
.toast-info    { background: var(--blue-bg); color: var(--blue-tx); border: 1px solid var(--blue-bd); }

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

/* ——— ANALYSE ——— */

.analyse-section { margin-bottom: 1.5rem; }
.analyse-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.analyse-list { list-style: none; display: grid; gap: 6px; }
.analyse-list li { font-size: 13px; color: var(--text-2); padding-left: 1rem; position: relative; line-height: 1.5; }
.analyse-list li::before { content: "→"; position: absolute; left: 0; color: var(--text-3); }

/* ——— UTILS ——— */

.text-muted { color: var(--text-3); }
.text-sm    { font-size: 13px; }
.mt-1       { margin-top: 0.5rem; }
.mt-2       { margin-top: 1rem; }
.flex       { display: flex; }
.items-center { align-items: center; }
.gap-2      { gap: 0.5rem; }
.w-full     { width: 100%; }

/* iOS safe area */
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
