/* ============================================
   Pocket Diary — stylesheet
   Font: Plus Jakarta Sans + JetBrains Mono
   Palette: Indigo/Violet brand, slate neutrals
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #6366f1;
  --brand-dark:  #4f46e5;
  --brand-light: #e0e7ff;
  --accent:      #8b5cf6;
  --success:     #10b981;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --info:        #06b6d4;

  --bg:          #f8fafc;
  --surface:     #ffffff;
  --surface-2:   #f1f5f9;
  --border:      #e2e8f0;
  --border-dark: #cbd5e1;

  --text:        #0f172a;
  --text-muted:  #64748b;
  --text-light:  #94a3b8;

  --sidebar-w:   240px;
  --topbar-h:    60px;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.12);

  --font:        'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;

  --modal-bg:    rgba(15,23,42,.5);
}

/* ── Dark theme palette ── */
[data-theme="dark"] {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface-2:   #263348;
  --border:      #334155;
  --border-dark: #475569;

  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --text-light:  #64748b;

  --brand-light: #1e1b4b;
  --modal-bg:    rgba(0,0,0,.65);
  --shadow:      0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.45);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background .2s, color .2s;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  font-size: 18px; font-weight: 700; color: var(--brand);
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 24px; }
.nav-links { list-style: none; padding: 12px 10px; flex: 1; }
.nav-links li { margin-bottom: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none;
  font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--brand-light); color: var(--brand); }
.nav-link.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ── Topbar ── */
.topbar {
  position: fixed; top: 0;
  left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  z-index: 100;
  transition: left .28s;
}
.page-title { font-size: 17px; font-weight: 600; color: var(--text); }
.menu-toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.menu-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: transform .2s;
}
.topbar-add-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: var(--brand); color: #fff;
  border-radius: var(--radius-sm);
  font-size: 20px; font-weight: 700; line-height: 1;
  text-decoration: none; flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.topbar-add-btn:hover { background: var(--brand-dark); }
.topbar-add-btn:active { transform: scale(.94); }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 28px) 28px 40px;
  min-height: 100vh;
  transition: margin-left .28s;
}

/* ── Overlay (mobile) ── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 150;
}
.overlay.show { display: block; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text); }

/* ── Stat tiles ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--brand); margin-top: 6px; font-family: var(--font-mono); }
.stat-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }

/* ── Alerts ── */
.alert {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 20px; font-size: 14px; font-weight: 500;
  gap: 12px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info     { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.alert-close { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; line-height: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  border: 1.5px solid transparent; cursor: pointer;
  text-decoration: none; transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: none; color: var(--text-muted); border-color: transparent; padding: 7px 10px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
label .req { color: var(--danger); }
input[type=text], input[type=email], input[type=tel], input[type=date],
input[type=search], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 12px; color: var(--text-light); }
.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 14px;
  background: var(--surface-2);
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
.td-actions { display: flex; gap: 6px; }

/* ── Avatar / initials chip ── */
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.contact-cell { display: flex; align-items: center; gap: 10px; }
.contact-name { font-weight: 600; }
.contact-sub { font-size: 12px; color: var(--text-muted); }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 9px;
  border-radius: 99px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
.badge-indigo { background: var(--brand-light); color: var(--brand-dark); }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-gray   { background: var(--surface-2); color: var(--text-muted); }

/* ── Search bar ── */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 36px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 16px; pointer-events: none; }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 60px 24px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ── Profile card ── */
.profile-hero {
  display: flex; align-items: center; gap: 24px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.profile-name { font-size: 22px; font-weight: 700; }
.profile-email { color: var(--text-muted); font-size: 14px; }

/* ── Date pill ── */
.date-pill {
  display: inline-block; padding: 3px 10px;
  background: var(--brand-light); color: var(--brand-dark);
  border-radius: 99px; font-size: 12px; font-weight: 600;
  font-family: var(--font-mono);
}

/* ── Page header ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header p  { color: var(--text-muted); font-size: 14px; margin-top: 3px; }

/* ── Diary entry card ── */
.diary-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 12px;
  background: var(--surface); box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: start;
}
.diary-date-col { display: flex; flex-direction: column; align-items: center; min-width: 56px; }
.diary-day { font-size: 26px; font-weight: 700; color: var(--brand); line-height: 1; font-family: var(--font-mono); }
.diary-month { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.diary-desc { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.diary-remarks { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.diary-contact-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border-radius: 99px;
  padding: 3px 10px; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
}

/* ── Modal ── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: var(--modal-bg); z-index: 500;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0; margin-bottom: 20px;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: 0 24px 24px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .main-content { margin-left: 0; padding: calc(var(--topbar-h) + 20px) 16px 32px; }
  .menu-toggle { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .diary-card { grid-template-columns: auto 1fr; }
  .diary-card .td-actions { grid-column: 1/-1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  table { font-size: 13px; }
  thead th, tbody td { padding: 9px 10px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}

/* ══════════════════════════════════════════════
   LIST SCREENS — added styles
══════════════════════════════════════════════ */

/* Two-column dashboard layout */
.two-col-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}
.col-main  { min-width: 0; }
.col-side  { display: flex; flex-direction: column; gap: 20px; }

/* Sortable table */
.entries-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.entries-table thead th {
  text-align: left; padding: 10px 14px;
  background: var(--surface-2);
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .07em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.entries-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.entries-table tbody tr:last-child td { border-bottom: none; }
.entries-table tbody tr:hover td { background: var(--surface-2); }

.sort-link {
  color: inherit; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: inherit; font-weight: inherit;
}
.sort-link:hover { color: var(--brand); }
.sort-icon { font-size: 11px; color: var(--text-light); }
.sort-icon.active { color: var(--brand); }

/* Date block in table */
.date-block { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.date-block-day { font-size: 20px; font-weight: 700; color: var(--brand); font-family: var(--font-mono); }
.date-block-mon { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Contact link */
.contact-link {
  color: var(--text); text-decoration: none; font-weight: 600;
  font-size: 13px;
}
.contact-link:hover { color: var(--brand); text-decoration: underline; }

/* Description / remarks cells */
.td-desc .desc-text { color: var(--text); line-height: 1.4; }
.td-remarks .remarks-text { color: var(--text-muted); font-size: 13px; line-height: 1.4; }
.na { color: var(--text-light); font-size: 13px; }
.td-meta { font-size: 12px; color: var(--text-light); font-family: var(--font-mono); white-space: nowrap; }

/* Toolbar above table */
.list-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 16px;
}
.result-info { font-size: 13px; color: var(--text-muted); }

/* Contact filter pills */
.filter-pills {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 18px;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 99px;
  font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted);
  border: 1.5px solid var(--border-dark);
  text-decoration: none; transition: all .15s;
}
.pill:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }
.pill-active { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 4px; flex-wrap: wrap; gap: 10px;
  border-top: 1px solid var(--border); margin-top: 4px;
}
.page-info { font-size: 13px; color: var(--text-muted); }
.page-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* Top contacts sidebar widget */
.top-contacts-list { display: flex; flex-direction: column; gap: 12px; }
.tc-row {
  display: grid; grid-template-columns: 18px 30px 1fr 28px;
  align-items: center; gap: 8px;
}
.tc-rank { font-size: 11px; font-weight: 700; color: var(--text-light); text-align: center; font-family: var(--font-mono); }
.tc-info { min-width: 0; }
.tc-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-bar-wrap { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 4px; }
.tc-bar { height: 4px; background: var(--brand); border-radius: 2px; transition: width .4s; }
.tc-count { font-size: 12px; font-weight: 700; color: var(--brand); font-family: var(--font-mono); text-align: right; }

/* Responsive overrides */
@media (max-width: 900px) {
  .two-col-layout { grid-template-columns: 1fr; }
  .col-side { flex-direction: row; flex-wrap: wrap; }
  .col-side .card { flex: 1; min-width: 220px; }
}
/* ── Mobile entry cards (replaces table on narrow screens) ── */
.mobile-entry-list { display: none; }
.mobile-entry-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.mobile-entry-card:last-child { border-bottom: none; }
.mec-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.mec-date { flex-shrink: 0; }
.mec-contact { flex: 1; min-width: 0; overflow: hidden; }
.mec-actions { display: flex; gap: 6px; flex-shrink: 0; }
.mec-desc {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.mec-remarks {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

@media (max-width: 768px) {
  .table-wrap { display: none !important; }
  .mobile-entry-list { display: block !important; }
  .filter-pills { gap: 6px; }
  .pagination { flex-direction: column; align-items: flex-start; }
  .search-wrap input { width: 100% !important; }
}

/* ══════════════════════════════════════════════
   THEME SWITCHER — Light / Dark / System
══════════════════════════════════════════════ */
.theme-switcher { position: relative; }
.theme-switcher-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1.5px solid var(--border-dark);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 7px 11px; font-size: 14px; cursor: pointer;
  font-family: var(--font); transition: background .15s, border-color .15s;
}
.theme-switcher-btn:hover { background: var(--border); }
.theme-switcher-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  min-width: 150px; padding: 6px; z-index: 300;
}
.theme-switcher.open .theme-switcher-menu { display: block; }
.theme-switcher-option {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: left;
}
.theme-switcher-option:hover { background: var(--surface-2); }
.theme-switcher-option.active { background: var(--brand-light); color: var(--brand); font-weight: 700; }
.theme-switcher-option .ts-icon { font-size: 15px; width: 18px; text-align: center; }

/* Theme-aware emoji icons that need a light backdrop in dark mode */
[data-theme="dark"] img.emoji-bg { background: var(--surface-2); border-radius: 50%; }

/* ══════════════════════════════════════════════
   APPEARANCE PICKER — used on Profile page
══════════════════════════════════════════════ */
.appearance-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.appearance-option {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 100%; padding: 20px 12px;
  border: 1.5px solid var(--border-dark); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  font-family: var(--font); cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s, color .15s;
}
.appearance-option:hover { border-color: var(--brand); }
.appearance-option.active {
  border-color: var(--brand); background: var(--brand-light); color: var(--brand);
}
.appearance-icon { font-size: 28px; line-height: 1; }
.appearance-label { font-size: 13px; font-weight: 700; }
@media (max-width: 480px) {
  .appearance-grid { grid-template-columns: 1fr; }
}


