/* ========================================
   DCP ERP — Light Theme
   ======================================== */

:root {
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --green: #10b981;
  --green-bg: #d1fae5;
  --amber: #f59e0b;
  --amber-bg: #fef3c7;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.14);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar (dark, kontras dengan konten terang) ---------- */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  padding: 24px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .logo {
  padding: 0 24px 24px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}
.sidebar .logo span { color: var(--blue-500); }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.18s;
  cursor: pointer;
}
.sidebar nav a:hover {
  color: #fff;
  background: var(--sidebar-hover);
}
.sidebar nav a.active {
  color: #fff;
  background: var(--blue-600);
  box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}
.sidebar nav a i { width: 20px; text-align: center; font-size: 0.95rem; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 24px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.75rem;
  color: #64748b;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
  max-width: 100%;
}
.main h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.main .subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 28px;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.page-head h1 { margin-bottom: 6px; }
.page-head .subtitle { margin-bottom: 0; }

/* ---------- Template Industri ---------- */
.template-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  border: 1px solid #dbeafe;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.template-info {
  display: flex;
  align-items: center;
  gap: 14px;
}
.template-info > i {
  font-size: 1.3rem;
  color: var(--accent);
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 10px 12px;
}
.template-info strong {
  display: block;
  font-size: 0.94rem;
  margin-bottom: 2px;
}
.template-info span {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.template-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.template-actions select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  min-width: 190px;
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--blue-500);
}
.stat-card.green::before { background: var(--green); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.red::before { background: var(--red); }

.stat-card .label {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.stat-card .value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.stat-card .hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 8px;
}

/* ---------- Card / Table Container ---------- */
.table-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
/* Pembungkus agar tabel bisa digeser horizontal di layar kecil */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll table { min-width: max(100%, 620px); }
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.table-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
}
.table-header .header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 24px; text-align: left; font-size: 0.86rem; }
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
td { border-bottom: 1px solid #f1f5f9; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: #f8fafc; }
tr:last-child td { border-bottom: none; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 40px 24px; }

/* ---------- Charts ---------- */
.charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
.chart-card { margin-bottom: 0; }
.chart-body {
  padding: 20px 24px;
  height: 300px;
  position: relative;
}

@media (max-width: 900px) {
  .charts { grid-template-columns: 1fr; }
}

/* ---------- Report Filters ---------- */
.report-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 8px 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
}
.filter-btn:hover { border-color: var(--blue-500); color: var(--blue-600); }
.filter-btn.active {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .report-grid { grid-template-columns: 1fr; }
}

/* ---------- Status Badge ---------- */
.status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.74rem;
  font-weight: 700;
}
.status.selesai  { background: var(--green-bg); color: #047857; }
.status.diproses { background: var(--amber-bg); color: #b45309; }
.status.dibatalkan { background: var(--red-bg); color: #b91c1c; }
.status.low { background: var(--red-bg); color: #b91c1c; }
.status.ok  { background: var(--green-bg); color: #047857; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 18px;
  height: 38px;
  background: var(--blue-600);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.18s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { background: var(--blue-700); }
.btn:active { transform: scale(0.97); }
.btn.sm { padding: 0 11px; height: 32px; font-size: 0.78rem; border-radius: 7px; }
.btn.danger { background: var(--red-bg); color: #b91c1c; }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.success { background: var(--green-bg); color: #047857; }
.btn.success:hover { background: var(--green); color: #fff; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(3px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s cubic-bezier(0.16,1,0.3,1);
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

/* ---------- Form ---------- */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-group { margin-bottom: 18px; }
.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -8px 0 16px;
  min-height: 1em;
}
.form-hint.pos { color: var(--green); }
.form-group label {
  display: block;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 7px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}

/* ---------- Search ---------- */
.search-input {
  padding: 0 14px;
  height: 38px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  width: 220px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}

/* ---------- Invoice ---------- */
.invoice-modal { max-width: 640px; }
.invoice-body {
  padding: 32px;
  color: #0f172a;
  background: #fff;
}
.invoice-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #2563eb;
  padding-bottom: 20px;
  margin-bottom: 24px;
}
.invoice-head .brand {
  font-size: 1.5rem;
  font-weight: 800;
  color: #2563eb;
  letter-spacing: -0.5px;
}
.invoice-head .brand-sub {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 4px;
}
.invoice-head .doc-title {
  text-align: right;
}
.invoice-head .doc-title h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
}
.invoice-head .doc-title .doc-id {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 4px;
}
.invoice-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.invoice-meta .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 6px;
}
.invoice-meta .value { font-size: 0.92rem; font-weight: 600; color: #0f172a; }
.invoice-meta .value.small { font-weight: 400; color: #475569; font-size: 0.85rem; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.invoice-table th {
  background: #f1f5f9;
  padding: 10px 12px;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
}
.invoice-table td {
  padding: 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid #f1f5f9;
}
.invoice-table th:last-child,
.invoice-table td:last-child { text-align: right; }
.invoice-total {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  padding-top: 12px;
  border-top: 2px solid #0f172a;
}
.invoice-total .label { font-size: 0.9rem; color: #64748b; }
.invoice-total .value { font-size: 1.2rem; font-weight: 800; color: #0f172a; }
.invoice-note {
  margin-top: 20px;
  padding: 12px 16px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #92400e;
  line-height: 1.5;
}
.invoice-foot {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 0.78rem;
  color: #94a3b8;
  text-align: center;
}
.invoice-status {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 8px;
}
.invoice-status.selesai { background: #d1fae5; color: #047857; }
.invoice-status.diproses { background: #fef3c7; color: #b45309; }
.invoice-status.dibatalkan { background: #fee2e2; color: #b91c1c; }

/* ---------- Print ---------- */
@media print {
  body * { visibility: hidden; }
  #modal-invoice, #modal-invoice * { visibility: visible; }
  #modal-invoice {
    position: absolute;
    inset: 0;
    background: #fff;
    display: block !important;
    padding: 0;
  }
  .no-print { display: none !important; }
  .modal {
    box-shadow: none;
    max-height: none;
    border-radius: 0;
    max-width: 100%;
  }
  .invoice-body { padding: 0; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #fff;
  border-left: 4px solid var(--green);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
  align-items: center;
  gap: 10px;
}
.toast.show { display: flex; animation: slideUp 0.2s ease; }
.toast.error { border-left-color: var(--red); }
.toast i.success { color: var(--green); }
.toast i.error { color: var(--red); }

/* ---------- Page ---------- */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

/* ---------- Menu Toggle (mobile) ---------- */
.menu-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--blue-600);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 120; /* harus di atas sidebar agar bisa diklik untuk menutup */
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}

/* Latar gelap saat sidebar terbuka di mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 90;
  border: none;
  cursor: pointer;
}
.sidebar-backdrop.show { display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .main { padding: 24px 20px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    z-index: 100;
    transition: left 0.25s ease;
    height: 100vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .menu-toggle { display: flex; }
  .search-input { width: 100%; }
  .table-header { flex-direction: column; align-items: stretch; }
  .table-header .header-actions { width: 100%; }
  .table-header .header-actions .btn { flex: 1; justify-content: center; }
  th, td { padding: 11px 16px; }
  .main { padding: 20px 16px 90px; }
  .main h1 { font-size: 1.4rem; }
  .template-bar { flex-direction: column; align-items: stretch; }
  .template-actions { flex-direction: column; }
  .template-actions select, .template-actions .btn { width: 100%; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
}
