/* ==========================================================================
   SADA Design System (diadaptasi dari sada-coffee/design-system-template)
   Primary #345c75 · Font Outfit · Light + Dark (class .dark di <html>)
   ========================================================================== */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.75);
  --border-glass: rgba(15, 23, 42, 0.08);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --bg-header: rgba(248, 250, 252, 0.85);
  --primary: #345c75;
  --primary-glow: rgba(52, 92, 117, 0.15);
  --accent: #274b60;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  --table-bg: rgba(255, 255, 255, 0.6);
  --th-bg: rgba(0, 0, 0, 0.02);
  --tr-hover: rgba(0, 0, 0, 0.015);
  --input-bg: #ffffff;
  --card-shadow: 0 10px 30px rgba(31, 41, 55, 0.06);
  --gradient-intensity: 0.07;
  --font: "Outfit", ui-sans-serif, system-ui, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: light;
}
.dark {
  --bg-primary: #0a0b10;
  --bg-secondary: #12131a;
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.07);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --bg-header: rgba(10, 11, 16, 0.75);
  --primary-glow: rgba(52, 92, 117, 0.4);
  --accent: #4a7896;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning-glow: rgba(245, 158, 11, 0.2);
  --danger-glow: rgba(239, 68, 68, 0.2);
  --table-bg: rgba(0, 0, 0, 0.2);
  --th-bg: rgba(255, 255, 255, 0.02);
  --tr-hover: rgba(255, 255, 255, 0.015);
  --input-bg: rgba(255, 255, 255, 0.02);
  --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --gradient-intensity: 0.12;
  color-scheme: dark;
}

/* --- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(at 0% 0%, rgba(52, 92, 117, var(--gradient-intensity)) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(74, 120, 150, var(--gradient-intensity)) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
.dark a { color: #7fb0cf; }
::selection { background: var(--primary-glow); }
.ic { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.ic, .chev { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-secondary); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* --- Shell: sidebar + konten (pola app-shell sada-coffee) ---------------- */
.glass-panel {
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
}
.shell { display: flex; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: 17rem;
  display: flex; flex-direction: column; border-width: 0 1px 0 0;
  transform: translateX(-100%); transition: transform .3s var(--ease);
}
.menu-open .sidebar { transform: none; }
.backdrop { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.menu-open .backdrop { display: block; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .5rem .75rem; }
.nav-title { padding: 1rem .75rem .5rem; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
.nav-link {
  display: flex; align-items: center; gap: .75rem; margin-bottom: .25rem;
  padding: .65rem .75rem; border-radius: .75rem; font-size: .9rem; font-weight: 500;
  color: var(--text-secondary) !important; text-decoration: none; transition: all .2s var(--ease);
}
.nav-link:hover { background: var(--bg-glass); color: var(--text-primary) !important; }
.nav-link.active { background: var(--primary-glow); color: var(--primary) !important; box-shadow: 0 0 0 1px var(--border-glass); }
.dark .nav-link.active { color: #a9cce2 !important; }
.nav-link .count { margin-left: auto; }
.sidebar-foot { border-top: 1px solid var(--border-glass); padding: 1rem 1.25rem; font-size: .75rem; color: var(--text-secondary); }
.sidebar-foot strong { color: var(--text-primary); display: block; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .8rem 1rem; border-width: 0 0 1px 0;
}
.topbar h1 { font-size: 1.1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .left, .topbar .right { display: flex; align-items: center; gap: .5rem; min-width: 0; }
main { flex: 1; width: 100%; max-width: 72rem; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.page-foot { border-top: 1px solid var(--border-glass); padding: 1rem; text-align: center; font-size: .75rem; color: var(--text-secondary); }

@media (min-width: 1024px) {
  .sidebar { position: sticky; top: 0; height: 100dvh; transform: none; }
  .backdrop, .only-mobile { display: none !important; }
  main { padding: 2rem; }
  .topbar { padding: .9rem 2rem; }
}

/* --- Brand --------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.brand-mark {
  width: 2.25rem; height: 2.25rem; padding: .25rem; border-radius: .75rem; background: #fff;
  border: 1px solid var(--border-glass); box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
  display: flex; align-items: center; justify-content: center;
}
.brand-mark img { width: 100%; height: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; }
.brand-name b {
  background: linear-gradient(135deg, #7fb0cf, #345c75);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand-name span { font-weight: 300; color: var(--text-secondary); }
.brand-sub { margin-top: .25rem; font-size: .62rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }

/* --- Tombol ikon, dropdown akun ------------------------------------------ */
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: 9999px; cursor: pointer; flex-shrink: 0;
  background: var(--bg-glass); border: 1px solid var(--border-glass); color: var(--text-primary) !important;
  box-shadow: var(--card-shadow); transition: all .3s var(--ease);
}
.icon-btn:hover { border-color: var(--primary); transform: scale(1.05); }
.icon-btn.plain { border: 0; box-shadow: none; background: none; border-radius: .6rem; }
.dot-count {
  position: absolute; top: -.2rem; right: -.2rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .3rem;
  border-radius: 9999px; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.theme-dark, .dark .theme-light { display: none; }
.dark .theme-dark { display: block; }

.account { position: relative; }
.account > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
  padding: .3rem .6rem .3rem .3rem; border-radius: .6rem; font-size: .875rem; font-weight: 500;
  background: var(--bg-glass); border: 1px solid var(--border-glass); transition: border-color .2s;
}
.account > summary::-webkit-details-marker { display: none; }
.account > summary:hover { border-color: var(--primary); }
.avatar {
  width: 1.75rem; height: 1.75rem; border-radius: 9999px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
}
.avatar .ic { width: 1rem; height: 1rem; }
.account[open] .chev { transform: rotate(180deg); }
.chev { width: .9rem; height: .9rem; transition: transform .2s; }
.menu {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 60; min-width: 14rem; max-width: calc(100vw - 2rem); padding: .35rem 0;
  background: var(--bg-secondary); border: 1px solid var(--border-glass); border-radius: .75rem;
  box-shadow: var(--card-shadow); animation: fadeInDown .2s ease;
}
.menu .who { padding: .6rem 1rem; }
.menu .who strong { display: block; font-size: .875rem; }
.menu .who span { display: block; font-size: .75rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu hr { border: 0; border-top: 1px solid var(--border-glass); margin: .25rem 0; }
.menu a, .menu button {
  display: flex; align-items: center; gap: .5rem; width: 100%; padding: .55rem 1rem; border: 0; background: none;
  font: inherit; font-size: .875rem; color: var(--text-primary) !important; text-decoration: none; cursor: pointer; text-align: left;
}
.menu a:hover, .menu button:hover { background: var(--bg-glass); }
.menu .danger { color: var(--danger) !important; }
.menu .danger:hover { background: var(--danger-glow); }
@media (max-width: 639px) { .account .name, .account .chev { display: none; } }

/* --- Kartu & judul ------------------------------------------------------- */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  box-shadow: var(--card-shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  animation: fadeIn .5s ease-out;
}
@media (min-width: 640px) { .glass-card { padding: 1.75rem; } }
.section-title { border-left: 4px solid var(--primary); padding-left: .75rem; font-size: 1.15rem; font-weight: 600; margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-head .section-title { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.stat {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin: 0; padding: 1rem 1.1rem;
}
.stat .label { font-size: .8rem; font-weight: 500; color: var(--text-secondary); }
.stat .value { margin-top: .3rem; font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.stat .hint { margin-top: .2rem; font-size: .72rem; color: var(--text-secondary); }
.stat-icon {
  width: 2.6rem; height: 2.6rem; border-radius: .75rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--tone, var(--primary)); background: color-mix(in srgb, var(--tone, var(--primary)) 14%, transparent);
}
.tone-success { --tone: var(--success); } .tone-warning { --tone: var(--warning); } .tone-danger { --tone: var(--danger); }

/* --- Form ---------------------------------------------------------------- */
form > div, .field { margin-bottom: 1rem; }
label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .45rem; color: var(--text-secondary); }
input:not([type=hidden]):not([type=checkbox]), select, textarea {
  width: 100%; padding: .8rem 1rem; font: inherit; font-size: .95rem; color: var(--text-primary);
  background: var(--input-bg); border: 1px solid var(--border-glass); border-radius: 12px;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 12px var(--primary-glow); }
textarea { resize: vertical; min-height: 5rem; }
textarea[rows="1"] { min-height: 2.9rem; }
select option { background: var(--bg-secondary); color: var(--text-primary); }
.helptext, .form-help { display: block; margin-top: .35rem; font-size: .75rem; color: var(--text-secondary); }
.errorlist { list-style: none; margin: 0 0 .45rem; color: var(--danger); font-size: .82rem; font-weight: 500; }
.errorlist.nonfield {
  padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem;
  background: var(--danger-glow); border: 1px solid rgba(239, 68, 68, .35);
}
.form-grid { display: grid; gap: 0 1.25rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: span 2; } }

/* --- Tombol -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.5rem; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-size: .9rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease), border-color .3s var(--ease);
}
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff !important;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(52, 92, 117, .4); }
.btn-secondary { background: var(--bg-glass); color: var(--text-primary) !important; border-color: var(--border-glass); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-success { background: var(--success); color: #fff !important; }
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 0 10px var(--success-glow); }
.btn-danger { background: var(--danger); color: #fff !important; }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 0 10px var(--danger-glow); }
.btn-sm { padding: .45rem .9rem; font-size: .8rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-hero { width: 100%; padding: 1.15rem; font-size: 1.15rem; border-radius: 16px; }
.btn-hero .ic { width: 1.5rem; height: 1.5rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* --- Badge status (titik di depan) --------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .7rem; border-radius: 9999px;
  font-size: .75rem; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  background: var(--primary-glow); color: var(--primary); border: 1px solid rgba(52, 92, 117, .3);
}
.dark .badge { color: #a9cce2; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success, .badge-disetujui, .badge-hadir { background: var(--success-glow); color: var(--success) !important; border-color: rgba(16, 185, 129, .3); }
.badge-warning, .badge-menunggu, .badge-telat { background: var(--warning-glow); color: var(--warning) !important; border-color: rgba(245, 158, 11, .3); }
.badge-danger, .badge-ditolak, .badge-alpa { background: var(--danger-glow); color: var(--danger) !important; border-color: rgba(239, 68, 68, .3); }
.badge-muted, .badge-dibatalkan, .badge-belum, .badge-kosong { background: var(--th-bg); color: var(--text-secondary) !important; border-color: var(--border-glass); }

/* --- Tabel --------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; border-radius: 12px; border: 1px solid var(--border-glass); background: var(--table-bg); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
th {
  background: var(--th-bg); padding: .8rem 1rem; font-weight: 600; font-size: .7rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-secondary); border-bottom: 1px solid var(--border-glass); white-space: nowrap;
}
td { padding: .8rem 1rem; border-bottom: 1px solid var(--border-glass); vertical-align: middle; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 12rem; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--tr-hover); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-secondary); font-style: italic; }

/* --- Daftar (cuti, persetujuan, notifikasi) ------------------------------ */
.item { padding: 1rem 0; border-bottom: 1px solid var(--border-glass); }
.item:first-of-type { padding-top: 0; }
.item:last-child { border-bottom: 0; padding-bottom: 0; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.item-title { font-weight: 600; }
.item-meta { margin-top: .25rem; font-size: .85rem; color: var(--text-secondary); }
.item form { margin-top: .75rem; }
.trail { margin-top: .5rem; padding-left: .75rem; border-left: 2px solid var(--border-glass); font-size: .8rem; color: var(--text-secondary); }
.unread { width: .5rem; height: .5rem; border-radius: 50%; background: var(--primary); display: inline-block; margin-right: .4rem; }

/* --- Tab periode (laporan) ----------------------------------------------- */
.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border-glass); padding-bottom: .75rem; overflow-x: auto; }
.tab { padding: .45rem 1rem; border-radius: 8px; font-weight: 500; color: var(--text-secondary) !important; text-decoration: none; white-space: nowrap; }
.tab:hover { background: var(--bg-glass); color: var(--text-primary) !important; }
.tab.active { color: var(--primary) !important; background: rgba(52, 92, 117, .1); font-weight: 600; }
.dark .tab.active { color: #a9cce2 !important; }
.filters { display: grid; gap: .75rem; grid-template-columns: 1fr; align-items: end; }
.filters > * { margin: 0; }
@media (min-width: 640px) { .filters { grid-template-columns: 1fr 1fr auto; } }

/* --- Halaman absen ------------------------------------------------------- */
.clock { font-size: 2.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.today { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1.25rem; }
.alert {
  display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem;
  font-size: .9rem; background: var(--primary-glow); border: 1px solid rgba(52, 92, 117, .3);
}
.alert-warning { background: var(--warning-glow); border-color: rgba(245, 158, 11, .35); }
.alert-success { background: var(--success-glow); border-color: rgba(16, 185, 129, .35); }
.alert-danger { background: var(--danger-glow); border-color: rgba(239, 68, 68, .35); color: var(--danger); }
#msg { display: block; margin-top: .75rem; text-align: center; }

/* --- Toast (pesan Django) ------------------------------------------------ */
.toasts { position: fixed; z-index: 100; left: 1rem; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .6rem; pointer-events: none; }
@media (min-width: 640px) { .toasts { left: auto; right: 2rem; bottom: 2rem; width: 26rem; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: .6rem; padding: .9rem 1.2rem;
  background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-glass);
  border-left: 4px solid var(--primary); border-radius: 12px; box-shadow: var(--card-shadow);
  animation: slideIn .3s cubic-bezier(.16, 1, .3, 1);
}
.toast-success { border-left-color: var(--success); } .toast-success .ic { color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error .ic { color: var(--danger); }
.toast-info .ic { color: var(--primary); }
.toast.hide { opacity: 0; transform: translateY(8px); transition: all .3s; }

/* --- Halaman login ------------------------------------------------------- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2.5rem 1rem; position: relative; }
.auth .corner { position: absolute; top: 1rem; right: 1rem; }
.auth .brand { transform: scale(1.25); margin-bottom: 1.75rem; }
.auth .glass-card { width: 100%; max-width: 28rem; }
.auth-foot { margin-top: 2rem; font-size: .75rem; color: var(--text-secondary); text-align: center; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
