/* ==========================================================
   Rimo Diary - stylesheet
   ========================================================== */

:root {
  --bg: #f3f6fd;
  --bg-glow-1: rgba(99, 102, 241, .14);
  --bg-glow-2: rgba(59, 130, 246, .14);
  --surface: #ffffff;
  --surface-2: #eaf0fb;
  --border: #dfe7f5;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #3b82f6;
  --primary-2: #6366f1;
  --primary-soft: #e3edff;
  --star: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: 0 12px 32px -14px rgba(30, 64, 175, .22);
  --radius: 20px;
  --ease: cubic-bezier(.2, .9, .3, 1.2);
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --bg-glow-1: rgba(129, 140, 248, .12);
  --bg-glow-2: rgba(96, 165, 250, .10);
  --surface: #111a2e;
  --surface-2: #172240;
  --border: #22304f;
  --text: #e2e8f5;
  --muted: #94a3b8;
  --primary: #60a5fa;
  --primary-2: #818cf8;
  --primary-soft: #1c2c52;
  --star: #fbbf24;
  --danger: #f87171;
  --shadow: 0 12px 32px -14px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background:
    radial-gradient(900px 480px at 100% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(800px 420px at -10% 110%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
button:disabled { cursor: not-allowed; opacity: .5; }
kbd {
  font: 700 .66rem/1 'Plus Jakarta Sans', sans-serif; padding: 4px 6px; border-radius: 6px;
  background: rgba(127,127,127,.14); border: 1px solid var(--border); color: var(--muted);
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- Ikon ---------- */
.ico { display: inline-grid; place-items: center; flex-shrink: 0; }
.ico svg, svg.ic {
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; display: block;
}
svg.ic.on { fill: currentColor; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 26px 22px; display: flex; flex-direction: column; gap: 24px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(14px);
  scrollbar-width: thin;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 44px; height: auto; flex-shrink: 0; filter: drop-shadow(0 8px 14px rgba(59,130,246,.3)); }
.brand h1 { font-size: 1.22rem; font-weight: 800; letter-spacing: -.02em; }
.brand p { font-size: .74rem; color: var(--muted); font-weight: 500; margin-top: 2px; }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 16px; border-radius: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 22px -10px rgba(59,130,246,.7);
  transition: transform .15s ease, filter .15s ease;
}
.btn-primary kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.25); color: #fff; margin-left: auto; }
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary:active { transform: scale(.98); }

.side-section h3 {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); font-weight: 700; margin-bottom: 12px;
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  position: relative; padding: 14px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; gap: 2px;
}
.stat .stat-ico { position: absolute; right: 12px; top: 12px; color: var(--primary); opacity: .75; }
.stat .stat-ico svg { width: 16px; height: 16px; }
.stat b { font-size: 1.3rem; font-weight: 800; }
.stat small { font-size: .7rem; color: var(--muted); font-weight: 600; }

.moods { display: flex; flex-direction: column; gap: 4px; }
.mood-filter {
  display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 14px;
  font-weight: 600; font-size: .9rem; color: var(--muted); text-align: left;
  transition: background .15s, color .15s;
}
.mood-filter:hover { background: var(--surface-2); color: var(--text); }
.mood-filter.active { background: var(--primary-soft); color: var(--primary); }
.mood-filter .count {
  margin-left: auto; font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2);
}
.mood-filter.active .count { background: var(--surface); }
.chip-ic {
  width: 32px; height: 32px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); flex-shrink: 0;
}
.chip-ic svg { width: 22px; height: 22px; display: block; }
.mood-filter.active .chip-ic { background: var(--surface); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud .empty-note { font-size: .8rem; color: var(--muted); }
.tag-chip {
  padding: 6px 11px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  transition: all .15s;
}
.tag-chip:hover { color: var(--primary); border-color: var(--primary); }
.tag-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tools { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool {
  display: flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 8px; border-radius: 14px;
  font-size: .78rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border);
  transition: transform .15s, border-color .15s, color .15s;
}
.tool:hover { transform: translateY(-2px); border-color: var(--primary); color: var(--primary); }

/* ---------- Main ---------- */
main { padding: 26px clamp(16px, 3.6vw, 46px) 60px; min-width: 0; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.greeting h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.greeting p { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.topbar-right { display: flex; gap: 10px; align-items: center; flex: 1; justify-content: flex-end; min-width: 0; }

.search {
  flex: 1; max-width: 420px; min-width: 200px; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 0 14px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.search .ico { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: none; background: transparent; padding: 13px 0; outline: none; }
.search input::placeholder { color: var(--muted); }
.search kbd { border: none; }

.mobile-only { display: none; }
.mobile-only.btn-primary { padding: 12px 14px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); transition: all .15s;
}
.chip svg { width: 15px; height: 15px; }
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--star) 16%, var(--surface)); color: var(--star); border-color: var(--star); }
.chip[aria-pressed="true"] svg { fill: currentColor; }

.active-filter {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 14px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-size: .85rem; font-weight: 700;
}
.chip-x {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--primary);
}
.chip-x svg { width: 14px; height: 14px; }

.sort {
  display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.sort select {
  appearance: none; background: transparent; border: none; outline: none; padding: 8px 4px;
  font-weight: 600; font-size: .85rem; color: var(--text); cursor: pointer;
}
.sort select option { background: var(--surface); color: var(--text); }

.result-count { font-size: .8rem; color: var(--muted); font-weight: 600; margin: 6px 2px 18px; }

.timeline { display: flex; flex-direction: column; gap: 26px; max-width: 880px; }
.day-label {
  font-size: .76rem; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .08em; margin-bottom: 12px; display: flex; align-items: center; gap: 12px;
}
.day-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.entries { display: grid; gap: 12px; }

.entry {
  position: relative; width: 100%; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; align-items: start;
  transition: transform .18s ease, border-color .18s ease;
  animation: rise .35s ease both;
}
.entry:hover { transform: translateY(-2px); border-color: var(--primary); }
.entry .emo {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2);
}
.entry .emo svg { width: 40px; height: 40px; display: block; }
.entry-head { display: flex; align-items: flex-start; gap: 8px; }
.entry h4 {
  flex: 1; min-width: 0; font-size: 1.02rem; font-weight: 700; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fav {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  color: var(--muted); transition: color .15s, background .15s, transform .15s;
}
.fav:hover { background: var(--surface-2); color: var(--star); transform: scale(1.08); }
.fav.on { color: var(--star); }
.fav svg { width: 17px; height: 17px; }
.preview {
  color: var(--muted); font-size: .9rem; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: .75rem; color: var(--muted); margin-top: 10px; font-weight: 600; }
.tag {
  padding: 2px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 700;
}

.empty {
  text-align: center; padding: 56px 20px; border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty .big {
  width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); margin-bottom: 6px;
}
.empty .big svg { width: 34px; height: 34px; }
.empty h3 { color: var(--text); font-size: 1.12rem; }
.empty .btn-ghost { margin-top: 8px; }

/* ---------- Overlay & dialog ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.overlay.open { display: flex; animation: fade .2s ease; }

.editor {
  width: min(660px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); border-radius: 26px; border: 1px solid var(--border);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.45);
  padding: 24px; display: flex; flex-direction: column; gap: 18px;
  animation: pop .25s var(--ease);
}
.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.editor-head h2 { font-size: 1.2rem; font-weight: 800; }
.editor-sub { font-size: .78rem; color: var(--muted); margin-top: 3px; min-height: 1em; }
.actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); transition: color .15s, background .15s, transform .15s;
}
.icon-btn:hover { color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.fav-btn.on { color: var(--star); }
.icon-btn.fav-btn.on svg { fill: currentColor; }
.icon-btn svg { width: 18px; height: 18px; }

label.lbl {
  display: block; font-size: .74rem; font-weight: 700; color: var(--muted);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em;
}
label.lbl .hint { text-transform: none; letter-spacing: 0; font-weight: 500; opacity: .8; }

.field {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  padding: 13px 15px; transition: border-color .15s, box-shadow .15s;
}
.field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.field:disabled { opacity: .7; }
textarea.field { min-height: 220px; resize: vertical; line-height: 1.7; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.mood-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.mood-opt {
  padding: 10px 4px 9px; border-radius: 16px; background: var(--surface-2); border: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: .68rem; font-weight: 700; color: var(--muted);
  transition: transform .15s, border-color .15s, background .15s, color .15s;
}
.mood-opt svg { width: 32px; height: 32px; display: block; }
.mood-opt:hover { transform: translateY(-2px); }
.mood-opt.sel { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wc { font-size: .8rem; color: var(--muted); font-weight: 600; }
.btn-ghost {
  padding: 12px 18px; border-radius: 14px; font-weight: 700; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); transition: border-color .15s;
}
.btn-ghost:hover { border-color: var(--primary); }
.btn-save {
  padding: 12px 22px; border-radius: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 22px -10px rgba(59,130,246,.7); transition: filter .15s, transform .15s;
}
.btn-save:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-danger {
  padding: 12px 18px; border-radius: 14px; font-weight: 700; color: #fff; background: var(--danger);
  transition: filter .15s;
}
.btn-danger:hover { filter: brightness(1.07); }

.confirm {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 26px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); animation: pop .25s var(--ease);
}
.confirm-ico {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); margin-bottom: 4px;
}
.confirm-ico svg { width: 26px; height: 26px; }
.confirm h3 { font-size: 1.1rem; font-weight: 800; }
.confirm p { color: var(--muted); font-size: .92rem; line-height: 1.5; }
.confirm .actions { margin-top: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 180%);
  display: flex; align-items: center; gap: 10px;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 14px;
  font-weight: 600; font-size: .9rem; box-shadow: 0 20px 40px -15px rgba(0,0,0,.4);
  transition: transform .35s var(--ease); z-index: 100; max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); }
.toast svg { width: 18px; height: 18px; color: var(--success); }
.toast.warn svg { color: var(--star); }

/* ---------- Animasi ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Responsif ---------- */
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border);
    padding: 18px; gap: 18px;
  }
  .stats-wrap { display: none; }
  .moods { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .mood-filter { white-space: nowrap; }
  .tag-cloud { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .tag-chip { white-space: nowrap; }
  .tools { margin-top: 0; grid-template-columns: repeat(4, 1fr); }
  .greeting { display: none; }
  .topbar-right { width: 100%; }
  .mobile-only { display: inline-flex; }
  .btn-primary#btnNew { display: none; }
}
@media (max-width: 560px) {
  main { padding: 18px 14px 50px; }
  .row { grid-template-columns: 1fr; }
  .mood-picker { grid-template-columns: repeat(3, 1fr); }
  .editor { padding: 20px; border-radius: 22px; }
  .entry { grid-template-columns: 46px minmax(0, 1fr); padding: 14px; gap: 12px; }
  .entry .emo { width: 46px; height: 46px; border-radius: 15px; }
  .entry .emo svg { width: 34px; height: 34px; }
  .sort { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
