/* ============================================================
   Enterprise UI — ui.css
   Companion stylesheet untuk layouts/app.blade.php
   ============================================================ */

/* ============================================================
   DESIGN TOKENS — Ubah di sini untuk ganti tema global
   ============================================================ */
:root {
  --border-light:   #e2e8f0;
  --bg-body:        #f1f5f9;
  --bg-surface:     #ffffff;
  --bg-header:      #0f172a;
  --bg-hover:       #f8fafc;
  --bg-selected:    #eff6ff;
  --text-main:      #334155;
  --text-muted:     #64748b;
  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --danger:         #dc2626;
  --success:        #16a34a;
  --warning:        #d97706;
  --info:           #0891b2;
}

/* ============================================================
   BASE
   ============================================================ */
* { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  background: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  overflow: hidden;
}

/* ============================================================
   PANEL — Container dasar berupa kotak dengan border + shadow
   Penggunaan: <div class="panel"> ... </div>
   ============================================================ */
.panel {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.panel-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   HEADER — Top bar aplikasi
   ============================================================ */
.app-header {
  background: var(--bg-header);
  color: #fff;
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  flex-shrink: 0;
}
.app-header .brand { font-size: 15px; font-weight: 600; }
.app-header .brand-icon { color: #60a5fa; font-size: 18px; }
.app-header .header-right { margin-left: auto; display: flex; align-items: center; gap: 20px; font-size: 12px; }

/* ============================================================
   MENUBAR — Menu bar horizontal desktop-style
   ============================================================ */
.menubar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  height: 34px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.menu-group { position: relative; display: flex; align-items: center; }
.menu-item {
  padding: 4px 12px; cursor: pointer; border-radius: 4px;
  font-weight: 500; color: var(--text-main); transition: all 0.15s;
  user-select: none;
}
.menu-item:hover { background: var(--bg-body); color: #0f172a; }
.menu-dropdown {
  position: absolute; top: 100%; left: 0;
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: 6px; min-width: 200px; z-index: 9999;
  display: none; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  padding: 6px; margin-top: 4px;
}
/* Bridge transparan untuk menutup gap 4px antara trigger dan dropdown */
.menu-group:hover::after {
  content: ''; position: absolute; top: 100%; left: 0; right: 0;
  height: 8px; z-index: 9998;
}
.menu-group:hover .menu-dropdown { display: block; }
.menu-dropdown-item {
  padding: 6px 12px; cursor: pointer; display: flex;
  align-items: center; gap: 10px; border-radius: 4px; transition: background 0.15s;
}
.menu-dropdown-item:hover { background: var(--bg-body); }
.menu-dropdown-item.danger { color: var(--danger); }
.menu-dropdown-divider { height: 1px; background: var(--border-light); margin: 6px 0; }

/* ============================================================
   TABS — Tab navigation
   ============================================================ */
.tabs-header {
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-light);
  padding-left: 8px; padding-top: 6px;
  display: flex; gap: 4px; flex-shrink: 0;
}
.tab {
  padding: 6px 14px; background: transparent;
  border: 1px solid transparent; border-bottom: none;
  color: var(--text-muted); cursor: pointer; margin-bottom: -1px;
  border-top-left-radius: 6px; border-top-right-radius: 6px;
  font-weight: 500; transition: all 0.15s; display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.tab:hover:not(.active) { color: var(--text-main); background: rgba(255,255,255,0.5); }
.tab.active {
  background: var(--bg-surface); color: var(--primary);
  border: 1px solid var(--border-light); border-bottom: 1px solid var(--bg-surface);
  position: relative;
}
.tab.active::before {
  content: ''; position: absolute; top: -1px; left: -1px; right: -1px;
  height: 2px; background: var(--primary);
  border-top-left-radius: 6px; border-top-right-radius: 6px;
}
.tab .tab-close { font-size: 13px; opacity: 0.5; }
.tab .tab-close:hover { opacity: 1; }

/* ============================================================
   TOOLBAR — Baris aksi di atas datagrid
   ============================================================ */
.toolbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: 6px 8px;
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.toolbar-sep { width: 1px; height: 20px; background: var(--border-light); margin: 0 4px; }

/* ============================================================
   BUTTON VARIANTS
   Penggunaan: <button class="btn-ui primary">Simpan</button>
   ============================================================ */
.btn-ui {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent;
  padding: 4px 10px; border-radius: 4px; color: var(--text-main);
  cursor: pointer; font-weight: 500; font-size: 13px; transition: all 0.15s;
  white-space: nowrap;
}
.btn-ui:hover { background: var(--bg-body); color: #0f172a; }
.btn-ui:active { transform: translateY(1px); }
.btn-ui.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-ui.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ui.danger { color: var(--danger); }
.btn-ui.danger:hover { background: #fef2f2; }
.btn-ui.success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-ui.success:hover { background: #15803d; border-color: #15803d; }
.btn-ui.outline { border-color: var(--border-light); background: var(--bg-hover); }
.btn-ui.outline:hover { border-color: #94a3b8; background: #f1f5f9; }
.btn-ui.ghost { color: var(--text-muted); }
.btn-ui.ghost:hover { background: var(--bg-body); color: var(--text-main); }
.btn-ui:disabled, .btn-ui[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ============================================================
   FORM CONTROLS
   Penggunaan: <input class="form-ctrl" ...>
   ============================================================ */
.form-ctrl {
  border: 1px solid var(--border-light); border-radius: 4px;
  font-size: 13px; padding: 5px 9px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s; width: 100%;
  background: var(--bg-surface); color: var(--text-main);
}
.form-ctrl:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1); outline: 0;
}
.form-ctrl:read-only { background: var(--bg-hover); color: var(--text-muted); cursor: default; }
.form-ctrl.is-error { border-color: var(--danger); }
.form-ctrl.is-error:focus { box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }
.form-label { font-weight: 500; margin-bottom: 4px; display: block; }
.form-label .req { color: var(--danger); }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 3px; }
/* Form row 2-kolom: label kanan + input kiri */
.form-row { display: flex; align-items: flex-start; margin-bottom: 14px; }
.form-row .form-row-label {
  width: 160px; min-width: 160px; padding-top: 6px;
  text-align: right; padding-right: 14px; font-weight: 500; color: var(--text-muted);
}
.form-row .form-row-label .req { color: var(--danger); }
.form-row .form-row-control { flex: 1; }

/* ============================================================
   DATAGRID / TABLE
   ============================================================ */
.datagrid { border-collapse: separate; border-spacing: 0; width: 100%; }
.datagrid thead th {
  background: var(--bg-hover); border-bottom: 1px solid var(--border-light);
  font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  font-size: 11px; letter-spacing: 0.5px; padding: 8px 10px;
  position: sticky; top: 0; z-index: 1;
}
.datagrid tbody td {
  border-bottom: 1px solid var(--border-light);
  padding: 7px 10px; vertical-align: middle; color: var(--text-main);
}
.datagrid tbody tr:last-child td { border-bottom: none; }
.datagrid tbody tr { transition: background 0.1s; cursor: default; }
.datagrid tbody tr:hover td { background: var(--bg-hover); }
.datagrid tbody tr.row-selected td { background: var(--bg-selected); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-bar {
  background: var(--bg-surface); border-top: 1px solid var(--border-light);
  padding: 6px 10px; display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0;
}

/* ============================================================
   DIALOG / MODAL
   Penggunaan: App.dialog.open('myDialog')
   ============================================================ */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.4);
  backdrop-filter: blur(2px); z-index: 9990;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.2s;
}
.dialog-backdrop.show { opacity: 1; visibility: visible; }
.dialog {
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  transform: translateY(-16px); transition: transform 0.25s cubic-bezier(0.175,0.885,0.32,1.275);
}
.dialog-backdrop.show .dialog { transform: translateY(0); }
.dialog.sm  { width: 360px; }
.dialog.md  { width: 480px; }
.dialog.lg  { width: 680px; }
.dialog.xl  { width: 900px; }
.dialog-btnbar {
  background: var(--bg-hover); border-top: 1px solid var(--border-light);
  padding: 10px 16px; display: flex; justify-content: flex-end; gap: 8px;
}

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.confirm-dialog {
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: 8px; width: 360px; overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
  transform: scale(0.95); transition: transform 0.2s cubic-bezier(0.175,0.885,0.32,1.275);
}
.dialog-backdrop.show .confirm-dialog { transform: scale(1); }

/* ============================================================
   LOADING MASK
   Penggunaan: App.mask.show() / App.mask.hide()
   ============================================================ */
.loading-mask {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.75); backdrop-filter: blur(2px);
  z-index: 9998; display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.15s; border-radius: 6px;
}
.loading-mask.show { opacity: 1; visibility: visible; }
.loading-mask-msg {
  background: var(--bg-surface); padding: 10px 22px;
  border-radius: 30px; font-weight: 500;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}

/* ============================================================
   TOAST / NOTIFICATION
   Penggunaan: App.toast('Judul', 'Pesan', 'success|error|warning|info')
   ============================================================ */
.toast-container {
  position: fixed; bottom: 24px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--bg-surface); width: 300px;
  border: 1px solid var(--border-light);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.08);
  border-radius: 8px; overflow: hidden;
  animation: toastIn 0.3s cubic-bezier(0.175,0.885,0.32,1.275) forwards;
}
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-border { height: 3px; }
.toast-border.success { background: var(--success); }
.toast-border.error   { background: var(--danger); }
.toast-border.warning { background: var(--warning); }
.toast-border.info    { background: var(--info); }

/* ============================================================
   ALERT INLINE
   Penggunaan: <x-ui.alert type="success">Pesan</x-ui.alert>
   ============================================================ */
.alert-inline {
  border-radius: 6px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; border: 1px solid transparent;
}
.alert-inline.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-inline.error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-inline.warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-inline.info    { background: #f0f9ff; color: #075985; border-color: #bae6fd; }

/* ============================================================
   BADGE VARIANTS
   Penggunaan: <x-ui.badge type="success">Aktif</x-ui.badge>
   ============================================================ */
.badge-ui {
  display: inline-block; padding: 3px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.badge-ui.success { background: #dcfce7; color: #166534; }
.badge-ui.danger  { background: #fee2e2; color: #991b1b; }
.badge-ui.warning { background: #fef9c3; color: #854d0e; }
.badge-ui.info    { background: #e0f2fe; color: #075985; }
.badge-ui.neutral { background: #f1f5f9; color: #475569; }
.badge-ui.primary { background: #dbeafe; color: #1e40af; }
.badge-ui.purple  { background: #f3e8ff; color: #6b21a8; }
.badge-ui.dot::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; margin-right: 5px; vertical-align: middle;
  background: currentColor;
}

/* ============================================================
   TREE SIDEBAR
   ============================================================ */
.tree-node {
  border: 1px solid transparent; border-radius: 4px;
  transition: all 0.15s; margin-bottom: 1px;
  display: flex; align-items: center; padding: 6px 8px; cursor: pointer;
}
.tree-node:hover { background: var(--bg-hover); }
.tree-node.active { background: var(--bg-selected); color: var(--primary); font-weight: 500; }

/* ============================================================
   STAT CARD
   Penggunaan: <x-ui.stat-card label="Total" value="124" ...>
   ============================================================ */
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: 10px; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.stat-card.accent-blue   { border-left: 4px solid var(--primary); }
.stat-card.accent-green  { border-left: 4px solid var(--success); }
.stat-card.accent-amber  { border-left: 4px solid var(--warning); }
.stat-card.accent-purple { border-left: 4px solid #7c3aed; }
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #0f172a; line-height: 1.1; }
.stat-card .stat-delta { font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 2px; }
.stat-card .stat-delta.up   { color: var(--success); }
.stat-card .stat-delta.down { color: var(--danger); }
.stat-card .stat-delta.neutral { color: var(--text-muted); }
.stat-card .stat-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-card .stat-icon.blue   { background: #dbeafe; color: var(--primary); }
.stat-card .stat-icon.green  { background: #dcfce7; color: var(--success); }
.stat-card .stat-icon.amber  { background: #fef9c3; color: var(--warning); }
.stat-card .stat-icon.purple { background: #f3e8ff; color: #7c3aed; }
.stat-card .stat-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* ============================================================
   EMPTY STATE
   Penggunaan: <x-ui.empty-state icon="bi-inbox" title="..." desc="...">
   ============================================================ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 24px; text-align: center;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state .empty-title { font-weight: 600; color: var(--text-main); margin-bottom: 6px; font-size: 14px; }
.empty-state .empty-desc  { font-size: 12px; max-width: 260px; }

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  background: transparent; color: var(--text-muted); font-size: 11px;
  height: 28px; display: flex; align-items: center;
  justify-content: space-between; padding: 0 14px; flex-shrink: 0;
}

/* ============================================================
   SCROLLBAR CUSTOM
   ============================================================ */
.scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.scroll::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted-ui  { color: var(--text-muted); }
.fw-medium      { font-weight: 500; }
.cursor-pointer { cursor: pointer; }
.font-mono      { font-family: 'Courier New', monospace; }
.section-title  {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--text-muted); padding: 8px 8px 4px;
}
.sidebar-sep { height: 1px; background: var(--border-light); margin: 6px 8px; }

/* ============================================================
   HAMBURGER — Tombol pembuka sidebar di mobile
   ============================================================ */
.btn-hamburger {
  display: none;
  background: none; border: none; color: rgba(255,255,255,0.85);
  font-size: 22px; padding: 0 4px; cursor: pointer; line-height: 1;
  flex-shrink: 0;
}
.btn-hamburger:hover { color: #fff; }

/* ============================================================
   SIDEBAR BACKDROP
   ============================================================ */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9979;
  opacity: 0; visibility: hidden;
  transition: all 0.25s;
  pointer-events: none;
}
.sidebar-backdrop.show {
  opacity: 1; visibility: visible;
  pointer-events: auto;
}

/* ============================================================
   RESPONSIVE — Mobile (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  .btn-hamburger { display: flex; align-items: center; }
  .app-header { padding: 0 12px; gap: 8px; }
  .app-header .brand { font-size: 13px; }
  .app-header .header-right .user-info { display: none; }
  .menubar { display: none; }

  aside.panel {
    position: fixed !important;
    top: 0; bottom: 0; left: -250px;
    z-index: 9980;
    width: 240px !important;
    min-width: 240px !important;
    border-radius: 0 !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  aside.panel.mobile-open { left: 0; }

  .main-area { padding: 6px !important; gap: 6px !important; }
  .tabs-header { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
  .tabs-header::-webkit-scrollbar { height: 0; }
  .tab { flex-shrink: 0; }
  .toolbar { flex-wrap: wrap; row-gap: 4px; height: auto !important; min-height: 40px; }
  .datagrid { min-width: 560px; }

  .form-row { flex-direction: column; gap: 2px; }
  .form-row .form-row-label {
    width: auto !important; min-width: auto !important;
    text-align: left !important;
    padding-right: 0 !important; padding-top: 0 !important;
    padding-bottom: 2px;
  }

  .dialog.sm,
  .dialog.md,
  .dialog.lg,
  .dialog.xl { width: calc(100vw - 20px); max-height: 88vh; }
  .confirm-dialog { width: calc(100vw - 20px); }

  .pagination-bar { flex-direction: column; align-items: flex-start; gap: 6px; padding: 8px 10px; }

  .toast-container { left: 10px; right: 10px; bottom: 16px; }
  .toast { width: 100%; }

  .app-footer .footer-brand { display: none; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; }
  .tab-content.p-3 { padding: 10px !important; }
}
