/* =====================================================
   ABSENSI MTC RSF — Material Design CSS
   ===================================================== */

:root {
  /* macOS Color Palette */
  --primary: #007AFF;
  /* macOS Blue */
  --primary-dark: #0056B3;
  --primary-light: #47A1FF;
  --accent: #FF9500;
  /* macOS Orange */
  --accent-light: #FFB340;
  --surface: rgba(255, 255, 255, 0.85);
  /* For Glassmorphism */
  --surface-solid: #ffffff;
  --bg: #F2F2F7;
  /* macOS Light Background */
  --text: #1C1C1E;
  --text-sec: #8E8E93;
  --divider: rgba(60, 60, 67, 0.12);

  /* Status Colors */
  --hadir: #34C759;
  --hadir-bg: rgba(0, 122, 255, 0.12);
  --izin: #FF9500;
  --izin-bg: rgba(255, 149, 0, 0.12);
  --mangkir: #8E8E93;
  --mangkir-bg: rgba(142, 142, 147, 0.12);
  --libur: #FF3B30;
  /* macOS Red */
  --libur-bg: rgba(255, 59, 48, 0.12);
  --error: #FF3B30;
  --success: #34C759;
  /* macOS Green */

  /* Shadows & Radius */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Layout */
  --app-bar-h: 56px;
  --drawer-w: 240px;
  --transition: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  --glass-bg: blur(20px) saturate(180%);
}

/* =====================================================
   DARK MODE
   ===================================================== */
body.dark-mode {
  --bg: #1C1C1E;
  --surface: rgba(44, 44, 46, 0.9);
  --surface-solid: #2C2C2E;
  --text: #F2F2F7;
  --text-sec: #AEAEB2;
  --divider: rgba(255, 255, 255, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body.dark-mode .app-bar {
  background: rgba(28, 28, 30, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode .drawer {
  background: rgba(28, 28, 30, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode .card {
  background: var(--surface-solid);
}

body.dark-mode .attendance-table th.col-no,
body.dark-mode .attendance-table td.col-no,
body.dark-mode .attendance-table th.col-nama,
body.dark-mode .attendance-table td.col-nama,
body.dark-mode .attendance-table th.col-nik,
body.dark-mode .attendance-table td.col-nik,
body.dark-mode .attendance-table th.col-ket,
body.dark-mode .attendance-table td.col-ket {
  background: #2C2C2E;
}

body.dark-mode .attendance-table tbody tr:nth-child(even) td.col-no,
body.dark-mode .attendance-table tbody tr:nth-child(even) td.col-nama,
body.dark-mode .attendance-table tbody tr:nth-child(even) td.col-nik,
body.dark-mode .attendance-table tbody tr:nth-child(even) td.col-ket {
  background: #3A3A3C;
}

body.dark-mode .day-row th,
body.dark-mode .dn-row th {
  background: #3A3A3C !important;
}

body.dark-mode select,
body.dark-mode input {
  background: #3A3A3C;
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

body.dark-mode .stat-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Dark Mode Toggle Button */
.dark-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sec);
  font-size: 22px;
  transition: background var(--transition);
  margin-right: 4px;
}

.dark-toggle:hover {
  background: rgba(0, 0, 0, 0.07);
}

body.dark-mode .dark-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-solid);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 6px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.search-box .material-icons {
  color: var(--text-sec);
  font-size: 20px;
}

.search-box input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  min-width: 150px;
  flex: 1;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  letter-spacing: -0.022em;
}

/* Glassmorphism Classes */
.glass {
  background: var(--surface);
  backdrop-filter: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-bg);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #eceff1;
}

::-webkit-scrollbar-thumb {
  background: #90a4ae;
  border-radius: 3px;
}

/* ==========================
   APP BAR
========================== */
.app-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-bar-h);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-bg);
  color: var(--text);
  z-index: 1000;
  border-bottom: 1px solid var(--divider);
}

.app-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
}

.app-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-btn {
  cursor: pointer;
  user-select: none;
  padding: 6px;
  border-radius: 8px;
  transition: background var(--transition);
  color: var(--primary);
}

.menu-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.app-title-main {
  font-size: 1rem;
  font-weight: 600;
  display: block;
}

.app-title-sub {
  font-size: 0.7rem;
  color: var(--text-sec);
  font-weight: 400;
}

.app-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  padding: 4px 12px;
}

.month-selector .material-icons {
  font-size: 16px;
  color: var(--text-sec);
}

.month-selector select {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  outline: none;
}

.month-selector option {
  background: var(--surface-solid);
  color: var(--text);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-sec);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--primary);
}

/* ==========================
   DRAWER
========================== */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1199;
}

.drawer-overlay.open {
  display: block;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--drawer-w);
  background: rgba(246, 246, 246, 0.8);
  backdrop-filter: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-bg);
  z-index: 1200;
  border-right: 1px solid var(--divider);
  transform: translateX(calc(-1 * var(--drawer-w)));
  transition: transform var(--transition);
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 32px 20px 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.drawer-logo {
  background: white;
  padding: 6px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  width: 50px;
  height: 50px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.app-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.drawer-sub {
  font-size: 0.75rem;
  color: var(--text-sec);
}

.drawer-nav {
  list-style: none;
  padding: 12px;
  flex: 1;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  border-radius: 10px;
  margin-bottom: 2px;
  transition: all var(--transition);
  font-weight: 500;
}

.drawer-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.drawer-item.active {
  background: var(--primary);
  color: #fff;
}

.drawer-item .material-icons {
  font-size: 20px;
}

/* ==========================
   MAIN CONTENT
========================== */
.main-content {
  margin-top: var(--app-bar-h);
  padding: 24px;
  min-height: calc(100vh - var(--app-bar-h));
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.tab-section {
  display: none;
}

.tab-section.active {
  display: block;
}

/* ==========================
   STATUS BANNER
========================== */
.status-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-solid);
  color: var(--text);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
}

.status-banner .material-icons {
  font-size: 18px;
  color: var(--primary);
}

.status-chip {
  margin-left: auto;
  background: var(--hadir-bg);
  color: var(--primary);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ==========================
   SEGMENTED CONTROLS (TABS)
========================== */
.subtab-bar,
.unit-tabs {
  display: inline-flex;
  background: rgba(118, 118, 128, 0.12);
  /* macOS unselected segment background */
  padding: 2px;
  border-radius: 8px;
  /* macOS style radius */
  margin-bottom: 20px;
  gap: 2px;
}

body.dark-mode .subtab-bar,
body.dark-mode .unit-tabs {
  background: rgba(118, 118, 128, 0.24);
}

.subtab-btn,
.unit-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 16px;
  border: none;
  border-radius: 6px;
  /* Inner radius */
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  white-space: nowrap;
  min-width: 100px;
}

.subtab-btn .material-icons,
.unit-tab .material-icons {
  font-size: 16px;
}

.subtab-btn:hover,
.unit-tab:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .subtab-btn:hover,
body.dark-mode .unit-tab:hover {
  background: rgba(255, 255, 255, 0.1);
}

.subtab-btn.active,
.unit-tab.active {
  background: var(--surface-solid);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  /* macOS active prominent shadow */
  color: var(--text);
  font-weight: 600;
  /* Bolder text for active state */
}

body.dark-mode .subtab-btn.active,
body.dark-mode .unit-tab.active {
  background: #636366;
  /* macOS dark mode active segment */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.24);
}

.unit-tabs {
  margin-bottom: 12px;
}

/* Sub-tab content panels */
.subtab-content {
  display: none;
}

.subtab-content.active {
  display: block;
}

/* ==========================
   CARDS
========================== */
.card {
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
  overflow: hidden;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  gap: 8px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-title-group .material-icons {
  color: var(--primary);
  font-size: 22px;
}

.card-title-group h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* ==========================
   ATTENDANCE TABLE
========================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  position: relative;
}

.attendance-table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 0.8rem;
}

.attendance-table th,
.attendance-table td {
  border: none;
  border-bottom: 1px solid var(--divider);
  border-right: 1px solid var(--divider);
  text-align: center;
  white-space: nowrap;
  padding: 8px 4px;
}

/* Fixed columns */
.attendance-table th.col-no,
.attendance-table td.col-no {
  min-width: 40px;
  width: 40px;
  position: sticky;
  left: 0;
  z-index: 10;
  background: #F9F9F9;
  font-weight: 600;
}

.attendance-table th.col-nama,
.attendance-table td.col-nama {
  min-width: 160px;
  text-align: left;
  padding-left: 12px;
  position: sticky;
  left: 40px;
  z-index: 10;
  background: #F9F9F9;
  font-weight: 500;
}

.attendance-table th.col-nik,
.attendance-table td.col-nik {
  min-width: 100px;
  position: sticky;
  left: 200px;
  z-index: 10;
  background: #F9F9F9;
  font-family: inherit;
  color: var(--text-sec);
}

.attendance-table th.col-ket,
.attendance-table td.col-ket {
  min-width: 120px;
  text-align: left;
  padding-left: 10px;
  position: sticky;
  left: 300px;
  z-index: 10;
  background: #F9F9F9;
}

/* Header styling */
.day-row th {
  background: #F2F2F7 !important;
  color: var(--text);
  font-weight: 600;
  padding: 10px 4px;
  font-size: 0.75rem;
}

.day-row th.day-sunday {
  color: var(--error);
}

.dn-row th {
  background: #F2F2F7 !important;
  color: var(--text-sec);
  font-size: 0.65rem;
  padding: 4px 2px;
  font-weight: 600;
  text-transform: uppercase;
}

.dn-row th.dn-mg {
  color: var(--error);
}

/* Data rows */
.attendance-table tbody tr {
  transition: background var(--transition);
}

.attendance-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.attendance-table tbody tr:nth-child(even) td.col-no,
.attendance-table tbody tr:nth-child(even) td.col-nama,
.attendance-table tbody tr:nth-child(even) td.col-nik,
.attendance-table tbody tr:nth-child(even) td.col-ket {
  background: #e3f2fd;
}

.attendance-table tbody tr:hover {
  background: #fffde7;
}

.attendance-table td {
  padding: 5px 3px;
  min-width: 28px;
  height: 32px;
  cursor: pointer;
}

.attendance-table td.fixed-col {
  cursor: default;
}

/* Cell states as chips */
.attendance-table td span.status-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.75rem;
}

.cell-H span {
  background: var(--hadir-bg);
  color: var(--hadir);
}

.cell-I span {
  background: var(--izin-bg);
  color: var(--izin);
}

.cell-X span {
  background: var(--mangkir-bg);
  color: var(--mangkir);
}

.cell-MG span {
  background: var(--libur-bg);
  color: var(--libur);
}

.badge-warning {
  background: rgba(255, 59, 48, 0.15);
  color: #D32F2F;
  border: 1px solid rgba(255, 59, 48, 0.2);
}

.cell-M span {
  background: rgba(69, 39, 160, 0.12);
  color: #4527A0;
}

.cell-S span {
  background: rgba(0, 105, 92, 0.12);
  color: #00695C;
}

.cell-P span {
  background: rgba(230, 81, 0, 0.12);
  color: #E65100;
}

.cell-libur-merah {
  background: rgba(255, 59, 48, 0.05) !important;
}

/* Sunday column highlight */
.col-sunday {
  background: rgba(255, 59, 48, 0.03) !important;
}

.attendance-table tbody tr:hover td {
  background: rgba(0, 122, 255, 0.04) !important;
}

/* ==========================
   LEGEND
========================== */
.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  font-size: .78rem;
  color: var(--text-sec);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.leg-box {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: inline-block;
}

.leg-hadir {
  background: var(--hadir);
}

.leg-izin {
  background: var(--izin);
}

.leg-mangkir {
  background: var(--mangkir);
}

.leg-libur {
  background: var(--libur);
}

.leg-empty {
  background: #e0e0e0;
  border: 1px solid #bdbdbd;
}

/* ==========================
   MODALS
========================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-card {
  background: var(--surface-solid);
  width: 90%;
  max-width: 480px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--divider);
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}

.modal-body {
  padding: 24px;
}

.modal-info {
  font-size: 0.9rem;
  color: var(--text-sec);
  margin-bottom: 20px;
  text-align: center;
}

.status-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.status-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--divider);
  border-radius: 10px;
  background: #F9F9F9;
  cursor: pointer;
  transition: all 0.2s ease;
}

.status-opt:hover {
  background: var(--hadir-bg);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.status-opt .material-icons {
  font-size: 24px;
  color: var(--primary);
}

.status-opt[data-val="H"] .material-icons {
  color: var(--hadir);
}

.status-opt[data-val="I"] .material-icons {
  color: var(--izin);
}

.status-opt[data-val="X"] .material-icons {
  color: var(--mangkir);
}

.status-opt[data-val="MG"] .material-icons {
  color: var(--libur);
}

/* Buttons & Forms */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 122, 255, 0.3);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 122, 255, 0.4);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-sm .material-icons {
  font-size: 18px;
}

.member-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.form-group input,
.form-group select {
  background: #F9F9F9;
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* ==========================
   MEMBER TABLE
========================== */
/* ==========================
   FILTER SELECTS (macOS Style)
========================== */
.member-filter select,
.card-header select {
  appearance: none;
  background-color: rgba(0, 0, 0, 0.04);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 6px 32px 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.member-filter select:hover,
.card-header select:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

.member-filter select:focus,
.card-header select:focus {
  outline: none;
  background-color: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.member-list-wrapper {
  overflow-x: auto;
}

.member-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.member-table th {
  background: #F2F2F7;
  color: var(--text);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--divider);
  font-weight: 600;
}

.member-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}

.member-table tr:last-child td {
  border-bottom: none;
}

.member-table tr:hover td {
  background: rgba(0, 122, 255, 0.04);
}

.badge {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-dayshift {
  background: var(--hadir-bg);
  color: var(--hadir);
}

.badge-cleaning {
  background: var(--izin-bg);
  color: var(--izin);
}

.badge-shift {
  background: #EDE7F6;
  color: #4527A0;
}

.btn-icon-sm {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  display: inline-flex;
  transition: background var(--transition);
  color: var(--text-sec);
}

.btn-icon-sm:hover {
  background: var(--bg);
}

.btn-icon-sm.del:hover {
  background: var(--mangkir-bg);
  color: var(--error);
}

.btn-icon-sm.edit:hover {
  background: var(--hadir-bg);
  color: var(--primary);
}

/* ==========================
   STATISTICS
========================== */
/* ==========================
   STATISTICS DASHBOARD
========================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-card .material-icons {
  font-size: 32px;
  margin-bottom: 4px;
}

.stat-val {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-lbl {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Specific Card Styling */
.stat-card.blue .material-icons,
.stat-card.blue .stat-val {
  color: var(--hadir);
}

.stat-card.orange .material-icons,
.stat-card.orange .stat-val {
  color: var(--izin);
}

.stat-card.red .material-icons,
.stat-card.red .stat-val {
  color: var(--mangkir);
}

/* Mangkir emphasized with Red */
.stat-card.green .material-icons,
.stat-card.green .stat-val {
  color: var(--success);
}

/* Highlight Mangkir Card */
/* Neutral Mangkir Card */
.stat-card.red {
  grid-column: span 1;
  border: 1px solid var(--divider);
  background: var(--surface-solid);
}

.stat-card.red::before {
  display: none;
}

@media (max-width: 960px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.stat-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
}

.stat-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--divider);
}

.stat-table tr:hover td {
  background: var(--hadir-bg);
}

.col-hadir {
  color: var(--hadir);
}

.col-izin {
  color: var(--izin);
}

.col-mangkir {
  color: var(--mangkir);
}

.col-libur {
  color: var(--libur);
}

td.col-hadir {
  background: var(--hadir-bg);
  color: var(--hadir);
  font-weight: 700;
}

td.col-izin {
  background: var(--izin-bg);
  color: var(--izin);
  font-weight: 700;
}

td.col-mangkir {
  background: var(--mangkir-bg);
  color: var(--mangkir);
  font-weight: 700;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--divider);
  flex: 1;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--hadir);
  transition: width .4s;
}

/* Chart */
.chart-area {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-label {
  width: 160px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-sec);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chart-bar-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
}

.chart-bar-track {
  flex: 1;
  height: 14px;
  background: var(--bg);
  border-radius: 7px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width .5s;
}

.chart-bar-fill.hadir {
  background: var(--hadir);
}

.chart-bar-fill.izin {
  background: var(--izin);
}

.chart-bar-fill.mangkir {
  background: var(--mangkir);
}

.chart-count {
  width: 28px;
  font-weight: 700;
  text-align: right;
}

/* ==========================
   MODAL
========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  animation: slideUp .22s ease;
}

.modal-sm {
  max-width: 340px;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--divider);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
}

.modal-header .material-icons {
  color: var(--primary);
}

.modal-body {
  padding: 18px;
}

.modal-info {
  font-size: .88rem;
  color: var(--text-sec);
  margin-bottom: 16px;
}

.status-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.status-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: .8rem;
  font-family: inherit;
  color: var(--text-sec);
  transition: all var(--transition);
}

.status-opt .material-icons {
  font-size: 22px;
}

.status-opt:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--hadir-bg);
}

.status-opt[data-val="I"]:hover {
  border-color: var(--izin);
  color: var(--izin);
  background: var(--izin-bg);
}

.status-opt[data-val="X"]:hover {
  border-color: var(--mangkir);
  color: var(--mangkir);
  background: var(--mangkir-bg);
}

.status-opt[data-val="MG"]:hover,
.status-opt[data-val="MG"].selected {
  border-color: var(--libur);
  color: var(--libur);
  background: var(--mangkir-bg);
}

.shift-only {
  display: none;
}

.shift-mode .shift-only {
  display: flex;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.btn-outline {
  border: 1.5px solid var(--divider);
  background: none;
  border-radius: 20px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-outline:hover {
  background: var(--bg);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-danger:hover {
  background: #b71c1c;
}

/* ==========================
   TOAST
========================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #323232;
  color: #fff;
  border-radius: 24px;
  padding: 12px 22px;
  font-size: .9rem;
  z-index: 9999;
  box-shadow: var(--shadow-md);
  transition: transform .3s, opacity .3s;
  opacity: 0;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================
   RESPONSIVE
========================== */
@media (min-width: 1081px) {
  .main-content {
    margin-left: var(--drawer-w);
    padding: 20px;
  }

  .drawer {
    transform: translateX(0);
    box-shadow: none;
    border-right: 1px solid var(--divider);
  }

  .drawer-overlay {
    display: none !important;
  }

  .menu-btn {
    display: none;
  }
}

@media (max-width: 1080px) {
  .subtab-btn span:not(.material-icons) {
    display: none;
  }

  .form-row {
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chart-label {
    width: 80px;
    font-size: .72rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Hide NIK and KET on mobile/tablet */
@media (max-width: 1080px) {

  .col-nik,
  .col-ket {
    display: none !important;
  }
}

/* Print styles */
@media print {

  .app-bar,
  .drawer,
  .subtab-bar,
  .legend-row,
  .status-banner {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .tab-section {
    display: block !important;
  }

  .subtab-content {
    display: block !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    margin-bottom: 20px;
  }

  .attendance-table th,
  .attendance-table td {
    border: 1px solid #999 !important;
  }
}

/* unit-tabs */
.unit-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--divider);
  padding-bottom: 4px;
}

.unit-tab {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-sec);
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: all 0.2s;
  position: relative;
}

.unit-tab:hover {
  background: rgba(0, 0, 0, 0.05);
}

.unit-tab.active {
  color: var(--primary);
}

.unit-tab.active::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

.unit-label {
  background: #e3f2fd;
  color: #1565c0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  vertical-align: middle;
  margin-left: 6px;
}

/* ===== Cell colors ===== */
.cell-H {
  background: var(--hadir) !important;
  color: #fff;
  font-weight: 700;
  border-radius: 3px;
}

.cell-I {
  background: var(--izin) !important;
  color: #fff;
  font-weight: 700;
  border-radius: 3px;
}

.cell-X {
  background: var(--mangkir) !important;
  color: #fff;
  font-weight: 700;
  border-radius: 3px;
}

.cell-MG {
  background: var(--libur) !important;
  color: transparent;
  border-radius: 3px;
}

.cell-M {
  background: #4527A0 !important;
  color: #fff;
  font-weight: 700;
  border-radius: 3px;
}

.cell-S {
  background: #00695C !important;
  color: #fff;
  font-weight: 700;
  border-radius: 3px;
}

.cell-P {
  background: #E65100 !important;
  color: #fff;
  font-weight: 700;
  border-radius: 3px;
}

/* JADWAL SHIFT (Transparan 30%) */
.cell-JD { background: rgba(56, 142, 60, 0.3) !important; color: #1b5e20; font-weight: 700; border-radius: 3px; border: 1px dashed #388e3c; }
.cell-JP { background: rgba(230, 81, 0, 0.3) !important; color: #e65100; font-weight: 700; border-radius: 3px; border: 1px dashed #e65100; }
.cell-JS { background: rgba(0, 105, 92, 0.3) !important; color: #004d40; font-weight: 700; border-radius: 3px; border: 1px dashed #00695c; }
.cell-JM { background: rgba(69, 39, 160, 0.3) !important; color: #311b92; font-weight: 700; border-radius: 3px; border: 1px dashed #4527a0; }

/* HADIR SHIFT (Solid) */
.cell-HD { background: #388e3c !important; color: #fff; font-weight: 700; border-radius: 3px; }
.cell-HP { background: #E65100 !important; color: #fff; font-weight: 700; border-radius: 3px; }
.cell-HS { background: #00695C !important; color: #fff; font-weight: 700; border-radius: 3px; }
.cell-HM { background: #4527A0 !important; color: #fff; font-weight: 700; border-radius: 3px; }


.cell-libur-merah {
  background: var(--libur) !important;
  color: transparent;
  border-radius: 3px;
}

.cell-empty {
  background: transparent;
}

/* Sunday column highlight */
.col-sunday {
  background: rgba(211, 47, 47, 0.08);
}

/* Saturday column highlight */
.col-saturday {
  background: rgba(255, 193, 7, 0.08);
}

/* Auth & User Management Styles */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.05);
  padding: 6px 14px;
  border-radius: 20px;
  margin-right: 12px;
}

.user-badge .material-icons {
  font-size: 20px;
  color: var(--primary);
}

#userNameDisplay {
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-admin {
  background: var(--role-admin) !important;
  color: #fff;
}

.badge-editor {
  background: var(--role-editor) !important;
  color: #fff;
}

.badge-viewer {
  background: var(--role-viewer) !important;
  color: #fff;
}

/* Read-Only mode overrides */
body.role-viewer .attendance-table td {
  cursor: default !important;
}

body.role-viewer .attendance-table td:hover {
  background: inherit !important;
}

@media print {

  .user-badge,
  #logoutBtn,
  .float-theme-toggle {
    display: none !important;
  }
}

/* =======================================
   FLOATING THEME TOGGLE (DAY/NIGHT)
   ======================================= */
.float-theme-toggle {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 80px;
  height: 40px;
  border-radius: 40px;
  border: none;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 1000;
  /* Light mode (Day) background */
  background: linear-gradient(180deg, #A1C4FD 0%, #C2E9FB 100%);
}

.float-theme-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

body.dark-mode .float-theme-toggle {
  /* Dark mode (Night) background */
  background: linear-gradient(180deg, #2A1B54 0%, #4D347B 100%);
}

.toggle-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Sun / Moon Circle */
.toggle-circle {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 10px 10px, #FFF387, #FBD124);
  box-shadow: 0 0 10px rgba(251, 209, 36, 0.5);
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

body.dark-mode .toggle-circle {
  left: calc(100% - 36px);
  background: radial-gradient(circle at 10px 10px, #EAEAEA, #C0C0C0);
  box-shadow: inset -4px -2px 5px rgba(0, 0, 0, 0.1), 0 0 8px rgba(255, 255, 255, 0.4);
}

/* Clouds / Stars Containers */
.clouds {
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 20px;
  background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 30" xmlns="http://www.w3.org/2000/svg"><path d="M 0 30 Q 15 15 25 25 Q 40 10 55 25 Q 70 15 85 25 Q 95 20 100 30 Z" fill="rgba(255,255,255,0.8)"/></svg>') repeat-x;
  background-size: 60px 20px;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.5s ease;
  transform: translateY(0);
}

body.dark-mode .clouds {
  opacity: 0.2;
  /* Subtly keep clouds as dark night clouds, or fade out */
  transform: translateY(5px);
  fill: #222;
}

.stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease;
  background-image:
    radial-gradient(1px 1px at 10px 10px, #fff, transparent),
    radial-gradient(1px 1px at 30px 20px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 15px 30px, #fff, transparent),
    radial-gradient(2px 2px at 45px 15px, #fff, transparent),
    radial-gradient(1px 1px at 25px 5px, #fff, transparent);
}

body.dark-mode .stars {
  opacity: 1;
}

/* =======================================
   REORDER MODE STYLES
   ======================================= */
.reorder-input {
  width: 45px;
  padding: 4px;
  text-align: center;
  border-radius: 4px;
  border: 1px solid var(--divider);
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
  margin: 0 auto;
  display: block;
}

.reorder-mode tr:hover td {
  background: rgba(0, 122, 255, 0.05) !important;
}

.reorder-mode td.col-no {
  background: rgba(0, 122, 255, 0.1) !important;
}

.btn-reorder.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

.subtab-bar.unit-tabs {
  margin-top: 10px;
}

.reorder-mode tr {
  cursor: grab;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reorder-mode tr:active {
  cursor: grabbing;
}

.reorder-mode tr.dragging {
  opacity: 0.5;
  background: var(--primary-light) !important;
  transform: scale(0.98);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.reorder-mode tr.drag-over {
  border-top: 2px solid var(--primary);
}