/* ==========================================================================
   NoteKeep — styles.css
   Palette matches the authentic Google Keep swatch set (light + dark
   variants) since this app is deliberately built as a Keep-style clone.
   ========================================================================== */

:root {
  --bg: #f4f3f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e3e1ea;
  --text: #1f1b2e;
  --text-muted: #6b6779;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(31,27,46,0.06), 0 2px 8px rgba(31,27,46,0.06);
  --shadow-hover: 0 4px 10px rgba(31,27,46,0.10), 0 8px 24px rgba(31,27,46,0.10);
  --shadow-fab: 0 6px 16px rgba(108,92,231,0.35), 0 2px 6px rgba(108,92,231,0.25);

  --accent: #6C5CE7;
  --accent-dark: #4834b0;
  --accent-soft: #ece9fd;

  /* Google Keep note colors — light theme */
  --c-default: #ffffff;
  --c-coral:   #f28b82;
  --c-peach:   #fbbc04;
  --c-sand:    #fff475;
  --c-mint:    #ccff90;
  --c-sage:    #a7ffeb;
  --c-fog:     #cbf0f8;
  --c-storm:   #aecbfa;
  --c-dusk:    #d7aefb;
  --c-blossom: #fdcfe8;
  --c-clay:    #e6c9a8;
  --c-chalk:   #e8eaed;
}

body.dark {
  --bg: #17151f;
  --surface: #241f31;
  --surface-raised: #2b2438;
  --border: #3a3448;
  --text: #ece9f5;
  --text-muted: #a29dbd;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 2px 10px rgba(0,0,0,0.3);
  --shadow-hover: 0 6px 16px rgba(0,0,0,0.4), 0 10px 28px rgba(0,0,0,0.35);
  --accent-soft: #362f4a;

  /* Google Keep note colors — dark theme (authentic muted variants) */
  --c-default: #2b2438;
  --c-coral:   #5c2b29;
  --c-peach:   #614a19;
  --c-sand:    #635d19;
  --c-mint:    #345920;
  --c-sage:    #16504a;
  --c-fog:     #16414f;
  --c-storm:   #2d3c4d;
  --c-dusk:    #472e5b;
  --c-blossom: #6c394f;
  --c-clay:    #4b443a;
  --c-chalk:   #3c3f43;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

button { font-family: inherit; }
.hidden { display: none !important; }

/* ---------------------------- Top bar ---------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-mark { width: 30px; height: 30px; flex-shrink: 0; }
.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  display: none;
}
@media (min-width: 560px) { .logo-text { display: inline; } }

.topbar-search {
  flex: 1;
  max-width: 720px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 999px;
  padding: 0 16px;
  height: 46px;
  transition: background 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.topbar-search:hover { background: var(--accent-soft); }
.topbar-search:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-hover);
}
.search-icon { width: 19px; height: 19px; color: var(--text-muted); flex-shrink: 0; transition: color 0.18s; }
.topbar-search:focus-within .search-icon { color: var(--accent); }
.topbar-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: var(--text);
  min-width: 0;
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-right { flex-shrink: 0; margin-left: auto; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }

.btn-primary {
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { transform: scale(0.97); }

/* ---------------------------- Sidebar drawer ---------------------------- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,12,25,0.35);
  z-index: 40;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.sidebar-overlay.hidden { display: none; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--surface);
  z-index: 41;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform: translateX(-100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 0 0 rgba(0,0,0,0);
}
.sidebar.open {
  transform: translateX(0);
  box-shadow: 8px 0 24px rgba(0,0,0,0.15);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
}
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-size: 18px; font-weight: 700; color: var(--text); }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
  padding: 11px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.sidebar-item svg { width: 19px; height: 19px; color: var(--text-muted); flex-shrink: 0; }
.sidebar-item:hover { background: var(--bg); }
.sidebar-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar-item.active svg { color: var(--accent); }

.sidebar-divider { height: 1px; background: var(--border); margin: 10px 6px; }
.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 14px 8px;
}
.sidebar-colors { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 14px 6px; }
.sidebar-spacer { flex: 1; }

/* ---------------------------- Main layout ---------------------------- */
.main-wrap {
  max-width: 940px;
  margin: 0 auto;
  padding: 28px 16px 100px;
}

/* ---------------------------- Composer trigger (desktop bar) ---------------------------- */
.composer-shell { display: flex; justify-content: center; margin-bottom: 40px; }
.composer-trigger {
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 4px 6px 4px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: text;
  font-size: 15.5px;
  color: var(--text-muted);
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
  height: 56px;
}
.composer-trigger:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.composer-trigger-icons { display: flex; }

/* ---------------------------- Shared composer/modal fields ---------------------------- */
.composer-title {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  padding: 6px 2px 10px;
  letter-spacing: -0.2px;
}
.composer-body {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 15.5px;
  font-family: inherit;
  color: var(--text);
  padding: 6px 2px;
  line-height: 1.6;
}
.composer-body::placeholder, .composer-title::placeholder { color: var(--text-muted); }

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 6px;
}
.composer-actions-left { display: flex; gap: 2px; }

/* Color swatch row */
.color-row { display: flex; flex-wrap: wrap; gap: 9px; padding: 10px 2px 6px; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.selected::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
}
.swatch.selected::before {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text);
}
.swatch-default { background: var(--surface); }

/* ---------------------------- Notes grid (responsive masonry) ---------------------------- */
.notes-section { margin-bottom: 32px; }
.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 14px 4px;
}

.notes-grid { column-count: 1; column-gap: 16px; }
@media (min-width: 540px)  { .notes-grid { column-count: 2; } }
@media (min-width: 800px)  { .notes-grid { column-count: 3; } }
@media (min-width: 1100px) { .notes-grid { column-count: 4; } }

.note-card {
  break-inside: avoid;
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 8px;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.12s;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.note-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.note-card:hover .note-quick-actions { opacity: 1; }

.note-pin-indicator { position: absolute; top: 10px; right: 10px; width: 17px; height: 17px; color: var(--text-muted); }

.note-title {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 6px;
  padding-right: 20px;
  word-break: break-word;
  white-space: pre-wrap;
}
.note-body {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  margin: 0;
  max-height: 260px;
  overflow: hidden;
}

/* Checklist rendering inside a note card */
.note-checklist { display: flex; flex-direction: column; gap: 7px; margin: 2px 0 4px; }
.note-checklist-item { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; line-height: 1.4; }
.note-checklist-item input[type="checkbox"] {
  margin-top: 2px;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.note-checklist-item span { word-break: break-word; }
.note-checklist-item.checked span { text-decoration: line-through; color: var(--text-muted); }
.note-checklist-more { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 4px; }

.note-quick-actions {
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  margin-top: 8px;
  padding-top: 4px;
}
@media (hover: none) { .note-quick-actions { opacity: 1; } }

/* ---------------------------- List view (distinct compact layout) ---------------------------- */
body.list-view .notes-grid {
  column-count: 1 !important;
  max-width: 640px;
  margin: 0 auto;
}
body.list-view .note-card {
  flex-direction: row;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
}
body.list-view .note-pin-indicator { position: static; margin-right: 2px; flex-shrink: 0; }
body.list-view .note-title { padding-right: 0; margin: 0; flex-shrink: 0; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.list-view .note-body { max-height: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
body.list-view .note-checklist { flex-direction: row; flex-wrap: nowrap; overflow: hidden; flex: 1; gap: 14px; }
body.list-view .note-checklist-item { white-space: nowrap; }
body.list-view .note-quick-actions { margin-top: 0; padding-top: 0; flex-shrink: 0; }

/* ---------------------------- Empty state ---------------------------- */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 80px 20px; color: var(--text-muted); }
.empty-illustration { width: 160px; height: auto; }
.empty-state p { font-size: 15px; margin: 0; }

/* ---------------------------- Floating action button ---------------------------- */
/* This `bottom` value is the fallback for browsers without the visualViewport
   API; app.js's syncFabPosition() overrides it with an inline style on every
   other browser to work around a known mobile address-bar/fixed-position bug
   (see the comment above syncFabPosition() in app.js for details). */
.fab-wrap {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.fab-main {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-fab);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s;
}
.fab-main svg { width: 26px; height: 26px; transition: transform 0.2s; }
.fab-main:hover { background: var(--accent-dark); transform: scale(1.06); }
.fab-main:active { transform: scale(0.94); }
.fab-main.open svg { transform: rotate(45deg); }

.fab-options {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.fab-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: var(--surface);
  color: var(--text);
  padding: 8px 8px 8px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-hover);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  animation: fabPop 0.16s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
#fabNoteBtn { animation-delay: 0.02s; }
#fabChecklistBtn { animation-delay: 0.06s; }
@keyframes fabPop {
  from { opacity: 0; transform: translateY(8px) scale(0.85); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.fab-option-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fab-option-icon svg { width: 18px; height: 18px; }

/* Hide the desktop inline composer trigger on very small screens; the FAB covers it there */
@media (max-width: 480px) {
  .composer-shell { margin-bottom: 24px; }
}

/* ---------------------------- Modal (create / edit) ---------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,12,25,0.55);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  background: var(--surface-raised);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  padding: 22px 24px 14px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: modalPop 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-textarea { min-height: 120px; max-height: 42vh; overflow-y: auto; }

/* ---------------------------- Checklist editor (inside modal) ---------------------------- */
.checklist-editor { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 6px; max-height: 45vh; overflow-y: auto; }
.checklist-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.checklist-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.checklist-row input[type="text"] {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14.5px;
  color: var(--text);
  padding: 5px 0;
}
.checklist-row.checked input[type="text"] { text-decoration: line-through; color: var(--text-muted); }
.checklist-row .remove-item-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
.checklist-row:hover .remove-item-btn { opacity: 1; }
.remove-item-btn:hover { background: var(--bg); color: var(--text); }
.remove-item-btn svg { width: 15px; height: 15px; }
.checklist-row.new-item-row input[type="checkbox"] { opacity: 0.3; pointer-events: none; }

/* ---------------------------- Offline toast ---------------------------- */
.offline-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: #1f1b2e;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 60;
}

/* ---------------------------- Focus visibility (accessibility) ---------------------------- */
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------- Reduced motion ---------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------- Mobile tweaks ---------------------------- */
@media (max-width: 539px) {
  .main-wrap { padding: 16px 12px 100px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-search { height: 42px; }
  .sidebar { width: 240px; }
}

/* ---------------------------- Sidebar install CTA ---------------------------- */
.sidebar-item.install-item {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.sidebar-item.install-item svg { color: var(--accent); }
.sidebar-item.install-item:hover { background: var(--accent); color: #fff; }
.sidebar-item.install-item:hover svg { color: #fff; }

/* ---------------------------- Help modal ---------------------------- */
.help-card { max-width: 480px; padding: 20px 22px 18px; }
.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.help-header h2 { font-size: 19px; font-weight: 700; margin: 0; }
.help-list { display: flex; flex-direction: column; gap: 6px; }
.help-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.help-item:last-child { border-bottom: none; }
.help-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.help-icon svg { width: 19px; height: 19px; }
.help-item strong { font-size: 14.5px; color: var(--text); }
.help-item p { font-size: 13.5px; color: var(--text-muted); margin: 3px 0 0; line-height: 1.5; }

/* ---------------------------- Archived note affordance ---------------------------- */
.note-archived-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}
