/* notes.css — inherits design tokens from slides.css */
:root {
  /* notes accent overrides */
  --accent: #6ea8ff;
  --accent-2: #8b5cf6;
}

/* ── Shell ── */
.notes-shell {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* ── Topbar search ── */
.notes-search-wrap {
  position: relative;
}
.notes-search-icon {
  position: absolute;
  left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--fg-mute); pointer-events: none;
  display: flex;
}
#searchInput {
  font: inherit; font-size: 13px;
  color: var(--fg);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 6px 10px 6px 30px;
  outline: none; width: 220px;
  transition: border-color var(--dur) var(--ease), width var(--dur) var(--ease);
}
#searchInput:focus { border-color: var(--accent); width: 280px; }
#searchInput::placeholder { color: var(--fg-mute); }

/* ── Tag filter bar ── */
.notes-tag-bar {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.tag-filter-btn {
  padding: 3px 10px; border-radius: 20px;
  font: inherit; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); background: transparent; color: var(--fg-mute);
  cursor: pointer; transition: all var(--dur) var(--ease);
}
.tag-filter-btn:hover { color: var(--fg); border-color: var(--line-2); }
.tag-filter-btn.active {
  background: rgba(110,168,255,.1);
  border-color: var(--accent);
  color: var(--fg);
}

/* ── Notes grid (masonry) ── */
.notes-grid {
  columns: 260px auto;
  column-gap: 14px;
}

.note-card {
  break-inside: avoid;
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  padding: 15px 16px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
  position: relative;
}
.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
  border-color: var(--line-2);
}

.note-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 8px; gap: 8px;
}
.note-card-title {
  font-weight: 700; font-size: 14px; line-height: 1.35;
  flex: 1; word-break: break-word; color: var(--fg);
}
.note-card-actions {
  display: flex; gap: 3px;
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.note-card:hover .note-card-actions { opacity: 1; }
.note-action-btn {
  width: 24px; height: 24px; border-radius: 5px;
  background: rgba(0,0,0,.2); border: none; cursor: pointer;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
  color: inherit; opacity: .7; transition: opacity var(--dur), background var(--dur);
}
.note-action-btn:hover { opacity: 1; background: rgba(0,0,0,.35); }
.note-action-btn.pinned { opacity: 1; }

.note-card-body {
  font-size: 13px; line-height: 1.65; word-break: break-word;
  white-space: pre-wrap; color: var(--fg-mute);
  display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-footer {
  margin-top: 10px; display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 5px;
}
.note-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.note-tag {
  font-size: 11px; padding: 2px 7px; border-radius: 20px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  color: var(--fg-mute);
}
.note-date { font-size: 11px; color: var(--fg-dim); }

/* Countdown badge */
.countdown {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}
.countdown.ok     { background: rgba(74,222,128,.12); color: #4ade80; }
.countdown.soon   { background: rgba(251,191,36,.12); color: #fbbf24; }
.countdown.urgent { background: rgba(248,113,113,.15); color: #f87171; }
.countdown.overdue{ background: rgba(248,113,113,.2); color: #f87171; font-style: italic; }

/* Note card images */
.note-card-images {
  display: flex; gap: 4px; margin-top: 6px; overflow: hidden;
}
.note-card-images img {
  width: 40px; height: 40px; border-radius: 4px;
  object-fit: cover; flex-shrink: 0;
}

/* Empty state */
.notes-empty {
  text-align: center; color: var(--fg-mute);
  padding: 60px 20px; font-size: 14px; margin: 0;
}
.notes-empty[hidden] { display: none; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-elev-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 620px;
  max-height: 90vh;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.title-input {
  flex: 1; font: inherit; font-size: 18px; font-weight: 700;
  color: var(--fg); background: transparent; border: none; outline: none; padding: 0;
}
.title-input::placeholder { color: var(--fg-mute); font-weight: 400; }

.modal-header-actions { display: flex; align-items: center; gap: 8px; }
.color-palette { display: flex; gap: 6px; }
.color-swatch {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--dur), border-color var(--dur);
}
.color-swatch:hover { transform: scale(1.18); }
.color-swatch.active { border-color: white; }

.modal-close {
  width: 28px; height: 28px; border-radius: var(--radius-xs);
  background: transparent; border: none; color: var(--fg-mute);
  cursor: pointer; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur), color var(--dur);
}
.modal-close:hover { background: var(--hover); color: var(--fg); }

/* Modal body */
.modal-body {
  padding: 16px 20px;
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
#noteBodyInput {
  width: 100%; min-height: 260px; font: inherit; font-size: 14px; line-height: 1.75;
  color: var(--fg); background: transparent; border: none; outline: none;
  resize: none;
}
#noteBodyInput::placeholder { color: var(--fg-mute); }

/* Image attachments */
.note-images {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.note-images:empty { display: none; }
.note-image-thumb {
  position: relative; width: 76px; height: 76px;
  border-radius: var(--radius-xs); overflow: hidden;
  border: 1px solid var(--line); flex-shrink: 0;
}
.note-image-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer;
}
.note-image-thumb img:hover { opacity: .8; }
.note-image-del {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.7); color: #fff;
  border: none; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--dur);
}
.note-image-thumb:hover .note-image-del { opacity: 1; }

.note-add-image-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--radius-xs);
  font: inherit; font-size: 12px; font-weight: 500;
  color: var(--fg-mute); background: transparent;
  border: 1px solid var(--line); cursor: pointer;
  transition: color var(--dur), border-color var(--dur), background var(--dur);
  align-self: flex-start;
}
.note-add-image-btn:hover {
  color: var(--fg); border-color: var(--line-2); background: var(--hover);
}

/* Modal footer */
.modal-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.tags-input {
  font: inherit; font-size: 13px; color: var(--fg-mute);
  background: transparent; border: none; outline: none; padding: 0;
  width: 100%;
}
.tags-input::placeholder { color: var(--fg-mute); opacity: .55; }

.modal-footer-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.meta-label {
  font-size: 11px; font-weight: 700; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
.due-input {
  font: inherit; font-size: 12px; color: var(--fg);
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-xs); padding: 4px 8px; outline: none;
  cursor: pointer;
}
.due-input:focus { border-color: var(--accent); }
.project-select {
  font: inherit; font-size: 12px; color: var(--fg);
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-xs); padding: 4px 8px; outline: none; cursor: pointer;
  max-width: 150px;
}
.project-select:focus { border-color: var(--accent); }

.modal-footer-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  /* Layout */
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }

  /* Topbar: stack crumbs + actions */
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }
  .crumbs { flex: 1 1 auto; }
  .topbar-actions {
    flex: 1 1 100%;
    gap: 8px;
  }
  .topbar-divider { display: none; }
  #presenceBarDoc { display: none !important; }

  /* Search grows to fill */
  .notes-search-wrap { flex: 1; }
  #searchInput {
    width: 100%;
    box-sizing: border-box;
  }
  #searchInput:focus { width: 100%; }

  /* Content */
  .notes-shell { padding: 12px 14px; }
  .notes-grid { columns: 1; }

  /* Note cards: larger tap targets */
  .note-card { padding: 14px; }
  .note-card-actions { opacity: 1; }
  .note-action-btn { width: 32px; height: 32px; font-size: 15px; }

  /* Modal: full-screen sheet */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
  }
  .modal-header { padding: 16px 16px 12px; }
  .title-input { font-size: 16px; }
  .modal-body { padding: 12px 16px; }
  #noteBodyInput { min-height: 180px; font-size: 15px; }
  .modal-footer { padding: 10px 16px 24px; }

  /* Footer meta: allow wrapping */
  .modal-footer-meta { gap: 8px; }
  .due-input, .project-select { max-width: none; flex: 1; min-width: 0; }

  /* Bottom nav for page switching */
  body::after {
    content: '';
    display: block;
    height: 60px;
  }
}

/* Bottom nav bar (mobile only) */
.mobile-bottom-nav {
  display: none;
}
@media (max-width: 700px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--bg-elev);
    border-top: 1px solid var(--line);
    z-index: 100;
    align-items: center;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 0 12px; gap: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--fg-mute);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: var(--radius-xs);
    transition: color var(--dur);
    min-width: 56px; flex-shrink: 0;
    text-align: center;
  }
  .mobile-nav-item[data-active] { color: var(--accent); }
  .mobile-nav-item svg { flex-shrink: 0; }
}
