/* === RECHERCHE === */

.notes-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: var(--space-4);
}

.notes-search-icon {
  position: absolute;
  left: var(--space-4);
  color: var(--text-muted);
  pointer-events: none;
}

.notes-search-input {
  width: 100%;
  padding: var(--space-3) var(--space-10) var(--space-3) calc(var(--space-4) + 24px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.notes-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

.notes-search-clear {
  position: absolute;
  right: var(--space-3);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.notes-search-clear:hover { background: var(--border); color: var(--text-primary); }

/* === FILTRES TAGS === */

.notes-tag-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  min-height: 0;
}

.notes-tag-filters:empty { margin-bottom: 0; }

.notes-tag-chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.notes-tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.notes-tag-chip.active { background: var(--accent); border-color: var(--accent); color: white; }

/* === GRILLE === */

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 480px) {
  .notes-grid { grid-template-columns: 1fr; }
}

/* === CARTE DE NOTE === */

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-align: left;
  width: 100%;
}

.note-card:hover {
  border-color: rgba(16, 185, 129, 0.45);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.note-card:active { transform: translateY(0); }

.note-card.pinned {
  border-color: rgba(16, 185, 129, 0.3);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(16, 185, 129, 0.04) 100%);
}

.note-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.note-card-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  flex-shrink: 0;
}

.note-card-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.note-pin-badge { font-size: 13px; line-height: 1; }

.note-card-excerpt {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

.note-card-tags {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-top: auto;
}

.note-card-tag {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  white-space: nowrap;
}

/* === ÉDITEUR === */

.note-editor-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: min(860px, 95vw);
  min-height: 420px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
  .note-editor-card {
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 95dvh;
    margin-top: auto;
  }

  /* Ancrer la modale en bas sur mobile */
  #note-editor-modal.modal-overlay {
    align-items: flex-end;
  }
}

.note-editor-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.note-editor-title-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  min-width: 0;
}

.note-editor-title-input::placeholder { color: var(--text-muted); font-weight: 400; }

.note-editor-tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.note-editor-tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
  cursor: pointer;
  background: transparent;
}

.note-editor-tab:hover { color: var(--text-primary); }
.note-editor-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.note-editor-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.note-editor-textarea {
  flex: 1;
  width: 100%;
  padding: var(--space-4);
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.75;
  color: var(--text-primary);
  resize: none;
  min-height: 260px;
}

.note-editor-textarea::placeholder { color: var(--text-muted); font-family: var(--font-sans); font-size: var(--text-sm); }

.note-editor-preview {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  min-height: 260px;
}

/* Styles du contenu markdown */
.note-editor-preview h1,
.note-editor-preview h2,
.note-editor-preview h3 {
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--space-5) 0 var(--space-2);
}

.note-editor-preview h1:first-child,
.note-editor-preview h2:first-child,
.note-editor-preview h3:first-child { margin-top: 0; }

.note-editor-preview h1 { font-size: var(--text-2xl); }
.note-editor-preview h2 { font-size: var(--text-xl); }
.note-editor-preview h3 { font-size: var(--text-lg); }

.note-editor-preview p {
  margin-bottom: var(--space-3);
  line-height: 1.7;
  color: var(--text-primary);
}

.note-editor-preview strong { font-weight: 700; }
.note-editor-preview em     { font-style: italic; }
.note-editor-preview del    { text-decoration: line-through; color: var(--text-muted); }

.note-editor-preview code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--bg-primary);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  color: var(--accent-light);
}

.note-editor-preview pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  margin: var(--space-3) 0;
}

.note-editor-preview pre code {
  background: none;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.note-editor-preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-4);
  margin: var(--space-3) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.note-editor-preview ul,
.note-editor-preview ol {
  padding-left: var(--space-6);
  margin: var(--space-3) 0;
}

.note-editor-preview li { margin-bottom: var(--space-1); line-height: 1.6; }

.note-editor-preview hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-5) 0;
}

.note-editor-preview a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Footer */
.note-editor-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.note-editor-tags-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.note-editor-tags-row label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 36px;
}

.note-editor-tags-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition-fast);
}

.note-editor-tags-input:focus {
  outline: none;
  border-color: var(--accent);
}

.note-editor-tags-input::placeholder { color: var(--text-muted); }

.note-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.note-pin-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  background: transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}

.note-pin-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Danger zone éditeur */
#note-editor-danger-actions { display: flex; gap: var(--space-3); }

.note-pin-btn.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}
