/* Averion — Custom CSS (minimal, Tailwind handles the rest) */

/* ─── Sidebar Transition ─────────────────────────────────────── */
.sidebar {
    transition: transform 0.2s ease, width 0.2s ease;
}

/* ─── Scrollbar Tipis ────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}
.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

/* ─── Focus Ring Konsisten ───────────────────────────────────── */
*:focus-visible {
    outline: 2px solid var(--brand-color, #6366f1);
    outline-offset: 2px;
}

/* ─── Sidebar Active Item ────────────────────────────────────── */
.nav-item-active {
    background-color: color-mix(in srgb, var(--brand-color, #6366f1) 10%, transparent);
    color: var(--brand-color, #6366f1);
}

/* ─── Brand Color Utilities ──────────────────────────────────── */
.text-brand {
    color: var(--brand-color, #6366f1);
}
.bg-brand {
    background-color: var(--brand-color, #6366f1);
}
.border-brand {
    border-color: var(--brand-color, #6366f1);
}
.bg-brand-soft {
    background-color: color-mix(in srgb, var(--brand-color, #6366f1) 10%, transparent);
}

/* ─── Flash Message Animasi ──────────────────────────────────── */
[data-flash-message] {
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Tabel Row Hover ────────────────────────────────────────── */
.table-row-hover:hover {
    background-color: #f8fafc;
}
.dark .table-row-hover:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* ─── Print Styles ───────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, [data-no-print] {
        display: none !important;
    }
    .print-full {
        margin: 0;
        padding: 0;
    }
}

/* ─── Soft Page Navigation ───────────────────────────────────── */

/* Progress bar saat berpindah halaman */
#nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 99999;
    opacity: 0;
    background: var(--brand-color, #6366f1);
    box-shadow: 0 0 10px var(--brand-color, #6366f1), 0 0 4px var(--brand-color, #6366f1);
    border-radius: 0 3px 3px 0;
    pointer-events: none;
    transition: width 0.18s ease, opacity 0.3s ease;
}
#nav-progress.active { opacity: 1; }

/* ─── Hero soft (homepage) ───────────────────────────────────── */
/* Latar terang ber-tint brand tipis; andal di light & dark tanpa
   bergantung pada Tailwind arbitrary gradient. */
.hero-soft {
    background:
        radial-gradient(60% 70% at 85% 0%, color-mix(in srgb, var(--brand-color) 16%, transparent), transparent 70%),
        linear-gradient(135deg, color-mix(in srgb, var(--brand-color) 11%, #ffffff), #ffffff 55%, color-mix(in srgb, var(--brand-color) 5%, #ffffff));
}
.dark .hero-soft {
    background:
        radial-gradient(60% 70% at 85% 0%, color-mix(in srgb, var(--brand-color) 26%, transparent), transparent 70%),
        linear-gradient(135deg, color-mix(in srgb, var(--brand-color) 24%, #0b1220), #0f172a 55%, #030712);
}

/* ============================================
   UI THEME SYSTEM — Averion Appearance Engine
   Scope: HANYA area dashboard (html.dash-themed) + sidebar (#sidebar).
   Halaman publik tidak punya class ini → tidak terpengaruh.
   Catatan specificity: html.dash-themed body (0,1,2) menang atas .bg-gray-50,
   tetapi .dark .bg-gray-950 (0,2,0) tetap menang → dark mode aman.
   ============================================ */

/* --- Canvas background (light mode dashboard). Dark mode dibiarkan dark. --- */
html.dash-themed body { background-color: var(--bg-canvas, #f9fafb); }

/* --- Card base: radius + shadow dari theme variable --- */
html.dash-themed .card-base {
  border-radius: var(--card-radius, 0.5rem);
  box-shadow: var(--card-shadow, 0 1px 3px rgba(0,0,0,0.10));
}

/* Sidebar full-height menempel ke tepi layar → tidak pakai border-radius
   (radius dari theme membuat sudut menggantung aneh). Sengaja flat. */

/* ===== SIDEBAR STYLE: light =====
   Default = perilaku lama (putih di light, gelap di dark via Tailwind).
   Tidak ada override agar dark mode tetap normal. */

/* ===== SIDEBAR STYLE: dark =====
   Selector ber-id (#sidebar) sengaja dipakai agar specificity mengalahkan
   utility Tailwind (bg-white/dark:bg-gray-900) tanpa perlu menghapus class-nya. */
html.sidebar-dark #sidebar {
  background-color: #0f172a !important;
  border-right: none;
  color: #e2e8f0;
}
html.sidebar-dark #sidebar a { color: #94a3b8; }
html.sidebar-dark #sidebar a:hover { background-color: rgba(255,255,255,0.06); color: #ffffff; }
html.sidebar-dark #sidebar .nav-item-active {
  background-color: rgba(255,255,255,0.10); /* subtle, bukan warna solid */
  color: #ffffff;
}
html.sidebar-dark #sidebar .nav-item-active svg { color: #ffffff; }
html.sidebar-dark #sidebar .text-gray-900,
html.sidebar-dark #sidebar .text-gray-700 { color: #f1f5f9; }
html.sidebar-dark #sidebar .text-gray-600,
html.sidebar-dark #sidebar .text-gray-500,
html.sidebar-dark #sidebar .text-gray-400 { color: #94a3b8; }
/* Divider internal (header border-b, footer border-t) memakai border-gray-200
   yang tampak putih saat halaman light mode + sidebar gelap → buat halus/blend. */
html.sidebar-dark #sidebar .border-t,
html.sidebar-dark #sidebar .border-b,
html.sidebar-dark #sidebar .border-r { border-color: rgba(255,255,255,0.07) !important; }
/* Scrollbar nav agar tidak ada track terang di sidebar gelap. */
html.sidebar-dark #sidebar *::-webkit-scrollbar { width: 6px; }
html.sidebar-dark #sidebar *::-webkit-scrollbar-track { background: transparent; }
html.sidebar-dark #sidebar *::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

/* ===== SIDEBAR STYLE: colored (pakai brand color) ===== */
html.sidebar-colored #sidebar {
  background-color: var(--brand-color) !important;
  border-right: none;
  color: #ffffff;
}
html.sidebar-colored #sidebar a { color: rgba(255,255,255,0.78); }
html.sidebar-colored #sidebar a:hover,
html.sidebar-colored #sidebar .nav-item-active {
  background-color: rgba(255,255,255,0.15);
  color: #ffffff;
}
html.sidebar-colored #sidebar .nav-item-active svg { color: #ffffff; }
html.sidebar-colored #sidebar .text-gray-900,
html.sidebar-colored #sidebar .text-gray-700,
html.sidebar-colored #sidebar .text-gray-600,
html.sidebar-colored #sidebar .text-gray-500,
html.sidebar-colored #sidebar .text-gray-400 { color: rgba(255,255,255,0.85); }
/* Divider internal → halus, hilangkan garis terang. */
html.sidebar-colored #sidebar .border-t,
html.sidebar-colored #sidebar .border-b,
html.sidebar-colored #sidebar .border-r { border-color: rgba(255,255,255,0.18) !important; }
html.sidebar-colored #sidebar *::-webkit-scrollbar { width: 6px; }
html.sidebar-colored #sidebar *::-webkit-scrollbar-track { background: transparent; }
html.sidebar-colored #sidebar *::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.28); border-radius: 3px; }

/* ===== THEME: Airy ===== */
html.theme-airy .card-base {
  background: linear-gradient(135deg, #ffffff 0%, #f8f7ff 100%);
}
/* Stat card gradient (dipakai saat --card-style = gradient). Ditaruh SETELAH
   .card-base agar background gradient berwarna menang. */
html.theme-airy .stat-card-1 { background: linear-gradient(135deg, #6ee7f7 0%, #60a5fa 100%); }
html.theme-airy .stat-card-2 { background: linear-gradient(135deg, #a78bfa 0%, #818cf8 100%); }
html.theme-airy .stat-card-3 { background: linear-gradient(135deg, #f9a8d4 0%, #f472b6 100%); }
html.theme-airy .stat-card-4 { background: linear-gradient(135deg, #86efac 0%, #34d399 100%); }
/* Paksa konten gradient stat card jadi putih (mengalahkan text-gray-* utility). */
html.theme-airy .stat-card p,
html.theme-airy .stat-card a,
html.theme-airy .stat-card svg { color: #ffffff !important; }
html.theme-airy .stat-card .stat-icon { background: rgba(255,255,255,0.22) !important; }

/* ===== THEME: Corporate ===== */
html.theme-corporate .card-base {
  border: 1px solid #e2e8f0;
  box-shadow: none;
}

/* ===== THEME: Minimal ===== */
html.theme-minimal .card-base {
  border: 1px solid #f1f5f9;
  box-shadow: none;
}

/* ============================================
   TOPBAR STYLE (Appearance V2)
   ============================================ */

/* --- Floating: melayang DI ATAS konten (fixed) agar efek kaca/transparan
   benar-benar terlihat — konten ter-blur saat scroll di belakang topbar.
   border radius lebih kecil + shadow lembut. --- */
.topbar-floating {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  margin: 0;
  z-index: 40;
  border-radius: 0.5rem;            /* lebih kecil, tidak terlalu bulat */
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.45);
  /* shadow lembut & menyebar, bukan keras */
  box-shadow: 0 10px 30px -16px rgba(15, 23, 42, 0.18),
              0 2px 8px -4px rgba(15, 23, 42, 0.05);
}
/* Sisihkan ruang sidebar (w-60 = 15rem) di layar besar. */
@media (min-width: 1024px) {
  .topbar-floating { left: calc(15rem + 16px); }
}
/* Beri jarak atas pada konten agar tidak tertutup topbar yang mengambang. */
.topbar-floating ~ main { padding-top: 80px; }

html.dark .topbar-floating {
  background: rgba(17, 24, 39, 0.52);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 34px -18px rgba(0, 0, 0, 0.55);
}

/* Fallback bila backdrop-filter tak didukung: naikkan opacity agar teks tetap terbaca. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar-floating { background: rgba(255, 255, 255, 0.92); }
  html.dark .topbar-floating { background: rgba(17, 24, 39, 0.92); }
}

/* --- Override warna ikon/teks untuk topbar colored & dark --- */
.topbar-colored svg,
.topbar-colored button,
.topbar-colored span,
.topbar-colored h1 {
  color: rgba(255, 255, 255, 0.92);
}
.topbar-dark svg,
.topbar-dark button,
.topbar-dark span,
.topbar-dark h1 {
  color: #e2e8f0;
}

/* --- Hover state untuk tombol di topbar colored/dark --- */
.topbar-colored button:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 0.375rem;
}
.topbar-dark button:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 0.375rem;
}

/* ============================================
   MOBILE RESPONSIVE — Global Fixes
   ============================================ */

/* Cegah auto-zoom iOS saat focus input (font < 16px memicu zoom). */
@media screen and (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="date"],
  input[type="datetime-local"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Minimum tap target untuk tombol interaktif di mobile. */
@media screen and (max-width: 767px) {
  button,
  a[role="button"],
  [type="submit"],
  [type="button"] {
    min-height: 44px;
  }
  /* Kecuali tombol dalam tabel & yang ditandai .no-min-tap (toolbar padat). */
  table button,
  table a,
  .no-min-tap,
  .no-min-tap button,
  .no-min-tap a {
    min-height: unset;
  }
}

/* Helper: tabel scroll horizontal (opt-in). */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Helper: modal mobile (opt-in via class). */
@media screen and (max-width: 640px) {
  .modal-container {
    margin: 0 12px;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-fullscreen-mobile {
    position: fixed !important;
    inset: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    max-height: 100vh !important;
  }
}

/* Helper: word-break untuk teks panjang (email, URL, order number). */
.break-words-mobile {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Mobile: sembunyikan scrollbar (touch swipe tetap jalan). */
@media screen and (max-width: 767px) {
  ::-webkit-scrollbar { width: 0; height: 0; }
}

/* Mobile: topbar floating dinonaktifkan → kembali jadi bar solid normal. */
@media screen and (max-width: 767px) {
  .topbar-floating {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  html.dark .topbar-floating { background: #111827 !important; }
  .topbar-floating ~ main { padding-top: 0 !important; }
}

/* ============================================
   Placeholder chip — brand-soft, transparan lembut
   Dipakai di referensi placeholder & chip insert form notifikasi.
   ============================================ */
.ph-chip {
  background-color: color-mix(in srgb, var(--brand-color) 10%, transparent);
  color: var(--brand-color);
  border: 1px solid color-mix(in srgb, var(--brand-color) 18%, transparent);
  cursor: pointer;
}
.ph-chip:hover {
  background-color: color-mix(in srgb, var(--brand-color) 20%, transparent);
}
/* Varian chip form edit yang membungkus 2 aksi (sisip + salin) */
.ph-chip-group { line-height: 1; }
.ph-chip-group .ph-chip-divider {
  border-left: 1px solid color-mix(in srgb, var(--brand-color) 22%, transparent);
}
/* Sembunyikan segitiga default <summary> yang opt-in pakai .list-none */
summary.list-none { list-style: none; }
summary.list-none::-webkit-details-marker { display: none; }

/* Tombol Edit compact (accordion) — chevron berputar & highlight saat terbuka */
.notif-edit-btn .notif-edit-chevron { transition: transform .2s ease; }
.notif-edit-btn.is-open .notif-edit-chevron { transform: rotate(180deg); }
.notif-edit-btn.is-open {
  border-color: color-mix(in srgb, var(--brand-color) 40%, transparent);
  background-color: color-mix(in srgb, var(--brand-color) 10%, transparent);
  color: var(--brand-color);
}
