/**
 * File: app-ui.css
 * GLOBAL DESIGN SYSTEM (Native App Style) — FINAL
 * Support Light Mode, Dark Mode, & Custom Accent Colors.
 */

/* ============================================================
   1. VARIABLES (LIGHT MODE - DEFAULT)
   ============================================================ */
:root {
  /* Background & Text */
  --ui-bg: #f2f4f8;
  --ui-card-bg: #ffffff;
  --ui-text-primary: #1a1d29;
  --ui-text-secondary: #6b7280;
  --ui-border-soft: #eef0f4;

  /* Colors */
  --ui-primary: #0d6efd;
  --ui-primary-gradient: linear-gradient(135deg, #0d6efd 0%, #4f46e5 100%);

  /* Status Colors (Pastel) */
  --ui-hadir: #10b981;
  --ui-hadir-bg: #d1fae5;
  --ui-sakit: #3b82f6;
  --ui-sakit-bg: #dbeafe;
  --ui-ijin: #f59e0b;
  --ui-ijin-bg: #fef3c7;
  --ui-alpha: #ef4444;
  --ui-alpha-bg: #fee2e2;

  /* Radius & Shadow */
  --ui-radius-lg: 16px;
  --ui-radius-md: 12px;
  --ui-radius-sm: 8px;
  --ui-shadow: 0 2px 8px rgba(20, 24, 40, 0.06);
}

/* ============================================================
   2. VARIABLES (DARK MODE)
   ============================================================ */
[data-theme="dark"] {
  /* Background & Text */
  --ui-bg: #121212;
  --ui-card-bg: #1e1e1e;
  --ui-text-primary: #f3f4f6;
  --ui-text-secondary: #9ca3af;
  --ui-border-soft: #2d2d2d;

  /* Colors */
  --ui-primary: #3b82f6;
  --ui-primary-gradient: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);

  /* Status Colors (Dark Mode) */
  --ui-hadir: #34d399;
  --ui-hadir-bg: rgba(16, 185, 129, 0.15);
  --ui-sakit: #60a5fa;
  --ui-sakit-bg: rgba(59, 130, 246, 0.15);
  --ui-ijin: #fbbf24;
  --ui-ijin-bg: rgba(245, 158, 11, 0.15);
  --ui-alpha: #f87171;
  --ui-alpha-bg: rgba(239, 68, 68, 0.15);

  /* Shadow */
  --ui-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   3. CUSTOM ACCENT COLORS (User Choice)
   ============================================================ */
[data-accent="green"] {
  --ui-primary: #10b981;
  --ui-primary-gradient: linear-gradient(135deg, #10b981 0%, #047857 100%);
}
[data-accent="orange"] {
  --ui-primary: #f59e0b;
  --ui-primary-gradient: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
}
[data-accent="purple"] {
  --ui-primary: #8b5cf6;
  --ui-primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
}
/* 🔥 TAMBAHKAN INI: Definisi untuk Pink dan Merah */
[data-accent="pink"] {
  --ui-primary: #ec4899;
  --ui-primary-gradient: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
}
[data-accent="red"] {
  --ui-primary: #ef4444;
  --ui-primary-gradient: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
}

/* ============================================================
   4. BASE LAYOUT
   ============================================================ */
body.ui-body {
  background-color: var(--ui-bg) !important;
  color: var(--ui-text-primary);
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

/* ============================================================
   5. HEADER GRADIENT (Hero)
   ============================================================ */
.ui-header {
  background: var(--ui-primary-gradient);
  border-radius: 0 0 24px 24px;
  padding: 16px 20px 24px;
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.ui-header::before {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 150px;
  height: 150px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}
.ui-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
  margin-bottom: 12px;
}
.ui-header-back {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  text-decoration: none;
}
.ui-header-title {
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  margin: 0;
  flex: 1;
  text-align: center;
}

/* ============================================================
   6. CARD & LIST ITEM
   ============================================================ */
.ui-card {
  background: var(--ui-card-bg);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--ui-border-soft);
  transition: background-color 0.3s ease;
}
.ui-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ui-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--ui-radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  background: var(--ui-primary-gradient);
}
.ui-info {
  flex: 1;
  min-width: 0;
}
.ui-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--ui-text-primary);
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.ui-meta {
  font-size: 12px;
  color: var(--ui-text-secondary);
}

/* ============================================================
   7. SEARCH BAR
   ============================================================ */
.ui-search-wrap {
  margin: 0 16px 16px;
  position: relative;
  z-index: 3;
}
.ui-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ui-text-secondary);
  font-size: 14px;
}
.ui-search-input {
  width: 100%;
  padding: 12px 14px 12px 38px;
  border-radius: 100px;
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-card-bg);
  box-shadow: var(--ui-shadow);
  font-size: 13px;
  color: var(--ui-text-primary);
  outline: none;
}

/* ============================================================
   8. BADGES & CHIPS (Status)
   ============================================================ */
.ui-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--ui-radius-sm);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
.ui-badge-high {
  background: var(--ui-hadir-bg);
  color: var(--ui-hadir);
}
.ui-badge-mid {
  background: var(--ui-ijin-bg);
  color: var(--ui-ijin);
}
.ui-badge-low {
  background: var(--ui-alpha-bg);
  color: var(--ui-alpha);
}

.ui-chip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.ui-chip-scroll::-webkit-scrollbar {
  display: none;
}
.ui-chip {
  flex-shrink: 0;
  min-width: 48px;
  padding: 8px 4px;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-card-bg);
  border: 1.5px solid var(--ui-border-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.ui-chip-day {
  font-size: 10px;
  font-weight: 600;
  color: var(--ui-text-secondary);
  margin-bottom: 2px;
}
.ui-chip-num {
  font-size: 14px;
  font-weight: 800;
  color: var(--ui-text-primary);
  line-height: 1;
  margin-bottom: 4px;
}
.ui-chip-status {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
}

.ui-chip.H {
  background: var(--ui-hadir-bg);
  border-color: var(--ui-hadir);
}
.ui-chip.H .ui-chip-status {
  background: var(--ui-hadir);
  color: #fff;
}
.ui-chip.S {
  background: var(--ui-sakit-bg);
  border-color: var(--ui-sakit);
}
.ui-chip.S .ui-chip-status {
  background: var(--ui-sakit);
  color: #fff;
}
.ui-chip.I {
  background: var(--ui-ijin-bg);
  border-color: var(--ui-ijin);
}
.ui-chip.I .ui-chip-status {
  background: var(--ui-ijin);
  color: #fff;
}
.ui-chip.A {
  background: var(--ui-alpha-bg);
  border-color: var(--ui-alpha);
}
.ui-chip.A .ui-chip-status {
  background: var(--ui-alpha);
  color: #fff;
}

/* ============================================================
   9. FAB (Floating Action Button) — BULAT
   ============================================================ */
.ui-fab {
  position: fixed;
  right: 20px;
  bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  z-index: 9990;

  /* 🔥 Ukuran bulat penuh */
  width: 56px;
  height: 56px;
  padding: 0;

  /* Layout center */
  display: inline-flex;
  align-items: center;
  justify-content: center;

  /* Styling */
  background: var(--ui-primary-gradient);
  color: #fff !important;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  text-decoration: none;
  transition: transform 0.15s ease;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.ui-fab:active {
  transform: scale(0.95);
}

/* ============================================================
   10. FOOTER NAVIGATION (DARK MODE COMPATIBLE)
   ============================================================ */
.ui-footer-nav {
  background: var(--ui-primary-gradient) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.3s ease;
}
.ui-footer-nav a {
  color: #fff !important;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}
.ui-footer-nav a.active-nav {
  opacity: 1 !important;
  font-weight: 700;
}
.ui-footer-nav a i {
  font-size: 20px;
  margin-bottom: 4px;
}

/* ============================================================
   11. IKON MENU DI DARK MODE (Tanpa 2 Gambar)
   ============================================================ */
/* 
 * Trik: Jika ikon asli berwarna gelap/hitam, kita bisa gunakan filter invert 
 * agar jadi putih. Namun, jika ikon berwarna-warni, filter ini akan merusaknya.
 * Solusi teraman: Beri background kontras pada wadah ikon (icon-wrap).
 */
[data-theme="dark"] .dash-menu-icon-wrap {
  background: #2d2d2d; /* Latar abu gelap untuk wadah ikon */
}
/* Jika ikon Anda berwarna hitam pekat dan ingin dipaksa putih di dark mode: */
[data-theme="dark"] .dash-menu-item img {
  filter: invert(1) brightness(200%);
}

/* ============================================================
   12. APPEARANCE SETTINGS MODAL (Bottom Sheet)
   ============================================================ */
.ui-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: none;
  align-items: flex-end;
  backdrop-filter: blur(4px);
}
.ui-modal-overlay.active {
  display: flex;
}

.ui-modal-sheet {
  background: var(--ui-card-bg);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: slideUp 0.3s ease;
  max-height: 85vh;
  overflow-y: auto;
  color: var(--ui-text-primary);
}
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.ui-modal-handle {
  width: 40px;
  height: 4px;
  background: var(--ui-border-soft);
  border-radius: 2px;
  margin: 12px auto 8px;
}
.ui-modal-header {
  padding: 8px 20px 16px;
  border-bottom: 1px solid var(--ui-border-soft);
}
.ui-modal-header h5 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
}
.ui-modal-body {
  padding: 20px;
}

/* Section */
.ui-setting-section {
  margin-bottom: 24px;
}
.ui-setting-section > label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--ui-text-primary);
}

/* Theme Options */
.ui-theme-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ui-theme-options button {
  padding: 12px;
  border-radius: var(--ui-radius-sm);
  border: 2px solid var(--ui-border-soft);
  background: var(--ui-card-bg);
  color: var(--ui-text-primary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ui-theme-options button.active {
  border-color: var(--ui-primary);
  background: var(--ui-primary);
  color: #fff;
}

/* Color Grid (Preset) */
.ui-color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.ui-color-swatch {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
}
.ui-color-swatch:active {
  transform: scale(0.9);
}
.ui-color-swatch.active {
  border-color: var(--ui-text-primary);
  box-shadow: 0 0 0 3px var(--ui-card-bg) inset;
}

/* Custom Color Row */
.ui-custom-color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--ui-radius-sm);
  border: 2px dashed var(--ui-border-soft);
  background: var(--ui-bg);
}
.ui-custom-color-row label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--ui-text-secondary);
  margin: 0;
}
.ui-color-input {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: none;
  padding: 0;
}
.ui-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}
.ui-color-input::-webkit-color-swatch {
  border: 2px solid var(--ui-border-soft);
  border-radius: 12px;
}

/* Reset Button */
.ui-btn-reset {
  width: 100%;
  padding: 12px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-card-bg);
  color: var(--ui-text-primary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.ui-btn-reset:active {
  background: var(--ui-bg);
}

/* Gear button (in dashboard header) */
/* Gear button (in dashboard header) */
.ui-settings-trigger {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 50%; /* Membuat bulat */
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: pointer;
  backdrop-filter: blur(4px);
  font-size: 16px;
  transition: background 0.2s ease;
}
.ui-settings-trigger:active {
  background: rgba(255, 255, 255, 0.4);
}

/* ============================================================
   13. FIX FOOTER ACTIVE STATE (IKON PUTIH & BACKGROUND KUSTOM)
   ============================================================ */

/* 1. Pastikan background tag <a> transparan agar tidak memunculkan kotak */
#footer-bar a.active-nav {
  background: transparent !important;
}

/* 2. Ikon & Teks yang aktif dipaksa BERWARNA PUTIH agar kontras */
#footer-bar a.active-nav i,
#footer-bar a.active-nav span {
  color: #ffffff !important;
  opacity: 1 !important;
  z-index: 2; /* Pastikan ikon di atas lingkaran */
  position: relative;
}

/* 3. Lingkaran di belakang ikon (biasanya tag <strong>) mengikuti warna kustom user */
#footer-bar a.active-nav strong,
#footer-bar a.active-nav::before,
#footer-bar a.active-nav::after {
  background-color: var(--ui-primary) !important;
  border-color: var(--ui-primary) !important;
}

/* 4. Khusus tag <strong> yang biasanya kosong, pastikan tidak ada teksnya */
#footer-bar a.active-nav strong {
  color: transparent !important;
}
