/* SAMA CRM — personal notebook widget. Twin of the chat widget (chat.css):
   same panel shell, header, search and list rows, so the two feel identical.
   Editor view replaces the chat thread. Uses the shared theme variables. */

/* ── Header button (twin of .chat-btn) ── */
.nb-btn {
  position: relative; width: 42px; height: 42px;
  border: none; background: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--transition); flex-shrink: 0;
}
.nb-btn:hover { background: rgba(224,123,32,.1); }
.nb-btn-icon { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; }
.nb-btn-icon svg { width: 22px; height: 22px; transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.nb-btn:hover .nb-btn-icon svg { transform: scale(1.08); }

/* ── Panel shell ── */
.nb-panel-backdrop { position: fixed; inset: 0; z-index: 9990; display: none; }
.nb-panel-backdrop.open { display: block; }
.nb-panel {
  position: fixed; bottom: 20px; right: 20px;
  width: 420px; max-width: calc(100vw - 24px);
  height: calc(100vh - var(--header-h) - 30px); max-height: 640px;
  background: var(--clr-surface); border: 1px solid var(--clr-border);
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.08);
  z-index: 9991; display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(20px) scale(.96); transform-origin: bottom right;
  transition: opacity .22s cubic-bezier(.4,0,.2,1), transform .22s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.nb-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

/* View switching: one view visible at a time */
.nb-list-view, .nb-editor-view { flex: 1; min-height: 0; flex-direction: column; display: none; }
.nb-panel[data-view="list"]   .nb-list-view,
.nb-panel[data-view="editor"] .nb-editor-view { display: flex; }

/* ── Heads ── */
.nb-panel-head {
  padding: 16px 18px 14px; border-bottom: 1px solid var(--clr-border);
  background: linear-gradient(135deg, #faf9f7, #f5f3f0);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; gap: 12px;
}
.nb-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nb-head-icon {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(224,123,32,.15), rgba(224,123,32,.08));
  border: 1.5px solid rgba(224,123,32,.22);
  display: flex; align-items: center; justify-content: center;
}
.nb-head-icon svg { width: 20px; height: 20px; }
.nb-panel-title {
  font-family: 'Times New Roman', Times, serif;
  font-size: 1.05rem; font-weight: 700; color: var(--clr-text); line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nb-panel-sub { font-size: .72rem; color: var(--clr-text-sub); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-panel-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.nb-new-btn, .nb-back-btn, .nb-panel-close, .nb-del-btn {
  border: none; background: none; cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition); color: var(--clr-gray); flex-shrink: 0;
}
.nb-new-btn { width: 32px; height: 32px; color: var(--clr-orange); border: 1px solid rgba(224,123,32,.25); }
.nb-new-btn:hover { background: rgba(224,123,32,.08); border-color: rgba(224,123,32,.5); }
.nb-new-btn svg { width: 16px; height: 16px; }
.nb-del-btn { width: 32px; height: 32px; color: #c0392b; }
.nb-del-btn:hover { background: rgba(192,57,43,.1); }
.nb-del-btn svg { width: 17px; height: 17px; }
.nb-del-btn[hidden] { display: none; }
.nb-back-btn { width: 32px; height: 32px; }
.nb-back-btn:hover { background: rgba(0,0,0,.06); color: var(--clr-text); }
.nb-back-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nb-panel-close { width: 30px; height: 30px; }
.nb-panel-close:hover { background: rgba(0,0,0,.07); color: var(--clr-text); }
.nb-panel-close svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.nb-editor-head { gap: 10px; }
.nb-editor-title { min-width: 0; flex: 1; }

/* ── Search ── */
.nb-search-bar { position: relative; padding: 10px 14px; border-bottom: 1px solid var(--clr-border); flex-shrink: 0; }
.nb-search-bar input {
  width: 100%; border: 1px solid var(--clr-border); border-radius: 20px;
  padding: 8px 12px 8px 34px; font-family: 'Times New Roman', Times, serif;
  font-size: .82rem; color: var(--clr-text); background: var(--clr-bg);
  outline: none; transition: border-color var(--transition), background var(--transition);
}
.nb-search-bar input:focus { border-color: var(--clr-orange); background: #fff; }
.nb-search-icon { position: absolute; left: 24px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: none; stroke-width: 2; opacity: .5; pointer-events: none; }

/* ── List body / note rows ── */
.nb-body { overflow-y: auto; flex: 1; padding: 6px; scrollbar-width: thin; scrollbar-color: var(--clr-border) transparent; }
.nb-row {
  display: flex; flex-direction: column; gap: 4px; padding: 11px 12px;
  border-radius: 10px; cursor: pointer; transition: background .13s; position: relative;
}
.nb-row:hover { background: #f7f3ee; }
.nb-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.nb-row-title { font-weight: 600; color: var(--clr-text); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-row-title.untitled { color: var(--clr-text-sub); font-style: italic; font-weight: 500; }
.nb-row-time { font-size: .66rem; color: var(--clr-text-sub); flex-shrink: 0; }
.nb-row-preview { font-size: .78rem; color: var(--clr-text-sub); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Editor ── */
.nb-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--clr-bg); }
.nb-title-input {
  border: none; outline: none; background: transparent; flex-shrink: 0;
  padding: 16px 16px 8px; font-family: 'Times New Roman', Times, serif;
  font-size: 1.15rem; font-weight: 700; color: var(--clr-text);
}
.nb-title-input::placeholder { color: var(--clr-text-sub); font-weight: 600; }
.nb-body-input {
  flex: 1; min-height: 0; resize: none; border: none; outline: none; background: transparent;
  padding: 4px 16px 12px; font-family: 'Times New Roman', Times, serif;
  font-size: .9rem; line-height: 1.6; color: var(--clr-text);
  scrollbar-width: thin; scrollbar-color: var(--clr-border) transparent;
}
.nb-body-input::placeholder { color: var(--clr-text-sub); }
.nb-editor-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-top: 1px solid var(--clr-border); background: var(--clr-surface); flex-shrink: 0;
}
.nb-save-state { font-size: .72rem; color: var(--clr-text-sub); }
.nb-save-btn {
  border: none; cursor: pointer; border-radius: 18px; padding: 9px 22px;
  font-family: 'Times New Roman', Times, serif; font-size: .85rem; font-weight: 600; color: #fff;
  background: linear-gradient(145deg, var(--clr-orange-dk), var(--clr-orange));
  box-shadow: 0 2px 8px rgba(224,123,32,.35); transition: transform .15s, opacity .15s;
}
.nb-save-btn:hover { transform: scale(1.04); }
.nb-save-btn:disabled { opacity: .45; cursor: default; transform: none; }

/* ── Empty / loading ── */
.nb-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 24px; color: var(--clr-text-sub); height: 100%; }
.nb-empty svg { width: 46px; height: 46px; stroke: var(--clr-border); fill: none; stroke-width: 1.4; margin-bottom: 12px; }
.nb-empty h4 { font-family: 'Times New Roman', Times, serif; color: var(--clr-text); font-size: 1rem; margin-bottom: 4px; }
.nb-empty p { font-size: .8rem; }

/* ── Responsive: full-screen sheet on phones ── */
@media (max-width: 560px) {
  .nb-panel {
    top: 0; right: 0; left: 0; bottom: 0; width: 100%; max-width: 100%;
    height: 100%; max-height: 100%; border-radius: 0; border: none;
  }
}
