/* ==========================================================================
   KAPROD WORKSPACE — REUSABLE COMPONENT SYSTEM (token-driven: dark & light)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. UTILITAS IKON SVG & AKSESIBILITAS
   -------------------------------------------------------------------------- */
svg.i {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--brand, #f59e0b);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   2. BUTTON SYSTEM
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-s, 8px);
  border: 1px solid var(--line-strong);
  background: var(--surface-2, #162033);
  color: var(--ink, #f1f5f9);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.btn:hover {
  background: var(--surface-3, #1e2a40);
  border-color: var(--line-strong);
}

.btn:active {
  transform: scale(0.97);
}

/* Varian Warna Tombol */
.btn-primary {
  background: var(--brand, #f59e0b);
  border-color: var(--brand, #f59e0b);
  color: var(--on-brand);
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2);
}
.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.btn-secondary {
  background: var(--surface-2, #162033);
  border-color: var(--line, #1b263b);
  color: var(--ink, #f1f5f9);
}
.btn-secondary:hover {
  background: var(--surface-3, #1e2a40);
  border-color: var(--line-strong, #2d3b55);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--err, #f87171);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: var(--err, #f87171);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2, #a3b0c4);
}
.btn-ghost:hover {
  background: var(--surface-2, #162033);
  color: var(--ink, #f1f5f9);
}

/* Ukuran Tombol */
.btn-lg { height: 44px; padding: 0 18px; font-size: 14px; border-radius: var(--r-m, 12px); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 11.5px; border-radius: 6px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 11px; border-radius: 5px; }

.btn-icon { width: 36px; padding: 0; flex-shrink: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-icon.btn-xs { width: 26px; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled, .btn.loading {
  opacity: 0.5;
  cursor: wait !important;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   3. FORM & INPUT CONTROLS
   -------------------------------------------------------------------------- */
.field {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink, #f1f5f9);
}

.field input, .field select, .field textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface, #0e1524);
  border: 1px solid var(--line-strong, #2d3b55);
  border-radius: var(--r-s, 8px);
  color: var(--ink, #f1f5f9);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 12px;
  resize: vertical;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand, #f59e0b);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.field-help {
  font-size: 11px;
  color: var(--ink-3, #6b7a92);
  margin-top: 4px;
}

.field.has-error input, .field.has-error select, .field.has-error textarea {
  border-color: var(--err, #ef4444);
}
.field.has-error .field-help { color: var(--err, #ef4444); }

.input-group {
  display: flex;
  align-items: center;
  width: 100%;
}
.input-group input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  flex: 1;
}
.input-group .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
}

.search-input {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong, #2d3b55);
  border-radius: var(--r-s, 8px);
  background: var(--bg, #080c14);
  color: var(--ink, #f1f5f9);
  width: 240px;
  font-size: 12.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus {
  outline: none;
  border-color: var(--brand, #f59e0b);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* --------------------------------------------------------------------------
   4. CARDS & KPI GRID (mengikuti tema lewat token)
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-m, 12px);
  padding: 18px;
  margin-bottom: var(--gap, 16px);
  box-shadow: var(--shadow);
  width: 100%;
  min-width: 0;
}

.card-title {
  font-family: var(--display, system-ui);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
  flex-wrap: wrap;
}

.card-header h2, .card-header h3 {
  font-family: var(--display, system-ui);
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--ink, #f1f5f9);
}

.card-body { flex: 1; }
.card-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.card-flat {
  box-shadow: none;
  background: var(--surface-2, #162033);
}

.card-interactive {
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.card-interactive:hover {
  transform: translateY(-2px);
  border-color: var(--brand, #f59e0b);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* KPI Box Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: var(--gap, 16px);
}

.kpi-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-m, 12px);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-3, #6b7a92);
  letter-spacing: 0.5px;
}

.kpi-value {
  font-family: var(--display, system-ui);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   5. DASHBOARD MODULE CARDS
   -------------------------------------------------------------------------- */
.modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.mod {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  background: var(--surface, #0e1524);
  border: 1px solid var(--line);
  border-radius: var(--r-m, 12px);
  padding: 16px;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.mod:hover {
  border-color: var(--brand, #f59e0b);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.mod-ic {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--brand-ink, #fbbf24);
  display: grid;
  place-items: center;
  transition: transform 0.2s ease;
}

.mod:hover .mod-ic {
  transform: scale(1.05);
}

.mod b {
  font-family: var(--display, system-ui);
  font-size: 14px;
  font-weight: 700;
  display: block;
}

.mod span {
  color: var(--ink-2, #a3b0c4);
  font-size: 12px;
  display: block;
  line-height: 1.4;
}

.nav-item.disabled, .mod.disabled {
  opacity: 0.45;
  cursor: not-allowed !important;
}
.nav-item.disabled:hover, .mod.disabled:hover {
  transform: none !important;
  background: transparent !important;
  border-color: var(--line) !important;
  box-shadow: none !important;
}

/* --------------------------------------------------------------------------
   6. SUB-NAVIGATION TABS
   -------------------------------------------------------------------------- */
.sub-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-m, 12px);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

@supports (scrollbar-width: none) {
  .sub-nav { scrollbar-width: none; }
}
.sub-nav::-webkit-scrollbar { display: none; }

.sub-nav-btn {
  border: none;
  background: transparent;
  color: var(--ink-2, #a3b0c4);
  padding: 6px 14px;
  border-radius: var(--r-s, 8px);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.sub-nav-btn:hover { color: var(--ink); background: var(--surface-2); }
.sub-nav-btn.active { background: var(--brand, #f59e0b); color: var(--on-brand); font-weight: 700; }

/* --------------------------------------------------------------------------
   7. CHIPS, BADGES & STATUS DOTS (Bersih, Transparan & Tidak Kusam)
   -------------------------------------------------------------------------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--line);
  border: 1px solid var(--line-strong);
  color: var(--ink-2, #a3b0c4);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.chip.brand { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.3); color: var(--brand-ink); }
.chip.ok    { background: rgba(16, 185, 129, 0.12);  border-color: rgba(16, 185, 129, 0.3);  color: var(--ok); }
.chip.err   { background: rgba(239, 68, 68, 0.12);   border-color: rgba(239, 68, 68, 0.3);   color: var(--err); }
.chip.warn  { background: rgba(245, 158, 11, 0.15);  border-color: rgba(245, 158, 11, 0.3);  color: var(--brand-ink); }
.chip.info  { background: rgba(59, 130, 246, 0.12);  border-color: rgba(59, 130, 246, 0.3);  color: var(--info); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

.badge-soon {
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--line-strong, #2d3b55);
  color: var(--ink-2, #a3b0c4);
  margin-left: auto;
  font-weight: 700;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   8. DATA TABLES
   -------------------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-m, 12px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
  min-width: 600px;
}

.data-table th {
  padding: 10px 14px;
  background: var(--surface-2, #162033);
  color: var(--ink-3, #6b7a92);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink, #f1f5f9);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }

/* --------------------------------------------------------------------------
   9. MEDIA & CAMERA PREVIEW
   -------------------------------------------------------------------------- */
.upload-box {
  border: 2px dashed var(--line-strong, #2d3b55);
  border-radius: var(--r-m, 12px);
  padding: 20px 16px;
  text-align: center;
  background: var(--bg, #080c14);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.upload-box:hover {
  border-color: var(--brand, #f59e0b);
  background: var(--surface-2, #162033);
}

.camera-preview-container {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 4/3;
  margin: 0 auto;
  border-radius: var(--r-m, 12px);
  overflow: hidden;
  background: #000000;
  border: 1px solid var(--line-strong, #2d3b55);
}
.camera-preview-container video, 
.camera-preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.progress-bar {
  width: 100%;
  height: 5px;
  background: var(--surface-2, #162033);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  background: var(--brand, #f59e0b);
  width: 0%;
  transition: width 0.2s ease;
}

/* --------------------------------------------------------------------------
   10. ALERTS & AVATARS
   -------------------------------------------------------------------------- */
.alert {
  padding: 10px 14px;
  border-radius: var(--r-m, 12px);
  font-size: 12.5px;
  line-height: 1.4;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
}
.alert-info { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.25); color: var(--info); }
.alert-warn { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.25); color: var(--brand-ink); }
.alert-err  { background: rgba(239, 68, 68, 0.12);  border-color: rgba(239, 68, 68, 0.25);  color: var(--err); }
.alert-ok   { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.25); color: var(--ok); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.15);
  color: var(--brand-ink, #fbbf24);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 44px; height: 48px; font-size: 15px; }

/* --------------------------------------------------------------------------
   11. TEXT & HELPER UTILITIES
   -------------------------------------------------------------------------- */
.text-brand  { color: var(--brand-ink, #fbbf24) !important; }
.text-ok     { color: var(--ok, #10b981) !important; }
.text-err    { color: var(--err, #ef4444) !important; }
.text-muted  { color: var(--ink-2, #a3b0c4) !important; }
.text-sub    { color: var(--ink-3, #6b7a92) !important; }

.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }

/* --------------------------------------------------------------------------
   12. RESPONSIVE MOBILE ADAPTATIONS
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .card { padding: 14px; }
  .card-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .search-input { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .modules { grid-template-columns: 1fr; }

  .hide-mobile { display: none !important; }
  .full-mobile { width: 100% !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}