/* TaxAI Indonesia — Playbook Viewer */

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

:root {
  --blue:      #0f2557;
  --blue-mid:  #1a3a7a;
  --blue-acc:  #2563eb;
  --blue-lt:   #e8edf8;
  --white:     #ffffff;
  --gray-50:   #f8f9fb;
  --gray-100:  #f0f2f7;
  --gray-200:  #e2e6ef;
  --gray-400:  #9aa3b8;
  --gray-600:  #5a6380;
  --gray-800:  #1e2540;
  --green:     #16a34a;
  --font:      'Inter', system-ui, sans-serif;
  --mono:      'JetBrains Mono', monospace;
  --sw:        300px;
  --radius:    8px;

  /* light mode tokens */
  --bg-main:       #ffffff;
  --bg-side:       #0f2557;
  --bg-content:    #f8f9fb;
  --bg-card:       #ffffff;
  --text-main:     #1e2540;
  --text-muted:    #5a6380;
  --text-faint:    #9aa3b8;
  --border:        #e2e6ef;
  --side-item-hover: rgba(255,255,255,0.07);
  --side-text:     rgba(255,255,255,0.78);
  --side-text-dim: rgba(255,255,255,0.4);
  --side-search-bg: rgba(255,255,255,0.09);
  --side-search-border: rgba(255,255,255,0.14);
}

[data-theme="dark"] {
  --bg-main:       #111827;
  --bg-side:       #0a1628;
  --bg-content:    #111827;
  --bg-card:       #1f2937;
  --text-main:     #f1f5f9;
  --text-muted:    #94a3b8;
  --text-faint:    #64748b;
  --border:        #374151;
  --blue-lt:       #1e3a5f;
  --gray-50:       #1f2937;
  --gray-100:      #253347;
  --gray-200:      #374151;
  --side-item-hover: rgba(255,255,255,0.06);
  --side-text:     rgba(255,255,255,0.82);
  --side-text-dim: rgba(255,255,255,0.35);
  --side-search-bg: rgba(255,255,255,0.07);
  --side-search-border: rgba(255,255,255,0.12);
}

html, body { height: 100%; font-family: var(--font); line-height: 1.6; }

body {
  display: flex; flex-direction: row;
  height: 100vh; overflow: hidden;
  background: var(--bg-main);
  color: var(--text-main);
  transition: background 0.2s, color 0.2s;
}

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sw); min-width: var(--sw);
  height: 100vh; background: var(--bg-side);
  display: flex; flex-direction: column;
  overflow: hidden; flex-shrink: 0;
  transition: background 0.2s;
}

.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.logo-icon svg { display: block; }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.logo-name { font-size: 16px; font-weight: 700; color: #fff; }
.logo-sub  { font-size: 10px; color: rgba(255,255,255,0.45); letter-spacing: 1px; text-transform: uppercase; }

/* Dark mode toggle */
#theme-toggle {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px; padding: 4px 8px; cursor: pointer;
  font-size: 14px; line-height: 1; color: #fff; flex-shrink: 0;
  transition: background 0.15s;
}
#theme-toggle:hover { background: rgba(255,255,255,0.18); }

.search-wrap { position: relative; margin: 14px 14px 0; }
#search-input {
  width: 100%; padding: 8px 32px 8px 12px;
  background: var(--side-search-bg);
  border: 1px solid var(--side-search-border);
  border-radius: 6px; color: #fff;
  font-family: var(--font); font-size: 13px; outline: none;
  transition: background 0.15s;
}
#search-input::placeholder { color: rgba(255,255,255,0.35); }
#search-input:focus { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: rgba(255,255,255,0.4);
  font-size: 12px; cursor: pointer; display: none; padding: 2px 4px;
}
.search-clear.visible { display: block; }

.pb-meta { padding: 10px 16px 6px; font-size: 11px; color: rgba(255,255,255,0.35); }
#pb-count { font-weight: 600; color: rgba(255,255,255,0.6); }

#pb-list { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
#pb-list::-webkit-scrollbar { width: 3px; }
#pb-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.pb-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 10px; border-radius: 6px; cursor: pointer;
  margin-bottom: 2px; border: 1px solid transparent;
  transition: background 0.12s; outline: none;
}
.pb-item:hover   { background: var(--side-item-hover); }
.pb-item.active  { background: var(--blue-acc); }
.pb-item:focus-visible { box-shadow: 0 0 0 2px rgba(255,255,255,0.4); }
.pb-item-id {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  color: var(--side-text-dim); padding-top: 2px; flex-shrink: 0; width: 38px;
}
.pb-item.active .pb-item-id { color: rgba(255,255,255,0.7); }
.pb-item-title { font-size: 13px; font-weight: 500; color: var(--side-text); line-height: 1.4; }
.pb-item.active .pb-item-title { color: #fff; font-weight: 600; }
.pb-no-result { color: rgba(255,255,255,0.35); font-size: 13px; padding: 20px 8px; text-align: center; }

/* ── MAIN PANEL ── */
#main-panel {
  flex: 1; min-width: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg-main);
  transition: background 0.2s;
}
#main-panel::-webkit-scrollbar { width: 4px; }
#main-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── STATE SCREENS ── */
.state-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; gap: 12px; padding: 40px 24px;
  text-align: center; color: var(--text-faint);
}
.state-icon { font-size: 40px; margin-bottom: 4px; }
.state-screen h2 { font-size: 17px; font-weight: 600; color: var(--text-muted); }
.state-screen p  { font-size: 14px; max-width: 340px; color: var(--text-faint); }

/* ── PLAYBOOK CONTENT ── */
#pb-content { max-width: 800px; margin: 0 auto; padding: 40px 48px 80px; }

.pb-header { margin-bottom: 36px; padding-bottom: 24px; border-bottom: 2px solid var(--blue-lt); }
.pb-badge-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }

.pb-id-badge {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  background: var(--blue); color: #fff; padding: 3px 8px; border-radius: 5px;
}
.pb-type-badge {
  font-size: 11px; font-weight: 500;
  background: var(--blue-lt); color: var(--blue-mid);
  padding: 3px 8px; border-radius: 5px; text-transform: capitalize;
}
[data-theme="dark"] .pb-type-badge { color: #93c5fd; }

.pb-difficulty { font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 5px; }
.difficulty-mudah    { background: #dcfce7; color: #166534; }
.difficulty-menengah { background: #fef9c3; color: #854d0e; }
.difficulty-sulit    { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .difficulty-mudah    { background: #14532d; color: #86efac; }
[data-theme="dark"] .difficulty-menengah { background: #713f12; color: #fde68a; }
[data-theme="dark"] .difficulty-sulit    { background: #7f1d1d; color: #fca5a5; }

#pb-title { font-size: 24px; font-weight: 700; color: var(--blue-acc); line-height: 1.3; margin-bottom: 12px; letter-spacing: -0.3px; }
[data-theme="dark"] #pb-title { color: #93c5fd; }

.pb-header-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.pb-header-actions h1 { margin-bottom: 0; }

.header-btns { display: flex; gap: 8px; flex-shrink: 0; }
.btn-icon {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted);
  font-family: var(--font); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-icon:hover { background: var(--blue-lt); border-color: var(--blue-acc); color: var(--blue-acc); }
[data-theme="dark"] .btn-icon:hover { background: #1e3a5f; }

.pb-module-row { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; }
.label-module { font-weight: 600; }
.dot { color: var(--text-faint); }

.pb-section { margin-bottom: 36px; }
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; color: var(--blue);
  text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 16px;
}
[data-theme="dark"] .section-title { color: #93c5fd; }
.section-num {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  background: var(--blue); color: #fff;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.objective-text {
  font-size: 14px; line-height: 1.7; color: var(--text-main);
  background: var(--gray-50); border-left: 3px solid var(--blue-acc);
  padding: 12px 16px; border-radius: 0 6px 6px 0;
}

.checklist { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.5; color: var(--text-main); }
.checklist li::before {
  content: ''; width: 16px; height: 16px; min-width: 16px;
  border: 2px solid var(--blue-acc); border-radius: 50%; margin-top: 2px;
}

/* ── TIMELINE ── */
.step-card { display: flex; gap: 16px; position: relative; }
.step-line { position: absolute; left: 15px; top: 32px; width: 2px; bottom: 0; background: var(--border); }
.step-num {
  width: 32px; height: 32px; min-width: 32px;
  background: var(--blue); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  position: relative; z-index: 1; flex-shrink: 0;
  transition: background 0.2s;
}
.step-card.done .step-num { background: var(--green); }
.step-body { flex: 1; padding-bottom: 24px; }
.step-meta { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.step-menu { font-size: 12px; font-weight: 600; color: var(--blue-acc); font-family: var(--mono); }
.step-page { font-size: 11px; color: var(--text-faint); }

.step-card-inner {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(15,37,87,0.06);
  transition: border-color 0.15s, background 0.2s;
}
.step-card.done .step-card-inner { border-color: #86efac; background: #f0fdf4; }
[data-theme="dark"] .step-card.done .step-card-inner { border-color: #166534; background: #052e16; }

.step-action-row { display: flex; flex-direction: column; gap: 8px; }
.step-row { display: flex; align-items: flex-start; gap: 8px; }
.step-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-faint); min-width: 44px; padding-top: 2px; }
.step-value { font-size: 13px; color: var(--text-main); line-height: 1.5; flex: 1; }
.step-expected { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-start; }
.step-expected .step-value { font-size: 13px; color: var(--text-muted); font-style: italic; }
.step-note { margin-top: 10px; padding: 8px 12px; background: #fffbeb; border-left: 3px solid #fcd34d; border-radius: 0 6px 6px 0; font-size: 12px; color: #78350f; line-height: 1.5; }
[data-theme="dark"] .step-note { background: #1c1508; color: #fde68a; border-left-color: #92400e; }

/* Step actions row (copy + check) */
.step-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.btn-copy, .btn-check {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 5px; border: 1px solid var(--border);
  background: transparent; color: var(--text-faint);
  font-family: var(--font); font-size: 11px; cursor: pointer;
  transition: all 0.15s;
}
.btn-copy:hover  { border-color: var(--blue-acc); color: var(--blue-acc); background: var(--blue-lt); }
.btn-check:hover { border-color: var(--green); color: var(--green); background: #f0fdf4; }
[data-theme="dark"] .btn-check:hover { background: #052e16; }
.btn-check.checked { border-color: var(--green); color: var(--green); background: #f0fdf4; font-weight: 600; }
[data-theme="dark"] .btn-check.checked { background: #052e16; }

/* ── PROGRESS BAR ── */
.progress-wrap { margin-bottom: 20px; }
.progress-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.3s ease; }

/* ── ERROR CARDS ── */
.error-card { border: 1px solid #fca5a5; background: #fff5f5; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
[data-theme="dark"] .error-card { border-color: #7f1d1d; background: #1a0808; }
.error-card-header { padding: 10px 14px; background: rgba(252,165,165,0.2); border-bottom: 1px solid #fca5a5; }
[data-theme="dark"] .error-card-header { border-bottom-color: #7f1d1d; }
.error-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: #991b1b; margin-bottom: 4px; }
.error-msg   { font-size: 13px; font-weight: 600; color: #991b1b; line-height: 1.4; }
[data-theme="dark"] .error-label, [data-theme="dark"] .error-msg { color: #fca5a5; }
.error-card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.error-cause, .error-solution { display: flex; flex-direction: column; gap: 3px; }
.error-cause .label, .error-solution .label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); }
.error-cause .val   { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.error-solution .val { font-size: 13px; color: var(--text-main); line-height: 1.5; font-weight: 500; }

/* ── SUCCESS ── */
.success-box { display: flex; align-items: flex-start; gap: 12px; background: #f0fdf4; border: 1px solid #86efac; border-radius: var(--radius); padding: 16px 18px; }
[data-theme="dark"] .success-box { background: #052e16; border-color: #166534; }
.success-icon { width: 26px; height: 26px; min-width: 26px; background: var(--green); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
#pb-success { font-size: 14px; line-height: 1.65; color: #14532d; }
[data-theme="dark"] #pb-success { color: #86efac; }

/* ── REFS & NOTES ── */
.ref-list, .note-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ref-list li { font-size: 13px; color: var(--text-muted); padding-left: 16px; position: relative; line-height: 1.5; }
.ref-list li::before { content: '→'; position: absolute; left: 0; color: var(--blue-acc); }
.note-list li { font-size: 13px; color: var(--text-muted); padding: 9px 12px; background: var(--gray-50); border-radius: 6px; border-left: 3px solid var(--border); line-height: 1.5; }

/* ── FOOTER ── */
.pb-footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); display: flex; gap: 10px; flex-wrap: wrap; }
.pb-footer strong { color: var(--text-muted); }


/* ── AI REPLY GENERATOR ── */
.ai-reply-wrap {
  margin-top: 20px;
  border: 1px solid var(--blue-lt);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}

.ai-reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--blue-lt);
  gap: 12px;
  flex-wrap: wrap;
}
[data-theme="dark"] .ai-reply-header {
  background: #1e3a5f;
}

.ai-reply-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  display: flex;
  align-items: center;
  gap: 8px;
}
[data-theme="dark"] .ai-reply-title { color: #93c5fd; }

.ai-reply-title span { font-size: 16px; }

.btn-generate {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--blue-acc);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn-generate:hover   { background: #1d4ed8; }
.btn-generate:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-reply-body { padding: 18px; display: none; }
.ai-reply-body.visible { display: block; }

.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0;
}
.ai-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--blue-acc);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-versions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-version-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ai-version-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .ai-version-header { background: #253347; }

.ai-version-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}

.btn-copy-reply {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-copy-reply:hover { border-color: var(--blue-acc); color: var(--blue-acc); }

.ai-version-text {
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-error {
  padding: 12px 14px;
  background: #fff5f5;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  font-size: 13px;
  color: #991b1b;
}
[data-theme="dark"] .ai-error { background: #1a0808; border-color: #7f1d1d; color: #fca5a5; }

@media print {
  .ai-reply-wrap { display: none !important; }
}

/* ── PRINT ── */
@media print {
  #sidebar, #sidebar-toggle, #sidebar-overlay, .header-btns, .step-footer, .progress-wrap { display: none !important; }
  body, #main-panel { display: block; height: auto; overflow: visible; }
  #pb-content { padding: 20px; max-width: 100%; }
  .step-card-inner { box-shadow: none; border: 1px solid #ccc; }
  #pb-title { color: #0f2557; }
}

/* ── MOBILE ── */
#sidebar-toggle {
  display: none; position: fixed; bottom: 20px; right: 20px;
  z-index: 200; width: 48px; height: 48px; border-radius: 50%;
  background: var(--blue); color: #fff; border: none; cursor: pointer;
  font-size: 20px; box-shadow: 0 4px 12px rgba(15,37,87,0.3);
}
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,37,87,0.4); z-index: 90; }
#sidebar-overlay.visible { display: block; }

@media (max-width: 768px) {
  body { overflow: auto; display: block; height: auto; }
  #sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transform: translateX(-100%); transition: transform 0.2s; }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(15,37,87,0.2); }
  #main-panel { height: auto; min-height: 100vh; overflow: visible; }
  #pb-content { padding: 24px 20px 80px; }
  #pb-title { font-size: 20px; }
  #sidebar-toggle { display: flex; align-items: center; justify-content: center; }
}
@media (max-width: 480px) { #pb-content { padding: 20px 16px 80px; } }
