/* ==========================================================================
   NOVA Dashboard — Komponen UI
   ========================================================================== */

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast), color var(--fast),
              box-shadow var(--fast), transform var(--fast);
  box-shadow: var(--shadow-xs);
  user-select: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-contrast);
  box-shadow: 0 1px 2px rgba(19, 22, 38, .12), 0 3px 10px hsl(var(--accent-h) var(--accent-s) 58% / .28);
}
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }

.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); box-shadow: none; }
.btn-soft:hover { background: var(--accent-soft-2); border-color: transparent; }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-soft); }
.btn-ghost:hover { background: var(--bg-hover); border-color: transparent; color: var(--text); }

.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); border-color: transparent; }
.btn-danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); box-shadow: none; }
.btn-danger-soft:hover { background: var(--danger-soft); filter: brightness(.96); border-color: transparent; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14.5px; border-radius: var(--r-md); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  color: var(--text-soft);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
  flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent-text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn-sm { width: 26px; height: 26px; border-radius: var(--r-xs); }
.icon-btn-sm svg { width: 14px; height: 14px; }
.icon-btn:disabled { opacity: .4; pointer-events: none; }

/* ---------- Segmented control ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.segmented button {
  padding: 5px 12px;
  border-radius: var(--r-xs);
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-soft);
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button svg { width: 14px; height: 14px; }
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: var(--bg-surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label,
.field-label {
  font-size: 12.5px;
  font-weight: 570;
  color: var(--text-soft);
  display: flex; align-items: center; gap: 6px;
}
.field-hint { font-size: 11.5px; color: var(--text-muted); }

.input, .textarea, .select {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px hsl(var(--accent-h) var(--accent-s) 58% / .16);
  outline: none;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23858ba3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.input-lg { min-height: 44px; font-size: 15px; font-weight: 550; }
.input-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px hsl(0 70% 55% / .13) !important; }

.input-group { display: flex; align-items: stretch; gap: 8px; }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > svg {
  position: absolute; left: 11px; width: 16px; height: 16px;
  color: var(--text-muted); pointer-events: none;
}
.input-icon > .input { padding-left: 34px; }

input[type="date"], input[type="time"], input[type="datetime-local"] { cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: .55; filter: var(--cal-filter, none);
}
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .6; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: var(--r-pill);
  background: var(--bg-active); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid var(--bg-surface);
  box-shadow: var(--shadow-sm); cursor: grab;
}
input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }
input[type="color"] {
  width: 42px; height: 34px; padding: 2px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-surface);
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }

/* Checkbox & radio */
.check {
  display: inline-flex; align-items: center; gap: 9px;
  cursor: pointer; user-select: none; font-size: 13.5px;
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 18px; height: 18px; flex: none;
  border: 1.8px solid var(--border-strong);
  border-radius: 5px;
  display: grid; place-items: center;
  transition: all var(--fast);
  background: var(--bg-surface);
}
.check-box svg { width: 12px; height: 12px; color: #fff; opacity: 0; transform: scale(.5); transition: all var(--fast); }
.check input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check-box svg { opacity: 1; transform: none; }
.check:hover .check-box { border-color: var(--accent); }
.check input:focus-visible + .check-box { box-shadow: 0 0 0 3px hsl(var(--accent-h) var(--accent-s) 58% / .2); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 38px; height: 22px; border-radius: var(--r-pill);
  background: var(--bg-active); position: relative; flex: none;
  transition: background var(--normal);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-xs);
  transition: transform var(--normal);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }

/* ---------- Kartu ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: 18px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.card-hover { transition: box-shadow var(--normal), transform var(--normal), border-color var(--normal); }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }

/* ---------- Chip / badge ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 570;
  background: var(--bg-sunken); color: var(--text-soft);
  border: 1px solid transparent; white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chip-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-outline { background: transparent; border-color: var(--border); }

.badge-count {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
  line-height: 1;
}

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(13, 16, 27, .48);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade-in 160ms var(--ease);
}
[data-theme="dark"] .overlay { background: rgba(0, 0, 0, .62); }

.modal {
  width: min(560px, 100%);
  max-height: calc(100dvh - 48px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop-in 230ms var(--ease);
}
.modal-sm { width: min(420px, 100%); }
.modal-lg { width: min(760px, 100%); }
.modal-xl { width: min(1040px, 100%); }

.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal-head h2 { font-size: 16.5px; font-weight: 660; letter-spacing: -.018em; }
.modal-head .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-2);
  flex: none;
}
.modal-foot .spread { margin-right: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Dropdown / popover ---------- */
.popover {
  position: fixed; z-index: 950;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  min-width: 190px;
  max-height: 380px;
  overflow-y: auto;
  animation: pop-in 150ms var(--ease);
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--r-xs);
  font-size: 13.5px; color: var(--text); text-align: left;
  transition: background var(--fast), color var(--fast);
  cursor: pointer;
}
.menu-item:hover, .menu-item.focus { background: var(--bg-hover); }
.menu-item svg { width: 16px; height: 16px; flex: none; color: var(--text-soft); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item .kbd { margin-left: auto; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.menu-label { padding: 7px 10px 4px; font-size: 11px; font-weight: 640;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }

.kbd {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  padding: 2px 5px; border-radius: 5px;
  background: var(--bg-sunken); border: 1px solid var(--border);
  color: var(--text-muted); line-height: 1.4;
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; bottom: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 11px;
  min-width: 250px; max-width: 400px;
  padding: 11px 15px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: slide-up 240ms var(--ease) both;
  pointer-events: auto;
}
.toast.leaving { animation: fade-in 200ms var(--ease) reverse both; }
.toast-icon { width: 20px; height: 20px; flex: none; display: grid; place-items: center; }
.toast-icon svg { width: 18px; height: 18px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warn .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 580; }
.toast-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 52px 24px; text-align: center; color: var(--text-muted);
}
.empty-icon {
  width: 60px; height: 60px; border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: var(--bg-sunken); color: var(--text-muted);
}
.empty-icon svg { width: 28px; height: 28px; }
.empty h3 { font-size: 15.5px; color: var(--text); font-weight: 620; }
.empty p { font-size: 13px; max-width: 380px; line-height: 1.6; }

/* ---------- Loading ---------- */
.spinner {
  width: 17px; height: 17px; flex: none;
  border: 2.2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 50%, var(--bg-sunken) 75%);
  background-size: 420px 100%;
  animation: shimmer 1.35s linear infinite;
  border-radius: var(--r-sm);
}

.progress {
  height: 7px; border-radius: var(--r-pill);
  background: var(--bg-sunken); overflow: hidden;
}
.progress-bar {
  height: 100%; border-radius: var(--r-pill);
  background: var(--accent);
  transition: width 320ms var(--ease);
}
.progress-bar.striped {
  background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%,
    transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%);
  background-size: 18px 18px;
  animation: progress-stripe .7s linear infinite;
}
@keyframes progress-stripe { to { background-position: 18px 0; } }

/* ---------- Tooltip ---------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 5px 9px; border-radius: var(--r-xs);
  background: var(--bg-inverse); color: var(--text-inverse);
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none; z-index: 800;
  transition: opacity var(--fast), transform var(--fast);
  box-shadow: var(--shadow-md);
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%); }
[data-tip-below]::after { bottom: auto; top: calc(100% + 7px); }

/* ---------- Avatar ---------- */
.avatar {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-text);
  font-weight: 640; font-size: 13px; overflow: hidden;
  background-size: cover; background-position: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 52px; height: 52px; border-radius: var(--r-md); font-size: 22px; }
.avatar-xl { width: 76px; height: 76px; border-radius: var(--r-lg); font-size: 34px; }
.avatar-sm { width: 24px; height: 24px; border-radius: var(--r-xs); font-size: 11px; }
.avatar-round { border-radius: 50%; }

/* ---------- Divider ---------- */
.divider { height: 1px; background: var(--border); margin: 14px 0; border: none; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 14px; font-size: 13.5px; font-weight: 550;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color var(--fast), border-color var(--fast);
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.tab svg { width: 15px; height: 15px; }

/* ---------- Color swatch grid ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch {
  width: 28px; height: 28px; border-radius: var(--r-xs);
  border: 2px solid transparent; cursor: pointer; position: relative;
  transition: transform var(--fast), box-shadow var(--fast);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.swatch:hover { transform: scale(1.12); }
.swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-surface) inset; }
.swatch.selected::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
}

/* ---------- Drop zone ---------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 34px 22px;
  text-align: center;
  background: var(--bg-surface-2);
  cursor: pointer;
  transition: border-color var(--normal), background var(--normal), transform var(--normal);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.008); }
.dropzone-icon {
  width: 46px; height: 46px; margin: 0 auto 12px;
  border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text);
}
.dropzone-icon svg { width: 22px; height: 22px; }
.dropzone h4 { font-size: 14.5px; font-weight: 600; margin-bottom: 3px; }
.dropzone p { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Emoji picker ---------- */
.emoji-picker { width: 320px; padding: 0; }
.emoji-search { padding: 9px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-surface); z-index: 2; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 8px 0; overflow-x: auto; }
.emoji-tabs button {
  padding: 4px 8px; border-radius: var(--r-xs); font-size: 15px; opacity: .55;
  transition: opacity var(--fast), background var(--fast);
}
.emoji-tabs button:hover { opacity: 1; background: var(--bg-hover); }
.emoji-tabs button.active { opacity: 1; background: var(--accent-soft); }
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 8px; max-height: 250px; overflow-y: auto;
}
.emoji-grid button {
  aspect-ratio: 1; display: grid; place-items: center;
  font-size: 20px; border-radius: var(--r-xs);
  transition: background var(--fast), transform var(--fast);
}
.emoji-grid button:hover { background: var(--bg-hover); transform: scale(1.15); }
.emoji-cat-label { grid-column: 1 / -1; padding: 6px 3px 2px; font-size: 10.5px;
  font-weight: 640; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); }
