/* notes.css */

/* ============================================
   GRUPOS
   ============================================ */
.groups-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.group-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.06);
  padding: 5px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
}

.group-btn span.group-name {
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-btn.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.group-delete {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.8em;
  opacity: 0.7;
  padding: 0 0 0 2px;
}

.group-delete:hover {
  opacity: 1;
}

.add-group-btn {
  border-radius: 999px;
  border: none;
  background: var(--primary);
  color: #fff;
  width: 30px;
  height: 30px;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
  transition: transform 0.1s, box-shadow 0.2s, background 0.2s;
}

.add-group-btn:hover {
  transform: translateY(-1px);
  background: var(--primary-dark);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.5);
}

/* ============================================
   BUSCA
   ============================================ */
.section-header.with-search {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.search-wrapper {
  flex: 1;
}

#searchInput {
  width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 0.9rem;
  color: var(--text);
}

#searchInput::placeholder {
  color: var(--text-muted);
}

/* ============================================
   LISTA DE NOTAS
   ============================================ */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Aumentado para mostrar mais cards */
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Scrollbar discreta */
.notes-list::-webkit-scrollbar {
  width: 4px;
}
.notes-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 999px;
}

.empty-state {
  text-align: center;
  padding: 30px 14px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.empty-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 1rem;
}

/* ============================================
   CARTÃO DE NOTA — maior e mais legível
   ============================================ */
.note-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  /* Padding aumentado para dar mais respiro */
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.02);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.15s, border-color 0.2s, transform 0.1s;
}

body.dark .note-card {
  background: rgba(255, 255, 255, 0.03);
}

.note-card:hover {
  background: rgba(148, 163, 184, 0.06);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
  border-color: rgba(148, 163, 184, 0.7);
  transform: translateY(-2px);
}

/* Título do card */
.note-card-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 1.05rem;
  color: var(--text);
  /* Título em até 2 linhas */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   SNIPPET — preview com ~5 linhas
   ============================================ */
.note-card-snippet {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
  /* ~5 linhas: line-height 1.55 × 5 = 7.75em */
  max-height: 7.75em;
  overflow: hidden;
  /* Respeita \n inseridos pelo JS (bullets de checklist) */
  white-space: pre-line;
  word-break: break-word;
}

/* Meta (grupo + data) */
.note-card-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  gap: 8px;
  flex-wrap: wrap;
}

/* Ações (editar / excluir) */
.note-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.note-action-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  padding: 5px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.note-action-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* ============================================
   EDITOR — título
   ============================================ */
.note-title-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
  margin-bottom: 10px;
  background: transparent;
  color: var(--text);
}

.note-title-input::placeholder {
  color: var(--text-muted);
}

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.toolbar button {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.08);
  padding: 5px 10px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.toolbar button:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

.toolbar select {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 5px 8px;
  font-size: 0.85rem;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
}

/* ============================================
   ÁREA RICH TEXT
   ============================================ */
.note-content-input {
  min-height: 160px;
  max-height: 300px;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  background: transparent;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

.note-content-input:focus {
  outline: 2px solid rgba(99, 102, 241, 0.2);
}

.note-content-input[placeholder]:empty::before {
  content: attr(placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================
   EDITOR — ações
   ============================================ */
.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* ============================================
   CHECKLIST
   ============================================ */
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  -webkit-user-modify: read-only;
}

.check-box {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  position: relative;
  z-index: 1;
  padding: 0;
}

.check-box.is-checked {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.check-box:hover {
  border-color: var(--primary);
}

.check-text {
  flex: 1;
  min-width: 0;
  outline: none;
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  cursor: text;
  -webkit-user-modify: read-write;
}

.check-text.is-done {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.65;
}

/* ============================================
   RESPONSIVO MOBILE
   ============================================ */
@media (max-width: 600px) {
  /* Botões de ação maiores no mobile */
  .note-action-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
  }

  .note-card {
    padding: 14px 14px;
  }

  /* No mobile mostra ~4 linhas de preview */
  .note-card-snippet {
    max-height: 6.2em;
  }

  .note-card-title {
    font-size: 1rem;
  }

  .notes-list {
    max-height: 420px;
  }
}