/* css/style.css - Stylesheet for Rihlah Estimasi Biaya */

:root {
  --bg: #f8fafc;
  --bg-2: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-2: #cbd5e1;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;

  --accent: #0d9488;
  --accent-2: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-soft-2: #f0fdf4;

  --good: #10b981;
  --good-ink: #047857;
  --good-soft: #d1fae5;

  --warn: #f59e0b;
  --warn-ink: #b45309;
  --warn-soft: #fef3c7;

  --danger: #ef4444;
  --danger-soft: #fee2e2;

  --fixed: #1e3a8a;
  --var: #0284c7;

  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* TOPBAR */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.topbar-title h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.topbar-title p {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BUTTONS */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--ink);
  transition: all 0.15s ease;
  user-select: none;
}
button:hover,
.btn:hover {
  background: var(--bg-2);
  border-color: var(--muted-2);
}
button.primary,
.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
button.primary:hover,
.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
button.accent,
.btn.accent {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
}
button.accent:hover,
.btn.accent:hover {
  background: var(--accent);
}
button.danger,
.btn.danger {
  color: var(--danger);
  border-color: #fca5a5;
  background: #fff;
}
button.danger:hover,
.btn.danger:hover {
  background: var(--danger-soft);
}

/* LAYOUT */
.app-container {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 20px 24px;
}

/* CARDS & PANELS */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.card-head h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.card-head .icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.card-head .icon.teal {
  background: var(--accent-soft);
  color: var(--accent-2);
}
.card-head .icon.blue {
  background: var(--primary-soft);
  color: var(--primary);
}
.card-head .icon.amber {
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.card-head .icon.green {
  background: var(--good-soft);
  color: var(--good-ink);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* FIELDS & INPUTS */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s;
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-with-stepper {
  display: flex;
  align-items: center;
}
.field-with-stepper input {
  border-radius: 6px 0 0 6px;
}
.stepper-btns {
  display: flex;
  flex-direction: column;
}
.stepper-btns button {
  padding: 2px 8px;
  border-radius: 0;
  height: 18px;
  font-size: 10px;
  line-height: 1;
}
.stepper-btns button:first-child {
  border-radius: 0 6px 0 0;
}
.stepper-btns button:last-child {
  border-radius: 0 0 6px 0;
}

/* TABS */
.tabs-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* TABLES */
.items-wrap,
.peserta-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
}
#itemsTable,
#pesertaTable {
  min-width: 650px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th {
  background: var(--bg-2);
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tr:last-child td {
  border-bottom: none;
}
.type-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.type-badge.fix {
  background: #dbeafe;
  color: var(--fixed);
}
.type-badge.var {
  background: #e0f2fe;
  color: var(--var);
}

/* PREVIEW DOCUMENT */
.preview-toolbar {
  position: sticky;
  top: 61px;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -16px -16px 16px -16px;
}
.preview-scroll {
  padding: 16px;
  background: #cbd5e1;
  min-height: calc(100vh - 130px);
  border-radius: var(--radius);
  overflow-x: auto;
}
.doc {
  background: #fff;
  width: 100%;
  max-width: 794px;
  margin: 0 auto 24px auto;
  padding: 32px 36px;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
  color: #0f172a;
}
.pdf-export-mode,
.pdf-clone-render {
  width: 794px !important;
  max-width: 794px !important;
  min-width: 794px !important;
  padding: 30px 32px !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  background: #ffffff !important;
}
.pdf-export-mode .doc-table,
.pdf-clone-render .doc-table {
  width: 100% !important;
  min-width: 100% !important;
  font-size: 11px !important;
}
.pdf-export-mode .doc-table th,
.pdf-export-mode .doc-table td,
.pdf-clone-render .doc-table th,
.pdf-clone-render .doc-table td {
  padding: 6px 8px !important;
  font-size: 11px !important;
  white-space: normal !important;
}
.pdf-export-mode .doc-table-wrap,
.pdf-clone-render .doc-table-wrap {
  overflow: visible !important;
  width: 100% !important;
}
.pdf-export-mode .doc-page-break,
.pdf-clone-render .doc-page-break {
  border-top: none !important;
  margin-top: 0 !important;
  padding-top: 20px !important;
}
.doc h1 {
  font-size: 18px;
  text-align: center;
  margin-bottom: 4px;
  font-weight: 800;
}
.doc .sub-info {
  text-align: center;
  font-size: 11px;
  color: #475569;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.doc .sub-info .chip {
  background: var(--accent-soft);
  color: var(--accent-2);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
}
.doc h2 {
  font-size: 13px;
  margin: 18px 0 8px;
  color: var(--accent-2);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-bottom: 12px;
}
.doc-table th,
.doc-table td {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
}
.doc-table th {
  background: #f1f5f9;
}
.doc-page-break {
  page-break-before: always;
  break-before: page;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px dashed #cbd5e1;
}

@media print {
  .doc-page-break {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
  }
}

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
  .topbar {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .app-container {
    padding: 8px;
  }
  .preview-scroll {
    padding: 4px;
    background: transparent;
    border-radius: 0;
  }
  .doc:not(.pdf-clone-render) {
    padding: 12px 8px !important;
    width: 100% !important;
    box-shadow: none !important;
    font-size: 11px !important;
    border-radius: 8px;
  }
  .doc:not(.pdf-clone-render) h1 {
    font-size: 14px !important;
  }
  .doc:not(.pdf-clone-render) h2 {
    font-size: 12px !important;
  }
  .doc:not(.pdf-clone-render) .doc-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
  }
  .doc:not(.pdf-clone-render) table.doc-table {
    width: 100% !important;
    min-width: 500px;
    font-size: 10px !important;
  }
  .doc:not(.pdf-clone-render) table.doc-table th,
  .doc:not(.pdf-clone-render) table.doc-table td {
    padding: 4px 6px !important;
    white-space: normal !important;
  }
}

/* TOAST & OVERLAY */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.25s;
  z-index: 999;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 998;
  display: none;
  align-items: center;
  justify-content: center;
}
.overlay.show {
  display: flex;
}
.overlay .spinner {
  background: #fff;
  padding: 20px 28px;
  border-radius: 10px;
  font-weight: 600;
}

/* MODAL STYLES */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.show {
  display: flex;
}
.modal-card {
  background: #fff;
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
}
.modal-head h3 {
  font-size: 14px;
  font-weight: 700;
}
.modal-body {
  padding: 18px;
}
.modal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.option-item:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.option-item input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.option-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
}
.option-desc {
  font-size: 11px;
  color: var(--muted);
}
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-2);
}
