/* NyoraNotes — Styles complémentaires aux thèmes */

/* ─── Variables typographie utilisateur ──────────────────────────────────── */
:root {
  --reading-font-size: 16px;
  --reading-max-width: 70ch;
}

/* Layout global */
html, body { height: 100%; margin: 0; }

/* Sidebar */
.sidebar {
  width: 240px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--bg-primary);
  flex-shrink: 0;
  font-family: var(--font-headings, var(--font-serif));
}

.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-section {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border-primary);
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

/* Formulaire de recherche dans la sidebar */
.search-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.625rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  box-sizing: border-box;
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 20%, transparent);
}

.search-input::placeholder { color: var(--text-tertiary); }

/* Bouton nouvelle note */
.btn-new {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: var(--accent-primary);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  text-decoration: none;
  justify-content: center;
  transition: background var(--transition-base);
}

.btn-new:hover { background: var(--accent-hover); }

/* Tags dans la sidebar */
.tag-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base);
}

.tag-link:hover, .tag-link.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.tag-count {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-size: 0.7rem;
  padding: 0 0.35rem;
  border-radius: 99px;
  min-width: 1.25rem;
  text-align: center;
}

/* Sélecteur de thème */
.theme-select {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  box-sizing: border-box;
}

/* Zone principale — liste des notes */
.note-list-panel {
  width: 320px;
  min-width: 280px;
  border-right: 1px solid var(--border-primary);
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-primary);
}

.note-list-panel-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.note-list-panel-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.note-card {
  display: block;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-base);
}

.note-card:hover { background: var(--bg-secondary); }
.note-card.active { background: var(--bg-tertiary); }

.note-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-card-meta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 0.375rem;
}

.note-card-excerpt {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-pill {
  display: inline-block;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 99px;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  margin: 0.15rem 0.1rem 0 0;
}

/* Zone de contenu de la note */
.note-content-panel {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-primary);
}

.note-header {
  padding: 2rem 2.5rem 1rem;
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.note-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-headings, var(--font-sans));
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.note-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  text-decoration: none;
  border: none;
  transition: background var(--transition-base), color var(--transition-base);
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
}
.btn-secondary:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-danger {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  color: #ef4444;
}
.btn-danger:hover { background: #fef2f2; border-color: #ef4444; }

/* Contenu de la note (rendu Markdown) */
.note-body {
  padding: 2rem 2.5rem;
}

.note-content {
  max-width: var(--reading-max-width);
  font-size: var(--reading-font-size);
  line-height: 1.7;
  color: var(--text-primary);
  font-family: var(--font-content, var(--font-sans));
  transition: font-size 150ms ease, max-width 150ms ease;
}

.note-content h1 { font-size: 1.6rem; margin: 2rem 0 0.75rem; }
.note-content h2 { font-size: 1.3rem; margin: 1.75rem 0 0.625rem; }
.note-content h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.note-content h1, .note-content h2, .note-content h3 {
  font-family: var(--font-headings, var(--font-sans));
  color: var(--text-primary);
  font-weight: 700;
}
.note-content p { margin: 0 0 1rem; }
.note-content ul, .note-content ol { padding-left: 1.5rem; margin: 0 0 1rem; }
.note-content li { margin-bottom: 0.25rem; }
.note-content a { color: var(--text-link); text-decoration: underline; text-underline-offset: 3px; }
.note-content code {
  background: var(--bg-code);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.note-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow-x: auto;
  margin: 0 0 1rem;
}
.note-content pre code { background: none; padding: 0; }
.note-content blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: 1rem;
  margin: 0 0 1rem;
  color: var(--text-secondary);
  font-style: italic;
}
.note-content hr {
  border: none;
  border-top: 1px solid var(--border-primary);
  margin: 2rem 0;
}
.note-content table { border-collapse: collapse; width: 100%; margin: 0 0 1rem; }
.note-content th, .note-content td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-primary);
  text-align: left;
}
.note-content th { background: var(--bg-secondary); font-weight: 600; }

/* Backlinks */
.backlinks-section {
  padding: 1rem 2.5rem 2rem;
  border-top: 1px solid var(--border-primary);
  margin-top: 2rem;
}

.backlinks-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 0.75rem;
}

.backlink-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  color: var(--text-link);
  text-decoration: none;
}
.backlink-item:hover { color: var(--accent-hover); }

/* Formulaire d'édition inline */
.edit-form {
  padding: 1.5rem 2.5rem;
  max-width: 800px;
}

.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input, .form-textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.875rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  box-sizing: border-box;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 20%, transparent);
}

.form-textarea {
  min-height: 400px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
}

/* État vide */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  text-align: center;
  padding: 2rem;
  color: var(--text-tertiary);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state-text { font-size: 1rem; margin-bottom: 0.5rem; color: var(--text-secondary); }
.empty-state-hint { font-size: 0.85rem; }

/* Indicateur de chargement HTMX */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Page de login */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}

.login-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--accent-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--bg-primary);
  margin: 0 auto 1.5rem;
  font-family: var(--font-serif);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-family: var(--font-headings, var(--font-sans));
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
}

.error-msg {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
  text-align: left;
}

/* Résultats de recherche */
.search-mark mark {
  background: color-mix(in srgb, var(--accent-primary) 25%, transparent);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 0 1px;
}

/* File path breadcrumb */
.file-path {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-top: 0.25rem;
}

/* ─── Bouton typographie dans la sidebar ─────────────────────────────────── */

.typo-toggle-btn {
  position: relative;
}

.typo-toggle-btn.has-custom::after {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 5px;
  height: 5px;
  background: var(--accent-primary);
  border-radius: 50%;
  pointer-events: none;
}

/* ─── Panneau typographie (popover) ──────────────────────────────────────── */

.typo-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
}

.typo-popover {
  position: fixed;
  z-index: 301;
  width: 268px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1rem;
}

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

.typo-header-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.typo-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--transition-base);
}
.typo-close-btn:hover { color: var(--text-primary); }

.typo-group { margin-bottom: 0.875rem; }

.typo-group-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.typo-pills-row {
  display: flex;
  gap: 0.375rem;
}

.typo-pill {
  flex: 1;
  padding: 0.3rem 0;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.typo-pill:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.typo-pill.active {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
  font-weight: 600;
}

.typo-reset-btn {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.35rem;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  background: none;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color var(--transition-base), border-color var(--transition-base);
}
.typo-reset-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

/* Scrollbar subtile */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-secondary); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ─── Toggle sidebars ─────────────────────────────────────────────── */

/* Wrapper : position:relative pour le bouton absolu,
   overflow:visible (défaut) pour que le bouton dépasse sans être coupé */
.sidebar-wrapper {
  position: relative;
  flex-shrink: 0;
}

/* Quand un panneau est masqué, le wrapper réserve 28px pour son bouton.
   Cela évite que les 2 wrappers à width:0 ne se superposent. */
.sidebar-wrapper.collapsed {
  min-width: 28px;
}

/* Transitions sur les 2 panneaux (état ouvert) */
.sidebar,
.note-list-panel {
  transition: width 150ms ease, min-width 150ms ease;
}

/* Désactivé au chargement initial pour éviter l'animation de restauration */
.no-transition {
  transition: none !important;
}

/* État masqué */
.sidebar.collapsed,
.note-list-panel.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  border-right: none;
}

/* ─── Bouton toggle ─────────────────────────────────────────────── */

.sidebar-toggle-btn {
  position: absolute;
  right: -14px;        /* centré sur le bord droit du wrapper (28px / 2) */
  top: 50%;
  transform: translateY(-50%);
  z-index: 200;

  width: 28px;
  height: 72px;
  padding: 0;

  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;

  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: background 150ms, color 150ms;
}

/* Zone de hover légèrement élargie via padding sans changer le layout */
.sidebar-toggle-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding-right: 4px;  /* léger débordement visuel côté contenu */
}

.sidebar-toggle-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Icônes SVG : chevron gauche = "fermer" (aria-expanded=true)
                chevron droit  = "ouvrir" (aria-expanded=false) */
.sidebar-toggle-btn[aria-expanded="true"]  .toggle-icon-open  { display: none; }
.sidebar-toggle-btn[aria-expanded="true"]  .toggle-icon-close { display: flex; }
.sidebar-toggle-btn[aria-expanded="false"] .toggle-icon-open  { display: flex; }
.sidebar-toggle-btn[aria-expanded="false"] .toggle-icon-close { display: none; }
