/* =============================================
   NoteVault — Premium Notepad Stylesheet
   Dark-first, glassmorphism design system
   ============================================= */

/* ── Tokens ──────────────────────────────── */
:root {
  --bg:          #0d0d14;
  --bg2:         #13131f;
  --bg3:         #1a1a2e;
  --surface:     #1e1e32;
  --surface2:    #252540;
  --border:      rgba(255,255,255,0.07);
  --border2:     rgba(255,255,255,0.12);
  --text:        #e2e2f0;
  --text2:       #9090b0;
  --text3:       #5a5a7a;
  --accent:      #7c3aed;
  --accent2:     #a855f7;
  --accent-glow: rgba(124,58,237,0.35);
  --green:       #10b981;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 8px 32px rgba(0,0,0,0.5);
  --sidebar-w:   260px;
  --panel-w:     320px;
  --trans:       all 0.22s cubic-bezier(0.4,0,0.2,1);
}

.light-mode {
  --bg:       #f0f0f7;
  --bg2:      #e8e8f3;
  --bg3:      #dcdcee;
  --surface:  #ffffff;
  --surface2: #f5f5fc;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.15);
  --text:     #1a1a2e;
  --text2:    #555570;
  --text3:    #9090aa;
  --shadow:   0 4px 24px rgba(0,0,0,0.12);
}

/* ── Reset ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; color: var(--text); }
a { text-decoration: none; color: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Layout ─────────────────────────────── */
.main-layout {
  display: flex;
  height: 100vh;
  margin-left: var(--sidebar-w);
  transition: margin-left 0.3s;
}
.main-layout.sidebar-hidden { margin-left: 0; }

/* ── Sidebar ─────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.sidebar.hidden { transform: translateX(-100%); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 0.5rem; }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.3px; background: linear-gradient(135deg, var(--accent2), #60a5fa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-close { background: none; border: none; color: var(--text2); font-size: 1rem; padding: 4px 8px; border-radius: 6px; display: none; }
.sidebar-close:hover { background: var(--surface); color: var(--text); }

.btn-new-note {
  margin: 1rem;
  padding: 0.65rem 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: var(--trans);
}
.btn-new-note:hover { transform: translateY(-1px); box-shadow: 0 6px 22px var(--accent-glow); }
.btn-new-note:active { transform: translateY(0); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 0.5rem 1rem; }
.nav-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text3); padding: 0.75rem 0.5rem 0.3rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 0.88rem;
  transition: var(--trans);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--accent2); font-weight: 500; }
.nav-item .nav-icon { font-size: 1rem; }
.nav-badge { margin-left: auto; background: var(--surface2); color: var(--text2); font-size: 0.7rem; font-weight: 600; padding: 1px 6px; border-radius: 20px; min-width: 20px; text-align: center; }
.nav-item.active .nav-badge { background: var(--accent-glow); color: var(--accent2); }

.cat-nav-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.75rem; border-radius: var(--radius-sm); color: var(--text2); font-size: 0.85rem; transition: var(--trans); margin-bottom: 2px; cursor: pointer; }
.cat-nav-item:hover { background: var(--surface); color: var(--text); }
.cat-nav-item.active { background: var(--surface2); font-weight: 500; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.stats-box { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; padding: 0 0.25rem; }
.stat-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.5rem; text-align: center; }
.stat-val { display: block; font-size: 1.2rem; font-weight: 700; color: var(--accent2); }
.stat-lbl { font-size: 0.7rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); }
.btn-theme { width: 100%; padding: 0.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text2); font-size: 0.82rem; transition: var(--trans); }
.btn-theme:hover { background: var(--surface2); color: var(--text); }

/* ── Notes Panel ─────────────────────────── */
.notes-panel {
  width: var(--panel-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg3);
  height: 100vh;
  overflow: hidden;
}
.panel-header { padding: 1rem; display: flex; align-items: center; gap: 0.5rem; border-bottom: 1px solid var(--border); }
.btn-menu { background: none; border: none; color: var(--text2); font-size: 1.2rem; padding: 4px 6px; border-radius: 6px; transition: var(--trans); }
.btn-menu:hover { background: var(--surface); color: var(--text); }

.search-wrap { flex: 1; position: relative; }
.search-icon { position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%); font-size: 0.85rem; pointer-events: none; }
.search-input { width: 100%; padding: 0.5rem 0.5rem 0.5rem 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 0.82rem; outline: none; transition: var(--trans); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-clear { position: absolute; right: 0.4rem; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text3); font-size: 0.75rem; padding: 2px 5px; border-radius: 4px; }
.search-clear:hover { color: var(--text); background: var(--surface2); }

.sort-select { padding: 0.4rem 0.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text2); font-size: 0.78rem; outline: none; cursor: pointer; }
.sort-select option { background: var(--bg2); }

.panel-title-row { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem 0.4rem; }
.panel-title { font-size: 0.95rem; font-weight: 600; }
.panel-count { font-size: 0.75rem; color: var(--text3); }

.notes-list { flex: 1; overflow-y: auto; padding: 0.5rem; }

/* Note Card */
.note-card {
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: var(--trans);
  position: relative;
  overflow: hidden;
}
.note-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--card-color, var(--accent)); border-radius: 3px 0 0 3px; }
.note-card:hover { border-color: var(--border2); transform: translateX(2px); box-shadow: var(--shadow); }
.note-card.active { border-color: var(--accent); background: var(--surface2); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.note-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.note-card-title { font-size: 0.88rem; font-weight: 600; line-height: 1.3; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-badges { display: flex; gap: 3px; flex-shrink: 0; }
.badge { font-size: 0.7rem; opacity: 0.9; }
.note-card-preview { font-size: 0.78rem; color: var(--text2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 0.4rem; }
.note-card-footer { display: flex; align-items: center; justify-content: space-between; }
.note-card-cat { font-size: 0.68rem; padding: 1px 6px; border-radius: 20px; background: var(--surface2); color: var(--text2); }
.note-card-meta { font-size: 0.68rem; color: var(--text3); }

/* Loading & Empty states */
.loading-state, .empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; padding: 3rem 1rem; color: var(--text3); text-align: center; }
.spinner { width: 28px; height: 28px; border: 2px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state .empty-icon { font-size: 2.5rem; }

/* ── Editor Panel ─────────────────────────── */
.editor-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg); min-width: 0; height: 100vh; overflow: hidden; }

.editor-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; color: var(--text3); text-align: center; padding: 2rem; }
.placeholder-icon { font-size: 3.5rem; opacity: 0.6; }
.editor-placeholder h3 { font-size: 1.1rem; color: var(--text2); }
.editor-placeholder p { font-size: 0.85rem; }

.editor-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; flex-wrap: wrap; gap: 0.5rem; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 0.4rem; }

.btn-icon { background: none; border: none; font-size: 1rem; padding: 5px 7px; border-radius: 6px; color: var(--text2); transition: var(--trans); }
.btn-icon:hover { background: var(--surface); color: var(--text); }
.btn-icon.active { color: var(--amber); }
.btn-icon.pinned { color: var(--accent2); }
.btn-icon.danger:hover { background: rgba(239,68,68,0.15); color: var(--red); }

.category-select { padding: 0.35rem 0.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text2); font-size: 0.78rem; outline: none; cursor: pointer; }
.category-select option { background: var(--bg2); }
.category-select:focus { border-color: var(--accent); }

.color-btn { font-size: 1rem; cursor: pointer; padding: 4px 6px; border-radius: 6px; display: inline-flex; align-items: center; }
.color-btn:hover { background: var(--surface); }
#noteColor { width: 0; height: 0; opacity: 0; position: absolute; }

.word-count { font-size: 0.75rem; color: var(--text3); padding: 0 0.5rem; }
.btn-save { padding: 0.4rem 1rem; background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; border-radius: 6px; color: #fff; font-size: 0.82rem; font-weight: 600; transition: var(--trans); box-shadow: 0 2px 8px var(--accent-glow); }
.btn-save:hover { transform: translateY(-1px); box-shadow: 0 4px 14px var(--accent-glow); }
.btn-save:active { transform: translateY(0); }

.note-title-input {
  width: 100%; padding: 1rem 1.25rem 0.5rem;
  background: transparent; border: none; outline: none;
  font-size: 1.4rem; font-weight: 700; color: var(--text);
  line-height: 1.3;
}
.note-title-input::placeholder { color: var(--text3); }

.note-content-area {
  flex: 1; width: 100%; padding: 0.5rem 1.25rem 1rem;
  background: transparent; border: none; outline: none;
  font-size: 0.92rem; color: var(--text); line-height: 1.8;
  resize: none; min-height: 0;
}
.note-content-area::placeholder { color: var(--text3); }

.editor-content { display: flex; flex-direction: column; height: 100%; }

.editor-footer { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg2); font-size: 0.72rem; color: var(--text3); flex-shrink: 0; }
.save-status { color: var(--green); font-weight: 500; transition: opacity 0.5s; }

/* ── Buttons ─────────────────────────────── */
.btn-primary { padding: 0.55rem 1.25rem; background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; border-radius: var(--radius-sm); color: #fff; font-size: 0.85rem; font-weight: 600; transition: var(--trans); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px var(--accent-glow); }
.btn-secondary { padding: 0.5rem 1rem; background: var(--surface2); border: 1px solid var(--border2); border-radius: 8px; color: var(--text); font-size: 0.85rem; transition: var(--trans); }
.btn-secondary:hover { background: var(--bg3); }
.btn-danger { padding: 0.5rem 1rem; background: var(--red); border: none; border-radius: 8px; color: #fff; font-size: 0.85rem; font-weight: 600; transition: var(--trans); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

/* ── Modal ───────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(6px); z-index: 500; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 2rem; text-align: center; max-width: 360px; width: 90%; box-shadow: var(--shadow); animation: slideUp 0.22s ease; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.modal h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.modal p { color: var(--text2); font-size: 0.85rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ── Toast ───────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999;
  padding: 0.7rem 1.2rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 500;
  background: var(--bg2); border: 1px solid var(--border2);
  box-shadow: var(--shadow); color: var(--text);
  transform: translateY(20px); opacity: 0;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }

/* ── Sidebar overlay (mobile) ─────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 199; }
.sidebar-overlay.show { display: block; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 900px) {
  .main-layout { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .notes-panel { width: 100%; border-right: none; }
  .editor-panel { display: none; position: fixed; inset: 0; z-index: 100; }
  .editor-panel.open { display: flex; }
}
@media (max-width: 600px) {
  .editor-toolbar { padding: 0.5rem 0.75rem; }
  .note-title-input { font-size: 1.1rem; padding: 0.75rem 0.75rem 0.5rem; }
  .note-content-area { padding: 0.5rem 0.75rem 1rem; }
  .toolbar-right .word-count { display: none; }
}
