/* ===========================
   Konter UI – Pro v2 (2025)
   Modern, rapih, aksesibel
   =========================== */

/* ---------- Tokens ---------- */
:root {
  /* Surfaces & text */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  /* Brand */
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff6ff;

  /* Status */
  --success: #16a34a;
  --warning: #d97706;
  --danger:  #dc2626;
  --info:    #0891b2;

  /* Ramps */
  --ring: rgba(37, 99, 235, .28);
  --shadow: 0 10px 30px rgba(2, 6, 23, .08);
  --shadow-2: 0 18px 50px rgba(2, 6, 23, .12);

  /* Radii & spacing */
  --r-md: 12px;
  --r-lg: 16px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #0f172a;
    --surface-2: #0b1326;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #1f2a44;

    --primary: #60a5fa;
    --primary-600: #3b82f6;
    --primary-50: #0b1220;

    --ring: rgba(96, 165, 250, .32);
    --shadow: 0 10px 30px rgba(0,0,0,.45);
    --shadow-2: 0 20px 60px rgba(0,0,0,.55);

    color-scheme: dark;
  }
}

/* Force dark secara manual */
.theme-dark {
  --bg: #0b1220;
  --surface: #0f172a;
  --surface-2: #0b1326;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #1f2a44;
  --primary: #60a5fa;
  --primary-600: #3b82f6;
  --primary-50: #0b1220;
  --ring: rgba(96, 165, 250, .32);
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --shadow-2: 0 20px 60px rgba(0,0,0,.55);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(37,99,235,.06), transparent 60%),
    radial-gradient(1000px 500px at -10% 20%, rgba(8,145,178,.06), transparent 60%),
    var(--bg);
  margin: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  accent-color: var(--primary);
}
::selection { background: rgba(37,99,235,.18); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Scrollbar (WebKit) */
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.theme-dark *::-webkit-scrollbar-thumb { background: #334155; }

/* SR only */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display:flex; align-items:center; justify-content:space-between;
  max-width: 1120px; margin: 0 auto; padding: 14px 20px;
}
header h1 { font-size: 18px; margin: 0; letter-spacing:.2px; }
nav a { margin-right: 12px; padding: 6px 10px; border-radius: 8px; }
nav a:hover, nav a.is-active, nav a[aria-current="page"] {
  background: var(--primary-50); text-decoration: none;
}

main { max-width: 1120px; margin: 24px auto; padding: 0 20px; }

/* ---------- Grid System ---------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--sp-4); align-items: start; }
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-7  { grid-column: span 7; }
.col-6  { grid-column: span 6; }
.col-5  { grid-column: span 5; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

@media (max-width: 900px) {
  .col-8, .col-7, .col-6, .col-5, .col-4, .col-3 { grid-column: span 12; }
}

/* Preset layout cepat */
.kpi-grid   { display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--sp-4); }
.duo-grid   { display:grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.split-grid { display:grid; grid-template-columns: 7fr 5fr; gap: var(--sp-4); }
@media (max-width: 900px){
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .duo-grid, .split-grid { grid-template-columns: 1fr; }
}

/* Hapus margin top saudara card di dalam grid agar rapi */
.grid .card { margin-top: 0 !important; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  transition: box-shadow .2s ease, transform .06s ease, border-color .2s ease;
}
.card-hover:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card + .card { margin-top: var(--sp-4); }
.card-hero {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
}

/* Toolbar */
.k-toolbar{ display:flex; align-items:center; justify-content:space-between; gap:var(--sp-4); }
.k-actions{ display:flex; gap:var(--sp-2); flex-wrap:wrap; }

/* Highlight */
.k-highlight{ position:relative; overflow:hidden; background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.k-h-label{ font-size:12px; letter-spacing:.2px; color:var(--muted); }
.k-h-value{ font-size:28px; font-weight:800; margin-top:4px; }
.k-h-sub{ font-size:12px; margin-top:2px; color:var(--muted); }
.k-spark{ margin-top:8px; }
.k-h-dates{ display:flex; justify-content:space-between; }

/* ---------- Typography ---------- */
.muted { color: var(--muted); }
.h3 { font-size: 20px; margin: 0 0 8px; }
.h4 { font-size: 16px; margin: 14px 0 8px; }

/* ---------- Forms ---------- */
label { display:block; margin: 12px 0 6px; font-weight: 600; }
input, textarea, select {
  width: 100%; max-width: 520px; padding: 10px 12px;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); outline: none;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: var(--primary-600); box-shadow: 0 0 0 4px var(--ring);
}
input[readonly], input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2); color: var(--muted); cursor: not-allowed;
}
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); max-width: 980px; }
@media (max-width: 720px){ .form-row { grid-template-columns: 1fr; } }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.input-group { display:flex; align-items:stretch; max-width: 520px; }
.input-group > input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group > .btn { border-radius: 0 var(--r-md) var(--r-md) 0; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button{ -webkit-appearance: none; margin: 0; }
input[type="number"]{ -moz-appearance: textfield; }

/* === Field dengan ikon & tombol peek (rapi & center) === */
.field { margin-top: 12px; }
.field .control { position: relative; }
.field .control input{
  height: 44px;
  line-height: 44px;
  padding-left: 42px;  /* ruang ikon kiri */
  padding-right: 42px; /* ruang tombol kanan */
}
.field .control .field-icon{
  position:absolute; left:12px; top:50%; transform: translateY(-50%);
  pointer-events:none; opacity:.55;
}
.field .control .peek{
  position:absolute; right:6px; top:50%; transform: translateY(-50%);
  width:36px; height:36px; border-radius:10px; border:0; background:transparent; cursor:pointer;
}
.field .control .peek:hover{ background: var(--primary-50); }

/* Switch / Toggle */
.switch { position: relative; width: 46px; height: 26px; display:inline-block; }
.switch input { opacity:0; width:0; height:0; }
.slider { position:absolute; cursor:pointer; inset:0; background:#cbd5e1; border-radius:999px; transition: .2s; }
.slider:before {
  content:""; position:absolute; height:20px; width:20px; left:3px; top:3px;
  background:#fff; border-radius:50%; transition:.2s; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ---------- Buttons ---------- */
button, .btn {
  display:inline-flex; align-items:center; justify-content:center; gap: var(--sp-2);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 14px; border-radius: var(--r-md); cursor: pointer;
  transition: transform .05s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  box-shadow: 0 2px 0 rgba(2,6,23,.04);
}
button:hover, .btn:hover { background: var(--primary-50); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
.btn:disabled, button:disabled { opacity:.6; cursor:not-allowed; }

.btn-primary { background: var(--primary); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--primary-600); }

.btn-outline { background: transparent; border-color: var(--primary-600); color: var(--primary-600); }
.btn-outline:hover { background: var(--primary-50); }

.btn-ghost { background: transparent; }
.btn-danger  { background: var(--danger); border-color: transparent; color:#fff; }
.btn-success { background: var(--success); border-color: transparent; color:#fff; }
.btn-warning { background: var(--warning); border-color: transparent; color:#fff; }
.btn-link { background: transparent; border-color: transparent; color: var(--primary); padding: 0; }

.btn-sm { padding: 6px 10px; border-radius: 10px; font-size: 14px; }
.btn-icon { width:38px; height:38px; padding:0; display:inline-flex; align-items:center; justify-content:center; }

/* Loading Spinner */
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tables ---------- */
.table-wrap { overflow:auto; border-radius: var(--r-md); border:1px solid var(--border); background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 720px; background: var(--surface); }
th, td { padding: 12px 12px; border-bottom: 1px solid var(--border); }
th {
  text-align: left; font-weight: 700; font-size: 13px; color: var(--muted); letter-spacing:.2px;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
tbody tr:hover { background: rgba(2,6,23,.03); }
@media (prefers-color-scheme: dark) { tbody tr:hover { background: rgba(255,255,255,.04); } }
.table-compact th, .table-compact td { padding: 8px 10px; }
.table-clickable tbody tr { cursor:pointer; }
.table-empty { color: var(--muted); text-align:center; padding: 24px; }
.nowrap { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display:inline-flex; align-items:center; gap:6px;
  padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent;
}
.badge-dot::before { content: ""; width:8px; height:8px; border-radius:999px; display:inline-block; background: currentColor; }
.badge-masuk              { color:#1e293b; background:#e2e8f0; }
.badge-dalam_perbaikan    { color:#0ea5e9; background:#e0f2fe; }
.badge-menunggu_sparepart { color:#d97706; background:#fef3c7; }
.badge-siap_diambil       { color:#2563eb; background:#dbeafe; }
.badge-selesai            { color:#16a34a; background:#dcfce7; }
.badge-batal              { color:#475569; background:#e2e8f0; text-decoration: line-through; }
.badge-gagal              { color:#dc2626; background:#fee2e2; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 14px; border-radius: var(--r-md); border:1px solid var(--border);
  background: var(--surface); display:flex; gap:10px; align-items:flex-start;
}
.alert-success { border-color: color-mix(in oklab, var(--success) 35%, transparent); background: color-mix(in oklab, var(--success) 10%, transparent); }
.alert-warning { border-color: color-mix(in oklab, var(--warning) 35%, transparent); background: color-mix(in oklab, var(--warning) 12%, transparent); }
.alert-danger  { border-color: color-mix(in oklab, var(--danger)  35%, transparent); background: color-mix(in oklab, var(--danger)  10%, transparent); }
.alert-info    { border-color: color-mix(in oklab, var(--info)    35%, transparent); background: color-mix(in oklab, var(--info)    10%, transparent); }

/* ---------- KPI Cards ---------- */
.kpi{ display:flex; align-items:center; gap:12px; position:relative; min-height: 106px; }
.kpi-icon{ width:40px; height:40px; border-radius:10px; display:flex; align-items:center; justify-content:center; color:#fff; }
.kpi-blue{ background: linear-gradient(135deg,#2563eb,#60a5fa); }
.kpi-indigo{ background: linear-gradient(135deg,#4f46e5,#818cf8); }
.kpi-emerald{ background: linear-gradient(135deg,#059669,#34d399); }
.kpi-amber{ background: linear-gradient(135deg,#d97706,#f59e0b); }
.kpi-meta{ flex:1; min-width: 0; }
.kpi-label{ font-size:12px; color:var(--muted); }
.kpi-value{ font-size:22px; font-weight:800; }
.kpi-link{ font-size:12px; padding:6px 10px; border-radius:8px; border:1px solid var(--border); }

/* ---------- Tiles (Quick Actions & Catalog) ---------- */
.tiles{ display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.tile{
  display:flex; align-items:center; gap:10px; padding:12px; border:1px solid var(--border);
  border-radius:14px; background:var(--surface); box-shadow: var(--shadow);
  transition: background .15s ease, transform .06s ease, border-color .2s ease;
}
.tile:hover{ background: var(--primary-50); text-decoration:none; transform: translateY(-1px); }
.tile-icon{ font-size:18px; }
.tile-text{ font-weight:600; }

/* ---------- Sparkline ---------- */
.spark { display:block; width:100%; height:auto; }

/* ---------- Tabs ---------- */
.tabs { display:flex; gap:var(--sp-2); flex-wrap:wrap; border-bottom:1px solid var(--border); margin-bottom: var(--sp-3); }
.tab {
  padding:8px 12px; border:1px solid transparent; border-bottom:2px solid transparent;
  border-radius:12px 12px 0 0; color:var(--muted); cursor:pointer;
}
.tab:hover { background: var(--primary-50); color: var(--text); }
.tab-active { color: var(--text); border-bottom-color: var(--primary); }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { display:flex; flex-wrap:wrap; gap:6px; font-size: 13px; color:var(--muted); }
.breadcrumbs a { color: inherit; }
.breadcrumbs .sep { opacity:.5; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,.45); display:none; align-items:center; justify-content:center; padding:16px; z-index: 50;
}
.modal-backdrop.show { display:flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  width: 100%; max-width: 520px; padding: 18px;
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display:flex; flex-direction:column; gap:8px; z-index: 60; }
.toast { background: var(--surface); border:1px solid var(--border); border-radius:var(--r-md); padding:10px 12px; box-shadow: var(--shadow); }
.toast-success{ border-color: color-mix(in oklab, var(--success) 35%, transparent); }
.toast-danger{ border-color: color-mix(in oklab, var(--danger)  35%, transparent); }

/* ---------- Pagination ---------- */
.pagination { display:flex; gap:6px; flex-wrap:wrap; }
.page { padding:6px 10px; border:1px solid var(--border); border-radius:8px; background: var(--surface); cursor: pointer; }
.page:hover { background: var(--primary-50); }
.page.active { background: var(--primary); color:#fff; border-color: transparent; }

/* ---------- Skeleton & Progress ---------- */
.skeleton {
  display:block; width: 100%; height: 1em; border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.progress { width:100%; height:10px; background: var(--surface-2); border-radius:999px; overflow:hidden; border:1px solid var(--border); }
.progress > div { height:100%; background: var(--primary); width:0; transition: width .3s ease; }

/* ---------- Utilities ---------- */
.mt-0{margin-top:0}.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mt-5{margin-top:24px}
.mb-0{margin-bottom:0}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mb-5{margin-bottom:24px}
.pt-2{padding-top:8px}.pt-3{padding-top:12px}.pt-4{padding-top:16px}
.pb-2{padding-bottom:8px}.pb-3{padding-bottom:12px}.pb-4{padding-bottom:16px}
.text-right{text-align:right}.text-center{text-align:center}
.float-right{float:right}
.flex{display:flex}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-2{gap:8px}.gap-3{gap:12px}
.hidden{display:none!important}

/* ---------- Login (layout berwarna & rapi) ---------- */
body.login-page{
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 100% -10%, var(--primary-50), transparent 60%),
    radial-gradient(900px 420px at -10% 120%, rgba(8,145,178,.10), transparent 60%),
    var(--bg);
}
.login-shell { max-width: 980px; margin: 32px auto; padding: 0 20px; }
.login-pro {
  display: grid; grid-template-columns: 5fr 7fr; gap: 0;
  overflow: hidden; border-radius: 20px; box-shadow: var(--shadow-2);
}
.login-hero{
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color:#fff; padding: 28px; display:flex; flex-direction:column; justify-content:space-between;
}
.login-form{ background: var(--surface); padding: 28px; }
.login-brand{ display:flex; align-items:center; gap:12px; font-weight:800; letter-spacing:.2px; }
.muted-on-hero{ color: rgba(255,255,255,.85); }
.login-illus{ opacity:.25; filter: drop-shadow(0 10px 30px rgba(0,0,0,.2)); }
@media (max-width: 900px) { .login-pro{ grid-template-columns: 1fr; } .login-illus{ display:none; } }

/* ---------- Footer ---------- */
footer { max-width: 1120px; margin: 24px auto; padding: 0 20px; color: var(--muted); }

/* ---------- Print (struk) ---------- */
@media print {
  header, nav, .btn, .no-print { display:none !important; }
  body { background: #fff; margin: 0; }
  .card, .table-wrap { box-shadow: none; border:1px solid #000; }
  a { color:#000; text-decoration:none; }
}

/* ---------- Motion reduce ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
