/* Gaya yang tidak bisa diungkapkan lewat utility Tailwind:
   lebar sidebar, keyframes, dan komponen form/tombol yang berulang. */

:root {
  --sb-width: 16rem;
  --sb-width-collapsed: 4.75rem;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
}

/* ------------------------------------------------------------- Sidebar */

#sidebar {
  width: var(--sb-width);
  will-change: transform, width;
  transition: transform .3s cubic-bezier(.4, 0, .2, 1), width .3s cubic-bezier(.4, 0, .2, 1);
}

html.sb-open #sidebar {
  --tw-translate-x: 0px;
  transform: translateX(0);
}

@media (min-width: 1024px) {
  #shell { padding-left: var(--sb-width); }
  html[data-sb="collapsed"] #sidebar { width: var(--sb-width-collapsed); }
  html[data-sb="collapsed"] #shell { padding-left: var(--sb-width-collapsed); }
}

.sb-label {
  transition: opacity .18s ease, transform .22s ease;
}

html[data-sb="collapsed"] .sb-label {
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
}

@media (min-width: 1024px) {
  html[data-sb="collapsed"] #sidebar nav p.sb-label { height: 0; padding: 0; overflow: hidden; }
  html[data-sb="collapsed"] .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
  html[data-sb="collapsed"] .nav-item .sb-label { display: none; }
}

.nav-item i { transition: transform .2s ease; }
.nav-item:hover i { transform: translateX(2px) scale(1.06); }

#sidebar nav::-webkit-scrollbar { width: 6px; }
#sidebar nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 99px; }

/* ---------------------------------------------------------- Animations */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px) scale(.96); }
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

.anim-rise { animation: rise .45s cubic-bezier(.16, 1, .3, 1) backwards; }
.pop-menu:not(.hidden) { animation: popIn .16s ease-out; }
.toast { animation: toastIn .28s cubic-bezier(.16, 1, .3, 1); }
.toast.leaving { animation: toastOut .2s ease-in forwards; }
.modal-panel { animation: modalIn .26s cubic-bezier(.16, 1, .3, 1); }

[data-modal] { display: none; }
[data-modal]:not(.hidden) { display: flex; }

.skeleton {
  position: relative;
  overflow: hidden;
  background: #e8ecf4;
}

.skeleton::after {
  position: absolute;
  inset: 0;
  content: "";
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
  animation: shimmer 1.4s infinite;
}

/* ------------------------------------------------------------ Controls */

.field {
  display: block;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: .75rem;
  background: #fff;
  padding: .625rem .875rem;
  font-size: .875rem;
  color: #0f172a;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field::placeholder { color: #94a3b8; }

.field:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .16);
}

.field:disabled { background: #f1f5f9; color: #64748b; }

textarea.field { line-height: 1.6; resize: vertical; }

.label {
  display: block;
  margin-bottom: .375rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #334155;
}

.hint { margin-top: .375rem; font-size: .75rem; line-height: 1.5; color: #64748b; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 1px solid transparent;
  border-radius: .75rem;
  padding: .625rem 1rem;
  font-size: .8125rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}

.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .9); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }

.btn-ghost { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-ghost:hover:not(:disabled) { background: #f8fafc; border-color: #94a3b8; }

.btn-danger { background: #e11d48; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #be123c; }

.btn-soft { background: #eef2ff; color: var(--brand-700); }
.btn-soft:hover:not(:disabled) { background: #e0e7ff; }

.btn-sm { padding: .375rem .625rem; font-size: .75rem; border-radius: .5rem; }

/* -------------------------------------------------------------- Tables */

.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }

.tbl thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  padding: .75rem 1.25rem;
  text-align: left;
  font-size: .6875rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.tbl tbody td { padding: .875rem 1.25rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tbody tr { transition: background-color .12s ease; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl tbody tr:last-child td { border-bottom: 0; }

.tbl tbody tr.dragging { opacity: .4; }
.tbl tbody tr.drop-target td { box-shadow: inset 0 2px 0 var(--brand-600); }

.grip { cursor: grab; color: #cbd5e1; }
.grip:active { cursor: grabbing; }

/* -------------------------------------------------------------- Toggle */

.switch { position: relative; display: inline-flex; height: 1.5rem; width: 2.75rem; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch .track { pointer-events: none; width: 100%; border-radius: 99px; background: #cbd5e1; transition: background-color .2s ease; }
.switch .knob {
  pointer-events: none;
  position: absolute;
  top: .1875rem; left: .1875rem;
  height: 1.125rem; width: 1.125rem;
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .3);
  transition: transform .2s cubic-bezier(.4, 0, .2, 1);
}
.switch input:checked ~ .track { background: #10b981; }
.switch input:checked ~ .knob { transform: translateX(1.25rem); }
.switch input:focus-visible ~ .track { outline: 2px solid var(--brand-600); outline-offset: 2px; }

/* --------------------------------------------------------------- Misc */

.scroll-x { overflow-x: auto; }
.scroll-x::-webkit-scrollbar { height: 8px; }
.scroll-x::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .skeleton::after { animation: none; }
}
