/* ============================================================
   Notes — Main Stylesheet
   Warm, modern, personal home-office aesthetic
   ============================================================ */

/* ── Design tokens ──────────────────────────────────────────── */
:root {
  /* Palette */
  --bg:             #F7F5F2;   /* warm off-white page bg */
  --surface:        #FFFFFF;   /* cards, panels */
  --surface-2:      #F0EDE8;   /* sidebar, subtle inputs */
  --primary:        #4A6FA5;   /* main accent — slate blue */
  --primary-h:      #3A5A8C;   /* hover */
  --primary-lt:     #E8EFF8;   /* light tint (selected bg, tags) */
  --success:        #5C7A6E;   /* sage green */
  --danger:         #B94040;
  --warning:        #C97D2B;

  /* Text */
  --text:           #2C2C2C;
  --text-2:         #6B7280;   /* secondary */
  --text-3:         #A0A8B2;   /* placeholder */
  --text-inv:       #FFFFFF;   /* on dark bg */

  /* Borders & shadows */
  --border:         #E4E1DC;
  --border-focus:   var(--primary);
  --shadow-sm:      0 1px 3px rgba(0,0,0,.07);
  --shadow:         0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.12);

  /* Radii */
  --r-sm:   6px;
  --r:      10px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-pill: 999px;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font:      system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

  /* Transitions */
  --t: 180ms ease;
  --t-slow: 300ms ease;

  /* Sidebar width */
  --sidebar-w: 260px;
}

/* ── Reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

h1,h2,h3,h4 { line-height: 1.2; font-weight: 600; }

/* ── Splash screen ───────────────────────────────────────────── */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  gap: var(--sp-3);
  animation: fadeIn .3s ease;
}
.splash__icon { font-size: 3rem; }
.splash__name { font-size: 1.5rem; font-weight: 700; color: var(--text-2); letter-spacing: -.02em; }

/* ── Auth screen ─────────────────────────────────────────────── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--sp-6);
  animation: fadeIn .25s ease;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-10) var(--sp-8);
  width: 100%;
  max-width: 420px;
}

.auth-card__header {
  text-align: center;
  margin-bottom: var(--sp-8);
}
.auth-card__icon  { font-size: 2.5rem; margin-bottom: var(--sp-2); }
.auth-card__title { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.auth-card__sub   { color: var(--text-2); font-size: .9rem; margin-top: var(--sp-1); }

/* Tabs (Login / Create Account) */
.auth-tabs {
  display: flex;
  border-radius: var(--r);
  background: var(--surface-2);
  padding: 3px;
  margin-bottom: var(--sp-6);
}
.auth-tab {
  flex: 1;
  padding: var(--sp-2) var(--sp-4);
  border: none;
  background: transparent;
  border-radius: calc(var(--r) - 2px);
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t);
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-group        { margin-bottom: var(--sp-4); }
.form-group label  { display: block; font-size: .875rem; font-weight: 500; margin-bottom: var(--sp-1); color: var(--text-2); }

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: .975rem;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(74,111,165,.15);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-3); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: .65rem 1.25rem;
  border-radius: var(--r);
  border: none;
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: var(--text-inv); }
.btn-primary:hover:not(:disabled)  { background: var(--primary-h); }

.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-ghost     { background: transparent; color: var(--primary); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-lt); }

.btn-danger    { background: var(--danger); color: var(--text-inv); }
.btn-danger:hover:not(:disabled) { opacity: .85; }

.btn-full      { width: 100%; justify-content: center; }
.btn-lg        { padding: .8rem 1.5rem; font-size: 1rem; }
.btn-sm        { padding: .4rem .8rem; font-size: .85rem; border-radius: var(--r-sm); }
.btn-icon      { padding: .5rem; border-radius: var(--r-sm); }

/* ── Error / success alerts ──────────────────────────────────── */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  font-size: .9rem;
  margin-bottom: var(--sp-4);
  display: none;
}
.alert.show      { display: block; }
.alert-error     { background: #FDE8E8; color: var(--danger); border: 1px solid #F5C6C6; }
.alert-success   { background: #E6F4F0; color: var(--success); border: 1px solid #B8DDD6; }

/* ── App shell ───────────────────────────────────────────────── */
#app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  animation: fadeIn .2s ease;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--t-slow);
}

.sidebar__top {
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.sidebar__brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.02em;
  flex: 1;
}

.sidebar__new-btn {
  width: 100%;
  margin: var(--sp-4);
  width: calc(100% - var(--sp-8));
}

.sidebar__search {
  padding: 0 var(--sp-4) var(--sp-3);
}
.sidebar__search .form-input {
  font-size: .875rem;
  padding: .5rem .8rem;
}

.sidebar__section-label {
  padding: var(--sp-2) var(--sp-4) var(--sp-1);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
}

.note-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--sp-2) var(--sp-4);
}
.note-list::-webkit-scrollbar { width: 4px; }
.note-list::-webkit-scrollbar-track { background: transparent; }
.note-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-pill); }

.note-item {
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--t);
  margin-bottom: 2px;
}
.note-item:hover         { background: var(--surface-2); }
.note-item.active        { background: var(--primary-lt); }
.note-item__title        { font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item__meta         { font-size: .75rem; color: var(--text-3); margin-top: 2px; }
.note-item.active .note-item__title { color: var(--primary); }

.sidebar__bottom {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
}
.user-pill {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--t);
}
.user-pill:hover { background: var(--surface-2); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-lt);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-pill__name  { font-size: .9rem; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pill__caret { color: var(--text-3); font-size: .7rem; }

/* ── Main content area ───────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.main__toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}
.main__title-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  outline: none;
  padding: var(--sp-2) 0;
}
.main__title-input::placeholder { color: var(--text-3); font-weight: 400; }

.main__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-8);
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.main__body::-webkit-scrollbar { width: 6px; }
.main__body::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-pill); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--sp-4);
  color: var(--text-2);
  text-align: center;
  padding: var(--sp-10);
}
.empty-state__icon { font-size: 3.5rem; opacity: .4; }
.empty-state h2    { font-size: 1.2rem; color: var(--text); }
.empty-state p     { font-size: .9rem; color: var(--text-2); max-width: 320px; }

/* ── Note editor (Phase 2+, foundation) ─────────────────────── */
.note-editor {
  min-height: 200px;
  font-family: var(--font);
  font-size: .975rem;
  line-height: 1.75;
  color: var(--text);
  outline: none;
  width: 100%;
}
.note-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
  pointer-events: none;
}

/* ── Input cards (typed text, image, audio) ──────────────────── */
.input-section    { margin-bottom: var(--sp-6); }
.input-section h3 { font-size: .9rem; font-weight: 600; color: var(--text-2); margin-bottom: var(--sp-3); text-transform: uppercase; letter-spacing: .05em; font-size: .72rem; }

.input-card {
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  text-align: center;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
}
.input-card:hover       { border-color: var(--primary); background: var(--primary-lt); }
.input-card.has-content { border-style: solid; border-color: var(--border); cursor: default; }
.input-card__icon       { font-size: 2rem; margin-bottom: var(--sp-2); }
.input-card__label      { font-size: .9rem; color: var(--text-2); }
.input-card__sublabel   { font-size: .8rem; color: var(--text-3); margin-top: 4px; }

/* ── Processing indicator ────────────────────────────────────── */
.processing-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  background: #FEF3C7;
  color: var(--warning);
  font-size: .8rem;
  font-weight: 500;
}
.processing-badge::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.2s infinite;
}

/* ── Dropdown / context menu ─────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown__menu {
  position: absolute;
  right: 0; top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  min-width: 180px;
  padding: var(--sp-1);
  z-index: 100;
  display: none;
  animation: fadeIn .15s ease;
}
.dropdown__menu.open { display: block; }
.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: .9rem;
  cursor: pointer;
  transition: background var(--t);
  color: var(--text);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.dropdown__item:hover { background: var(--surface-2); }
.dropdown__item.danger { color: var(--danger); }
.dropdown__divider { height: 1px; background: var(--border); margin: var(--sp-1) 0; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
  z-index: 200;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
}
.modal__header {
  display: flex; align-items: center;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.modal__title  { font-size: 1.1rem; font-weight: 600; flex: 1; }
.modal__close  { background: none; border: none; cursor: pointer; color: var(--text-2); font-size: 1.2rem; padding: var(--sp-1); border-radius: var(--r-sm); line-height: 1; }
.modal__close:hover { background: var(--surface-2); color: var(--text); }
.modal__body   { padding: var(--sp-6); overflow-y: auto; }
.modal__footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); display: flex; gap: var(--sp-3); justify-content: flex-end; }

/* ── Toast notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 300;
}
.toast {
  background: var(--text);
  color: var(--text-inv);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  font-size: .9rem;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
  max-width: 300px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ── Profile panel (in modal) ────────────────────────────────── */
.profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.profile-avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--primary-lt);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 600;
  overflow: hidden;
}
.profile-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

/* ── Upload progress ─────────────────────────────────────────── */
.upload-progress {
  height: 4px;
  background: var(--border);
  border-radius: var(--r-pill);
  margin-top: var(--sp-3);
  overflow: hidden;
}
.upload-progress__bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-pill);
  transition: width .3s ease;
  width: 0;
}

/* ── Divider ─────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: var(--sp-5) 0; }
.divider-label {
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--text-3); font-size: .8rem;
  margin: var(--sp-5) 0;
}
.divider-label::before,
.divider-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Utility classes ─────────────────────────────────────────── */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.flex     { display: flex; }
.flex-1   { flex: 1; }
.gap-2    { gap: var(--sp-2); }
.gap-3    { gap: var(--sp-3); }
.items-center  { align-items: center; }
.justify-end   { justify-content: flex-end; }
.text-sm  { font-size: .875rem; }
.text-2   { color: var(--text-2); }
.mt-4     { margin-top: var(--sp-4); }
.mb-4     { margin-bottom: var(--sp-4); }
.fw-600   { font-weight: 600; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse   { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Responsive: mobile ──────────────────────────────────────── */
@media (max-width: 680px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--t-slow);
    width: min(var(--sidebar-w), 85vw);
  }
  #sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }

  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 49;
  }
  .sidebar-overlay.show { display: block; }

  .main__body { padding: var(--sp-5) var(--sp-5); }
  .auth-card  { padding: var(--sp-8) var(--sp-6); }
  #toast-container { bottom: var(--sp-4); right: var(--sp-4); left: var(--sp-4); }
  .toast { max-width: 100%; }
}
