/* ═══════════════════════════════════════════════
   NOTED PAD PRO v4 — modals.css
   Modal backdrop, container, and all modal contents
═══════════════════════════════════════════════ */

/* ── MODAL BASE ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(5px);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
  position: relative;
}
.modal-sm  { max-width: 400px; }
.modal-md  { max-width: 480px; }
.modal-lg  { max-width: 580px; }
.modal-xl  { max-width: 680px; }

.modal h2 {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}
.modal p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }

/* Modal form elements */
.modal label {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); letter-spacing: .5px;
  display: block; margin-bottom: 4px;
}
.modal input,
.modal textarea,
.modal select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color var(--t-fast);
  margin-bottom: 12px;
}
.modal input:focus,
.modal textarea:focus { border-color: var(--border-accent); }
.modal textarea { resize: vertical; min-height: 80px; }

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ── TEMPLATE MODAL ── */
.tpl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.tpl-card {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-input);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--t-fast);
}
.tpl-card:hover { border-color: var(--border-accent); background: var(--bg-hover); }
.tpl-icon { font-size: 22px; margin-bottom: 4px; }
.tpl-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.tpl-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ── FOLDER MODAL ── */
.folder-input-row { display: flex; gap: 7px; margin-bottom: 12px; }
.folder-input-row input { margin-bottom: 0; }
.folder-emoji-input { width: 52px !important; text-align: center; }
.folder-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.folder-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border);
}
.folder-item-emoji { font-size: 17px; }
.folder-item-name  { flex: 1; font-size: 12.5px; color: var(--text-primary); }
.folder-item-count { font-size: 10px; color: var(--text-muted); background: var(--bg-hover); padding: 2px 7px; border-radius: var(--radius-sm); }
.folder-item-del   { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; transition: color var(--t-fast); }
.folder-item-del:hover { color: var(--danger); }

/* ── REMINDER MODAL ── */
.reminder-form {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  margin-bottom: 12px;
}
.reminder-form-title { font-size: 10px; font-weight: 700; color: var(--text-muted); letter-spacing: .5px; margin-bottom: 9px; text-transform: uppercase; }
.reminder-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.reminder-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border);
}
.reminder-item.overdue { border-color: rgba(224,85,85,.25); }
.reminder-item.overdue .ri-name { color: var(--danger); }
.reminder-item.soon    { border-color: rgba(240,165,0,.25); }
.reminder-item.soon .ri-name    { color: var(--warning); }
.ri-icon { font-size: 18px; flex-shrink: 0; }
.ri-body { flex: 1; }
.ri-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.ri-time { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.ri-del  { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; transition: color var(--t-fast); }
.ri-del:hover { color: var(--danger); }

/* ── THEME MODAL ── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.theme-card {
  padding: 12px 10px; border-radius: var(--radius);
  border: 2px solid var(--border); cursor: pointer;
  transition: all var(--t-fast); text-align: center;
}
.theme-card:hover { transform: scale(1.03); }
.theme-card.active { border-color: var(--accent) !important; box-shadow: 0 0 16px var(--accent-glow); }
.theme-name  { font-size: 11.5px; font-weight: 600; margin-top: 7px; }
.theme-dots  { display: flex; gap: 5px; justify-content: center; }
.theme-dot   { width: 14px; height: 14px; border-radius: 50%; }
.accent-row  {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg-input);
  border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 12px;
}
.accent-row span { font-size: 12px; color: var(--text-secondary); flex: 1; }
#accent-picker { width: 44px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; background: transparent; }
.accent-presets { display: flex; gap: 7px; flex-wrap: wrap; }
.accent-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: transform var(--t-fast), border-color var(--t-fast);
}
.accent-swatch:hover  { transform: scale(1.2); }
.accent-swatch.active { border-color: white; transform: scale(1.15); }

/* ── DASHBOARD MODAL ── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 16px;
}
.dash-card { padding: 13px; border-radius: var(--radius); background: var(--bg-input); border: 1px solid var(--border); text-align: center; }
.dash-num  { font-size: 26px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); line-height: 1; }
.dash-lbl  { font-size: 10px; color: var(--text-muted); margin-top: 4px; letter-spacing: .5px; text-transform: uppercase; }
.dash-section { margin-bottom: 16px; }
.dash-section-title { font-size: 10.5px; font-weight: 700; color: var(--text-muted); letter-spacing: .8px; text-transform: uppercase; margin-bottom: 9px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.bar-label { font-size: 11px; color: var(--text-secondary); width: 68px; flex-shrink: 0; text-align: right; }
.bar-track { flex: 1; height: 7px; background: rgba(255,255,255,.05); border-radius: 4px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 4px; background: var(--accent); transition: width .5s ease; }
.bar-val   { font-size: 10px; color: var(--text-muted); width: 32px; text-align: right; font-family: var(--font-mono); }
.top-note {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; border-radius: 7px;
  background: var(--bg-input); border: 1px solid var(--border);
  margin-bottom: 5px; cursor: pointer; transition: all var(--t-fast);
}
.top-note:hover { border-color: var(--border-accent); background: var(--bg-hover); }
.top-note-title { font-size: 12px; color: var(--text-primary); flex: 1; }
.top-note-wc    { font-size: 10px; color: var(--text-muted); margin-left: 8px; font-family: var(--font-mono); flex-shrink: 0; }

/* ── POMODORO MODAL ── */
.pomo-mode-row { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.pomo-ring-wrap { display: flex; justify-content: center; margin: 16px 0; }
.pomo-ring      { position: relative; width: 160px; height: 160px; }
.pomo-ring svg  { transform: rotate(-90deg); }
.pomo-ring-bg   { fill: none; stroke: var(--border); stroke-width: 8; }
.pomo-ring-fill {
  fill: none; stroke: var(--danger); stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 440;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .5s linear, stroke .3s;
}
.pomo-ring-fill.rest { stroke: var(--success); }
.pomo-time  {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-family: var(--font-mono); font-size: 28px; font-weight: 700;
  color: var(--text-primary);
}
.pomo-label   { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
.pomo-controls { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pomo-cycles   { display: flex; justify-content: center; gap: 5px; margin-top: 10px; }
.pomo-cycle-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background .3s; }
.pomo-cycle-dot.done { background: var(--danger); }
.pomo-cycle-dot.rest { background: var(--success); }
.pomo-settings {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.pomo-set-item label { font-size: 10px; color: var(--text-muted); margin-bottom: 3px; display: block; }
.pomo-set-item input { margin-bottom: 0; padding: 5px 8px; }
#pomo-start-btn.pausing { background: var(--danger-soft); color: var(--danger); border-color: rgba(224,85,85,.3); }

/* ── CALENDAR MODAL ── */
.cal-header     { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav        { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; transition: all var(--t-fast); font-size: 14px; }
.cal-nav:hover  { background: var(--bg-hover); color: var(--accent); }
.cal-month-lbl  { font-size: 15px; font-weight: 700; color: var(--text-primary); font-family: var(--font-display); }
.cal-grid       { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.cal-day-hdr    { text-align: center; font-size: 9.5px; font-weight: 700; color: var(--text-muted); letter-spacing: .5px; padding: 4px 0; }
.cal-day        { min-height: 42px; padding: 3px; border-radius: var(--radius-sm); border: 1px solid transparent; transition: all var(--t-fast); cursor: default; }
.cal-day.has-due { border-color: var(--border-accent); background: var(--accent-soft); cursor: pointer; }
.cal-day.has-due:hover { background: rgba(240,165,0,.2); }
.cal-day.today .cal-dn { background: var(--accent); color: #0d0f14; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.cal-day.other-month .cal-dn { opacity: .3; }
.cal-dn         { font-size: 11px; color: var(--text-primary); font-weight: 600; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.cal-dots       { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.cal-dot        { width: 5px; height: 5px; border-radius: 50%; }
.cal-dot.ok { background: var(--success); }
.cal-dot.sn { background: var(--accent);  }
.cal-dot.ov { background: var(--danger);  }
.cal-event-list { margin-top: 14px; max-height: 200px; overflow-y: auto; }
.cal-event-item {
  padding: 7px 10px; border-radius: 7px;
  background: var(--bg-input); border: 1px solid var(--border);
  margin-bottom: 5px; cursor: pointer; transition: all var(--t-fast);
  display: flex; align-items: center; gap: 8px;
}
.cal-event-item:hover { border-color: var(--border-accent); background: var(--bg-hover); }
.cal-event-dot   { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cal-event-title { font-size: 12px; color: var(--text-primary); flex: 1; }
.cal-event-date  { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }

/* ── GLOBAL SEARCH MODAL ── */
.gs-input-wrap { position: relative; margin-bottom: 14px; }
.gs-input-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
#gs-input { padding: 10px 12px 10px 40px; font-size: 14px; border-radius: var(--radius); margin-bottom: 0; }
.gs-results { max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.gs-item {
  padding: 11px 13px; border-radius: var(--radius);
  background: var(--bg-input); border: 1px solid var(--border);
  cursor: pointer; transition: all var(--t-fast);
}
.gs-item:hover { border-color: var(--border-accent); background: var(--bg-hover); }
.gs-item-title   { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.gs-item-preview { font-size: 11.5px; color: var(--text-muted); line-height: 1.6; }
.gs-item-meta    { display: flex; align-items: center; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.gs-badge { font-size: 10px; color: var(--text-secondary); background: var(--bg-hover); padding: 1px 7px; border-radius: 9px; }
.gs-empty { text-align: center; padding: 32px; color: var(--text-muted); font-size: 13px; }

/* ── VERSION HISTORY MODAL ── */
.vh-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.vh-item {
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--bg-input); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.vh-item.current { border-color: var(--border-accent); }
.vh-num   { font-size: 10px; font-weight: 700; color: var(--text-muted); background: var(--bg-hover); padding: 2px 7px; border-radius: var(--radius-sm); flex-shrink: 0; font-family: var(--font-mono); }
.vh-info  { flex: 1; }
.vh-date  { font-size: 11.5px; color: var(--text-primary); font-weight: 600; }
.vh-wc    { font-size: 10px; color: var(--text-muted); }
.vh-prev  { font-size: 10px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.vh-actions { display: flex; gap: 4px; flex-shrink: 0; }
.vh-btn       { padding: 3px 9px; font-size: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: none; color: var(--text-muted); cursor: pointer; transition: all var(--t-fast); }
.vh-btn:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--border-accent); }
.vh-btn.restore { color: var(--success); border-color: rgba(72,187,120,.3); }
.vh-btn.restore:hover { background: rgba(72,187,120,.1); }

/* ── BACKLINK DROPDOWN ── */
#bl-dropdown {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: var(--z-dropdown);
  display: none;
  max-width: 280px;
  max-height: 220px;
  overflow-y: auto;
}
#bl-dropdown.show { display: block; }
.bl-opt {
  padding: 7px 11px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12.5px; color: var(--text-primary);
  transition: all var(--t-fast);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bl-opt:hover { background: var(--bg-hover); color: var(--accent); }
.bl-opt-hint  { font-size: 10px; color: var(--text-muted); margin-left: 5px; }

/* ── BACKLINKS PANEL ITEMS ── */
.bl-back-item {
  padding: 6px 9px; border-radius: 7px;
  background: var(--bg-hover); border: 1px solid var(--border);
  font-size: 11px; cursor: pointer; transition: all var(--t-fast); margin-bottom: 4px;
}
.bl-back-item:hover { border-color: rgba(167,139,250,.3); }
.bl-back-title { font-weight: 600; color: var(--text-primary); font-size: 11.5px; }
.bl-back-ctx   { color: var(--text-muted); font-size: 10px; margin-top: 2px; }

/* ── Modal close X button ── */
.modal-close-x {
  position: absolute;
  top: 14px; right: 14px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  z-index: 1;
}
.modal-close-x:hover { background: var(--danger-soft); color: var(--danger); border-color: rgba(224,85,85,.3); }

/* ── Mobile modal slide-up ── */
@media (max-width: 768px) {
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal {
    border-radius: 18px 18px 0 0 !important;
    max-height: 90vh !important;
    animation: slideUpMobile var(--t-slow) !important;
    width: 100% !important;
    margin: 0 !important;
  }
  .modal.modal-xl { max-width: 100% !important; }
}
@keyframes slideUpMobile {
  from { transform: translateY(100%); opacity: 0.5; }
  to   { transform: translateY(0);    opacity: 1;   }
}
