/* ═══════════════════════════════════════════════════════
   notes.css — Notes tab, tasks panel, note cards
   ═══════════════════════════════════════════════════════ */

.notes-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; padding: 20px; height: calc(100vh - 98px); overflow: hidden; flex: 1; }

/* Sidebar */
.notes-sidebar { border-right: 1px solid var(--border); padding-right: 20px; overflow-y: auto; }
.notes-sidebar h3 { font-size: 14px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 12px 0; }
.category-list { display: flex; flex-direction: column; gap: 4px; }
.category-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: all 0.15s; }
.category-item:hover { background: var(--bg-hover); }
.category-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.category-icon { font-size: 16px; }
.category-name { flex: 1; font-size: 13px; }
.category-count { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }

/* Main */
.notes-main { overflow-y: auto; padding-right: 8px; }
.notes-toolbar { display: flex; gap: 12px; margin-bottom: 16px; padding: 0 16px; }
.notes-toolbar input { flex: 1; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 14px; }
.notes-toolbar input:focus { outline: none; border-color: var(--accent); }
.notes-toolbar select { padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 13px; cursor: pointer; }

/* Tag Cloud */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; padding: 0 16px; }
.cloud-tag { padding: 4px 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; font-size: 12px; color: var(--text-dim); cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.cloud-tag:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text); }
.cloud-tag.active { background: var(--accent); border-color: var(--accent); color: white; }
.cloud-tag.freq-high { font-size: 14px; font-weight: 700; }
.cloud-tag.freq-medium { font-size: 13px; font-weight: 600; }
.cloud-tag.freq-low { font-size: 11px; }
.tag-count { opacity: 0.7; font-size: 0.9em; }

/* Notes Grid — CSS Grid (row-first order, newest left→right) */
.notes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 0 16px; align-items: start; }
.notes-pinned-section { grid-column: 1 / -1; }
.notes-pinned-header { font-size: 15px; font-weight: 600; color: var(--text-dim); margin-bottom: 12px; }
.notes-pinned-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.note-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer; position: relative; z-index: 1; }
.note-card:hover:not(.focused) { box-shadow: 0 4px 16px rgba(0,0,0,0.15); transform: translateY(-2px); border-color: var(--accent); }
.note-card.focused { position: fixed; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) scale(1.2); z-index: 10002; max-width: 700px; width: 90vw; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.4); border-color: var(--accent); cursor: default; }
.note-card.dimmed { opacity: 0.3; filter: blur(2px); pointer-events: none; }
.note-focus-backdrop { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0); backdrop-filter: blur(0px); z-index: 10001; opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.note-focus-backdrop.active { background: rgba(0,0,0,0.3); backdrop-filter: blur(4px); opacity: 1; pointer-events: all; cursor: pointer; }

.note-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 8px; line-height: 1.4; }
.note-preview { font-size: 13px; color: var(--text-dim); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; margin: 8px 0 12px; transition: all 0.3s ease; }
.note-preview.full-text { display: block; -webkit-line-clamp: unset; overflow-y: auto; max-height: 50vh; padding-right: 8px; color: var(--text); font-size: 14px; line-height: 1.7; }
.note-meta { margin-bottom: 8px; }
.note-category { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; }
.cat-business { background: #E3F2FD; color: #1565C0; }
.cat-ideas { background: #FFF3E0; color: #E65100; }
.cat-tech { background: #E8F5E9; color: #2E7D32; }
.cat-personal { background: #F3E5F5; color: #7B1FA2; }
.cat-fitness { background: #FFF8E1; color: #F57F17; }
.cat-bugs { background: #FFEBEE; color: #C62828; }
.cat-tasks { background: #E0F2F1; color: #00695C; }
.cat-uncategorized { background: #F5F5F5; color: #616161; }
.note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.note-tag { padding: 2px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 10px; color: var(--text-muted); }
.note-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); }
.note-source, .note-date { font-family: var(--mono); }

/* Note Detail Modal */
.note-detail { padding: 8px 0; }
.note-detail-meta { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.note-detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.note-detail-text { font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; }

/* Pagination */
#notes-pagination { display: flex; justify-content: space-between; align-items: center; padding: 20px 16px; margin-top: 20px; border-top: 1px solid var(--border); }
#notes-pagination .pagination-controls { display: flex; gap: 12px; align-items: center; }
#notes-pagination button { padding: 6px 14px; background: var(--accent-dim); border: 1px solid var(--accent); border-radius: 6px; color: var(--text); font-size: 13px; cursor: pointer; transition: all 0.15s; }
#notes-pagination button:hover:not(:disabled) { background: var(--accent); color: white; }
#notes-pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Sub-tabs */
.notes-subtab-bar { display: flex; gap: 4px; padding: 12px 20px 0; border-bottom: 1px solid var(--border); background: var(--bg); flex-shrink: 0; }
.notes-subtab { padding: 8px 18px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: transparent; color: var(--text-dim); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; position: relative; bottom: -1px; }
.notes-subtab:hover { color: var(--text); background: var(--bg-hover); }
.notes-subtab.active { background: var(--bg-card); color: var(--accent); border-color: var(--border); border-bottom-color: var(--bg-card); font-weight: 600; }

/* Tasks Panel */
.notes-tasks-panel { display: flex; flex-direction: column; height: calc(100vh - 100px); overflow: hidden; }
.notes-tasks-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--bg); flex-shrink: 0; }
.notes-tasks-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.notes-tasks-filters select { padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-card); color: var(--text); font-size: 13px; cursor: pointer; }
.nt-toggle-wrap { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); cursor: pointer; user-select: none; }
.notes-tasks-actions { display: flex; gap: 8px; flex-shrink: 0; }
#notes-tasks-grid { flex: 1; overflow-y: auto; padding: 20px; columns: 3 280px; column-gap: 16px; }

/* Task card */
.note-card.task-card { break-inside: avoid; cursor: pointer; }
.task-status-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; margin-bottom: 6px; }
.task-status-badge.status-todo    { background: #e3f2fd; color: #1565c0; }
.task-status-badge.status-doing   { background: #fff8e1; color: #f57f17; }
.task-status-badge.status-done    { background: #e8f5e9; color: #2e7d32; }
.task-status-badge.status-blocked { background: #fce4ec; color: #b71c1c; }
.task-priority-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; margin-left: 4px; }
.task-priority-badge.priority-critical { background: #fce4ec; color: #c62828; }
.task-priority-badge.priority-high     { background: #fff3e0; color: #e65100; }
.task-priority-badge.priority-medium   { background: #e8f5e9; color: #2e7d32; }
.task-priority-badge.priority-low      { background: #f5f5f5; color: #616161; }
.task-project-label { font-size: 11px; color: var(--text-muted); font-family: var(--mono); background: var(--bg); padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border); }
.task-due-date { font-size: 11px; color: var(--text-muted); }
.task-due-date.overdue { color: var(--red); font-weight: 600; }

/* Form / Edit Modal */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.3px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-card); color: var(--text); font-size: 13px; font-family: var(--sans); width: 100%; }
.form-input:focus { outline: none; border-color: var(--accent); }
textarea.form-input { resize: vertical; min-height: 70px; line-height: 1.5; }
.modal-footer { display: flex; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); }
.btn-danger { padding: 8px 16px; background: var(--red); color: #fff; border: none; border-radius: 4px; font-size: 13px; cursor: pointer; font-weight: 500; }
.btn-danger:hover { background: #b71c1c; }

/* Responsive */
@media (max-width: 1024px) { .notes-grid { grid-template-columns: repeat(2, 1fr); } .notes-pinned-grid { grid-template-columns: repeat(2, 1fr); } .notes-layout { grid-template-columns: 180px 1fr; } }
@media (max-width: 767px) {
  #tab-notes { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .notes-layout { grid-template-columns: 1fr; padding: 12px; gap: 8px; height: auto; overflow: visible; }
  .notes-sidebar { border-right: none; padding-right: 0; padding-bottom: 0; margin-bottom: 0; max-height: none; overflow: visible; }
  .notes-sidebar h3 { display: none; }
  .notes-grid { grid-template-columns: 1fr; }
  .notes-pinned-grid { grid-template-columns: 1fr; }
  .notes-toolbar { flex-direction: column; padding: 0; }
  .tag-cloud { padding: 0; }
  .notes-main { padding-right: 0; overflow: visible; }
}