/**
 * NOMMY AbsensiPro — Custom Theme
 * Brand: #ba8c67 (warm gold / coffee)
 */
:root {
  --brand: #ba8c67;
  --brand-dark: #9a704f;
  --brand-darker: #7d5a3f;
  --brand-light: #d4b08e;
  --brand-soft: #f5ebe0;
  --brand-muted: #e8d5c4;

  --primary: #ba8c67;
  --primary-dark: #9a704f;
  --primary-light: #d4b08e;

  --success: #2f9e6e;
  --success-soft: #d8f3e7;
  --warning: #c9891a;
  --warning-soft: #fef3c7;
  --danger: #c44b4b;
  --danger-soft: #fde8e8;
  --info: #5a7fa8;
  --info-soft: #e8f0f8;

  --bg: #f7f3ef;
  --card: #ffffff;
  --text: #2c241c;
  --text-muted: #7a6b5d;
  --border: #e5d9ce;

  --radius: 12px;
  --shadow: 0 4px 14px rgba(122, 90, 63, 0.10);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --header-h: 56px;
  --bottom-h: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  font-size: 16px;
}

.hidden { display: none !important; }

/* ========== Splash ========== */
.splash {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, var(--brand-darker) 0%, var(--brand) 45%, var(--brand-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: white;
}
.splash-content { text-align: center; }
.splash-icon { font-size: 64px; margin-bottom: 16px; animation: pulse 1.5s infinite; }
.splash h1 { font-size: 28px; font-weight: 700; letter-spacing: 0.02em; }
.splash p { opacity: 0.92; margin-top: 4px; }
.splash-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 24px;
  background: #fff;
  padding: 12px;
  margin: 0 auto 16px;
  display: block;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
}
.app-logo {
  max-width: 160px;
  max-height: 80px;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
}
.app-logo-sm {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}
.loader {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  margin: 24px auto 0;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* ========== Auth ========== */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--brand-darker) 0%, var(--brand) 50%, var(--brand-light) 100%);
}
.auth-card {
  background: var(--card);
  border-radius: 20px;
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
}
.logo-area { text-align: center; margin-bottom: 28px; }
.logo-area i { font-size: 48px; color: var(--brand); }
.logo-area h1 { font-size: 24px; margin-top: 8px; color: var(--text); }
.logo-area p { color: var(--text-muted); font-size: 14px; }

.role-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}
.role-btn {
  background: var(--brand-soft);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.role-btn i { font-size: 24px; color: var(--brand); }
.role-btn.active {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(186, 140, 103, 0.2);
}

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(186, 140, 103, 0.18);
}
.hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; text-align: center; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover, .btn-primary:active { background: var(--brand-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover, .btn-outline:active {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-soft);
}

/* ========== App shell ========== */
.app {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.header {
  min-height: var(--header-h);
  height: auto;
  background: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top, env(safe-area-inset-top, 0px))) 12px 10px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(125, 90, 63, 0.25);
}
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header h2 { font-size: 17px; font-weight: 600; }
.user-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.22);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:active { background: rgba(0,0,0,0.1); }
.icon-btn.spinning i { animation: spin 0.8s linear infinite; }
.icon-btn:disabled { opacity: 0.6; pointer-events: none; }

/* Side menu */
.side-menu {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: white;
  z-index: 200;
  transform: translateX(-105%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}
.side-menu.open { transform: translateX(0); }
.side-header {
  background: var(--brand);
  color: white;
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 18px;
}
.side-header i { font-size: 28px; }
.menu-list { list-style: none; flex: 1; overflow-y: auto; padding: 8px 0; }
.menu-list li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  transition: background 0.15s;
}
.menu-list li a:active,
.menu-list li a.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.menu-list li i { width: 22px; text-align: center; color: var(--brand); }
.side-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 28, 0.45);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.menu-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Content */
.content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--bottom-h) + 16px + var(--safe-bottom));
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bottom-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 40;
  box-shadow: 0 -2px 12px rgba(122, 90, 63, 0.08);
}
.bottom-nav button,
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
}
.bottom-nav a.active,
.bottom-nav button.active {
  color: var(--brand-dark);
  font-weight: 600;
}
.bottom-nav i { font-size: 20px; }

/* Cards & stats */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.stat-box {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-box .value { font-size: 24px; font-weight: 700; color: var(--brand-dark); }
.stat-box .label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Attendance */
.attendance-hero {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 55%, var(--brand-light) 100%);
  color: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(154, 112, 79, 0.28);
}
.attendance-hero .clock {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.attendance-hero .date { opacity: 0.92; font-size: 14px; margin-top: 4px; }
.attendance-hero .status-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255,255,255,0.22);
}

.camera-box {
  position: relative;
  width: min(200px, 52vw);
  height: min(200px, 52vw);
  max-width: 220px;
  margin: 8px auto 10px;
  border-radius: 50%;
  overflow: hidden;
  background: #1a1410;
  aspect-ratio: 1 / 1;
  box-shadow: var(--shadow);
  border: 3px solid rgba(186, 140, 103, 0.35);
}
.camera-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}
.camera-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.face-guide {
  width: 78%;
  height: 78%;
  border: 2px dashed rgba(255,255,255,0.5);
  border-radius: 50%;
}

/* Attendance compact — status di atas, tombol tidak perlu scroll */
.att-compact .attendance-hero {
  padding: 8px 12px !important;
  margin-bottom: 8px;
}
.att-compact .attendance-hero .clock { font-size: 22px; }
.att-compact .attendance-hero .date { font-size: 12px; }
.att-compact .gps-status,
.att-compact .face-status {
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 12px;
}
.att-compact .punch-btn {
  padding: 14px 10px;
}
.att-compact .punch-btn .punch-icon { font-size: 28px; }
.att-compact .punch-btn .punch-label { font-size: 14px; }
.att-compact p.att-hint { margin-top: 8px !important; font-size: 11px !important; }


.gps-status,
.face-status {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.gps-status.ok, .face-status.ok {
  background: var(--success-soft);
  color: #1f6b4a;
}
.gps-status.warn, .face-status.warn {
  background: var(--warning-soft);
  color: #8a5a10;
}
.gps-status.err, .face-status.err {
  background: var(--danger-soft);
  color: #8b2e2e;
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.action-row .btn { flex: 1; }

/* Lists */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .name { font-weight: 600; font-size: 14px; }
.list-item .info .meta { font-size: 12px; color: var(--text-muted); }

.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.badge-success { background: var(--success-soft); color: #1f6b4a; }
.badge-warning { background: var(--warning-soft); color: #8a5a10; }
.badge-danger { background: var(--danger-soft); color: #8b2e2e; }
.badge-info { background: var(--info-soft); color: #3d5a7a; }

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 8px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
}

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}
.empty i { font-size: 36px; margin-bottom: 8px; opacity: 0.5; color: var(--brand); }

.shift-pill {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.loc-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}
.loc-card.active { border-color: var(--brand); }
.loc-card .coords {
  font-size: 12px;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.photo-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 28, 0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: white;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 18px calc(20px + var(--safe-bottom));
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 18px; color: var(--text); }
.modal-close {
  border: none;
  background: var(--brand-soft);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  color: var(--brand-dark);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 400;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Success overlay (CSS fallback — JS also uses inline) */
.att-success-overlay {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  z-index: 99999 !important;
  background: var(--brand) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}
.att-success-card {
  background: rgba(255,255,255,0.16);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 24px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  color: #fff;
  box-shadow: 0 20px 50px rgba(0,0,0,0.28);
}
.att-success-check {
  font-size: 64px;
  color: #fff;
  line-height: 1;
  margin-bottom: 8px;
}
.att-success-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #fff;
}
.att-success-photo {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: 16px;
  margin: 12px auto;
  display: block;
  border: 3px solid #fff;
}
.att-success-emoji { font-size: 64px; margin: 12px 0; }
.att-success-type { font-size: 20px; font-weight: 700; margin: 10px 0 4px; color: #fff; }
.att-success-name { font-size: 16px; margin: 0; color: #fff; }
.att-success-meta { font-size: 13px; margin: 10px 0 12px; color: rgba(255,255,255,0.9); }
.att-success-extra { margin-top: 8px; font-size: 13px; color: rgba(255,255,255,0.9); }
.att-success-wa { margin-top: 14px; font-size: 12px; color: rgba(255,255,255,0.85); }
.att-success-card .btn,
.att-success-card .btn-success-done {
  background: #fff !important;
  color: var(--brand-darker) !important;
  font-weight: 700;
  margin-top: 20px;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  cursor: pointer;
  width: 100%;
}


/* Home shortcuts & punch */
.home-shortcuts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.home-sc {
  background: var(--brand-soft);
  border: none;
  border-radius: 14px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--brand-darker);
  font-size: 12px;
  font-weight: 600;
}
.home-sc i { font-size: 22px; color: var(--brand); }
.home-sc:active { transform: scale(0.96); opacity: 0.9; }

.punch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}
.punch-btn {
  border: none;
  border-radius: 16px;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.punch-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.punch-btn .punch-icon { font-size: 36px; line-height: 1; }
.punch-btn .punch-label { font-size: 16px; }
.punch-btn small { font-size: 11px; font-weight: 500; opacity: 0.85; }
.punch-in { background: linear-gradient(145deg, #fef9c3, #fde047); color: #854d0e; }
.punch-out { background: linear-gradient(145deg, #e0e7ff, #a5b4fc); color: #312e81; }
.punch-home-card { padding: 14px; }

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.profile-row:last-child { border-bottom: none; }
.profile-label { color: var(--text-muted); }
.profile-val { font-weight: 600; text-align: right; color: var(--text); }

.cal-month { text-align: center; font-weight: 700; margin: 8px 0 12px; }
.cal-grid-head, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: 11px;
}
.cal-grid-head { font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.cal-cell {
  min-height: 52px;
  border-radius: 8px;
  background: #f8fafc;
  padding: 4px 2px;
}
.cal-cell.empty { background: transparent; }
.cal-cell.today { outline: 2px solid var(--brand); }
.cal-cell.normal { background: #d1fae5; }
.cal-cell.late { background: #ffedd5; }
.cal-cell.partial { background: #e0e7ff; }
.cal-num { font-weight: 700; font-size: 12px; }
.cal-times { font-size: 9px; line-height: 1.2; color: #334155; margin-top: 2px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; font-size: 12px; }
.cal-legend .leg {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: middle;
}
.leg.normal { background: #d1fae5; }
.leg.late { background: #ffedd5; }
.leg.partial { background: #e0e7ff; }
