/* =========================================================
   PENGATURAN TEMA & WARNA E-OFFICE (CSS VARIABLES)
   Pemula dapat mengubah warna utama di blok :root ini saja
   ========================================================= */
:root {
  --primary: #1e3a8a;        /* Biru tua elegan sesuai struktur E-Office */
  --primary-light: #2563eb;
  --primary-soft: #dbeafe;
  --sidebar-bg: #0f172a;     /* Sidebar gelap modern */
  --sidebar-hover: #1e293b;
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;

  --success: #16a34a;
  --warning: #eab308;
  --danger: #dc2626;
  --info: #0891b2;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* =========================================================
   HALAMAN LOGIN & FORGOT PASSWORD
   ========================================================= */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}

.auth-card {
  width: 100%;
  max-width: 540px;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

.demo-roles-box {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.demo-role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

/* =========================================================
   LAYOUT UTAMA DASHBOARD (SIDEBAR + TOPBAR + KONTEN)
   ========================================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 265px;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  padding: 10px 10px 4px;
  font-weight: 700;
}

.nav-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: #cbd5e1;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--primary-light);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #1e293b;
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-search {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-body);
}

.topbar-search input {
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: 0.82rem;
  outline: none;
  width: 190px;
}

.topbar-search button {
  border: none;
  background: var(--primary-light);
  color: #fff;
  padding: 0 10px;
  cursor: pointer;
}

.app-content {
  padding: 20px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

.mobile-menu-btn,
.mobile-only {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 55;
}

/* =========================================================
   KOMPONEN KARTU, GRID, TOMBOL, TABEL & STATUS DOKUMEN
   ========================================================= */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-card small {
  color: var(--text-muted);
  font-weight: 600;
}

.stat-card strong {
  display: block;
  font-size: 1.4rem;
  margin-top: 4px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: #d97706; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
}

.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-block { width: 100%; }

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.15rem;
  padding: 4px 8px;
}

.form-group { margin-bottom: 12px; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.86rem;
  font-family: inherit;
  background: #fff;
}

textarea.form-control { min-height: 76px; resize: vertical; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }

th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th { background: #f8fafc; font-weight: 700; white-space: nowrap; }

/* 6 Status Dokumen Resmi Sesuai Struktur E-Office */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
}

.status-draft { background: #e2e8f0; color: #475569; }       /* Abu-abu */
.status-submitted { background: #dbeafe; color: #1d4ed8; }   /* Biru */
.status-reviewed { background: #fef08a; color: #854d0e; }    /* Kuning */
.status-approved { background: #dcfce7; color: #166534; }    /* Hijau */
.status-completed { background: #cffafe; color: #0e7490; }   /* Teal */
.status-rejected { background: #fee2e2; color: #991b1b; }    /* Merah */

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-fill {
  height: 100%;
  background: var(--primary-light);
}

/* =========================================================
   BAGAN STRUKTUR ORGANISASI & ALUR APPROVAL WORKFLOW
   ========================================================= */
.org-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.org-md-box {
  background: #1e3a8a;
  color: #fff;
  padding: 12px 28px;
  border-radius: 10px;
  text-align: center;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.org-divisions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

.org-col {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}

.org-col-head {
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.84rem;
  text-align: center;
  margin-bottom: 10px;
}

.org-sub-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.8rem;
  margin-bottom: 6px;
  text-align: center;
}

.workflow-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.workflow-step {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.workflow-step.done {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

/* =========================================================
   MODAL, SURAT BARCODE & TOAST
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-dialog {
  background: var(--bg-card);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
}

.modal-body { padding: 18px; }

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.letter-sheet {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  background: #fff;
}

.barcode-stamp {
  border: 2px dashed var(--primary-light);
  border-radius: 10px;
  padding: 10px;
  display: inline-flex;
  background: #f8fafc;
}

/* =========================================================
   RESPONSIF HP & TABLET
   ========================================================= */
@media (max-width: 1024px) {
  .grid-4, .org-divisions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -270px;
    transition: left 0.2s ease;
  }
  .sidebar.open { left: 0; }
  .mobile-menu-btn, .mobile-only {
    display: inline-flex;
    border: 1px solid var(--border);
    background: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
  }
  .sidebar-header .mobile-only { background: transparent; border: none; }
  .grid-4, .grid-3, .grid-2, .org-divisions, .demo-role-grid {
    grid-template-columns: 1fr;
  }
  .topbar-search input { width: 130px; }
  .app-content { padding: 14px; }
}
