/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:    #003366;
  --indigo:  #4f46e5;
  --green:   #137333;
  --red:     #d93025;
  --slate:   #1e293b;
  --muted:   #64748b;
  --light:   #f8fafc;
  --border:  #e2e8f0;
  --white:   #ffffff;
  --radius:  16px;
  --shadow:  0 2px 16px rgba(0,0,0,0.07);
}

html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--light); color: var(--slate); font-size: 14px; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; outline: none; border: none; background: none; width: 100%; }
textarea { resize: none; }

.hidden { display: none !important; }

/* ===== SPINNER ===== */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-lg {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: flex; height: 100vh; }

/* ===== LOGIN ===== */
.login-bg {
  flex: 1;
  background: linear-gradient(135deg, #eef2ff 0%, #f0f8ff 60%, #e0e7ff 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: 24px;
  padding: 36px 32px;
  width: 100%; max-width: 420px;
  box-shadow: 0 8px 40px rgba(79,70,229,0.12);
  border: 1px solid #e0e7ff;
}
.login-logo { text-align: center; margin-bottom: 24px; }
.logo-box {
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--navy); border-radius: 14px;
  padding: 10px 18px;
}
.logo-box.small { padding: 7px 12px; gap: 9px; }
.logo-r {
  font-size: 28px; font-weight: 900; color: #fff;
  width: 36px; height: 36px; background: var(--indigo);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.logo-box.small .logo-r { font-size: 20px; width: 28px; height: 28px; border-radius: 8px; }
.logo-text-group { display: flex; flex-direction: column; }
.logo-rawuh { color: #fff; font-weight: 800; font-size: 16px; letter-spacing: 1px; line-height: 1.1; }
.logo-sub { color: #93c5fd; font-size: 10px; font-weight: 500; }
.logo-box.small .logo-rawuh { font-size: 13px; }
.logo-box.small .logo-sub { font-size: 9px; }
.login-tagline { color: var(--muted); font-size: 12px; margin-top: 12px; }
.login-title { font-size: 20px; font-weight: 700; color: var(--slate); margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 7px; }
.input-wrapper {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--border); border-radius: 12px;
  padding: 0 14px; height: 48px; background: var(--light);
  transition: border-color 0.2s;
}
.input-wrapper:focus-within { border-color: var(--indigo); }
.input-wrapper i { color: #94a3b8; flex-shrink: 0; }
.input-wrapper.textarea-wrap { height: auto; padding: 12px 14px; align-items: flex-start; }
.input-wrapper.textarea-wrap i { margin-top: 2px; }
.toggle-pass { color: #6b7280; display: flex; align-items: center; padding: 4px; }
.btn-primary {
  width: 100%; height: 48px; border-radius: 12px;
  background: var(--navy); color: #fff;
  font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px; transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.6; pointer-events: none; }
.forgot-link { display: block; text-align: center; color: var(--muted); font-size: 12px; text-decoration: underline; margin-top: 14px; }
.login-footer { display: flex; flex-direction: column; align-items: center; margin-top: 30px; gap: 4px; }
.credit { font-size: 13px; font-weight: 700; color: var(--indigo); }
.version { font-size: 11px; color: #94a3b8; }
.error-msg { background: #fef2f2; border: 1px solid #fca5a5; color: var(--red); font-size: 12px; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }

/* ===== MAIN APP LAYOUT ===== */
#screen-main {
  display: none; flex-direction: row;
}
#screen-main.active { display: flex; }

/* SIDEBAR */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--navy);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.sidebar-header { padding: 24px 20px 20px; }
.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  color: #93c5fd; font-size: 13px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--indigo); color: #fff; }
.nav-item i { width: 18px; text-align: center; }
.sidebar-footer { padding: 16px 20px 24px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  color: #f87171; font-size: 13px; font-weight: 600;
  padding: 8px 12px; border-radius: 10px;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(239,68,68,0.12); }
.sidebar-footer .credit { color: #4f46e5; font-size: 11px; }

/* MAIN CONTENT */
.main-content {
  flex: 1; overflow-y: auto; position: relative;
  padding-bottom: 70px; /* space for mobile bottom bar */
}
.hamburger {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 200;
  background: var(--navy); color: #fff;
  width: 40px; height: 40px; border-radius: 10px;
  font-size: 16px; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

/* TABS */
.tab-content { display: none; padding: 0 24px 32px; animation: fadeIn 0.25s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* BOTTOM TAB BAR */
.bottom-tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--white); border-top: 1px solid var(--border);
  height: 60px;
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: #6b7280; font-size: 10px; font-weight: 600;
  transition: color 0.15s;
}
.tab-btn i { font-size: 20px; }
.tab-btn.active { color: var(--indigo); }

/* ===== HERO HEADER ===== */
.hero-header {
  background: var(--navy);
  padding: 32px 24px 20px;
  display: flex; justify-content: space-between; align-items: flex-start;
  margin: 0 -24px;
}
.hero-greeting { color: #94a3b8; font-size: 12px; margin-bottom: 4px; }
.hero-name { color: #fff; font-size: 22px; font-weight: 800; line-height: 1.2; }
.hero-role { color: #93c5fd; font-size: 10px; font-weight: 600; display: block; margin-top: 4px; }
.hero-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: #fff; color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; border: 2px solid #3b82f6; flex-shrink: 0;
}

/* SCHEDULE CARD */
.schedule-card {
  background: var(--white); border-radius: 20px;
  padding: 20px; margin: 16px 0;
  box-shadow: var(--shadow);
}
.schedule-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.schedule-label { font-size: 12px; font-weight: 700; color: #475569; }
.schedule-date { font-size: 11px; color: #94a3b8; }
.schedule-time { font-size: 28px; font-weight: 800; color: var(--slate); text-align: center; margin: 12px 0; }
.btn-checkin-main {
  width: 100%; height: 46px; border-radius: 12px;
  background: var(--indigo); color: #fff;
  font-weight: 700; font-size: 14px; display: flex;
  align-items: center; justify-content: center; gap: 8px;
  transition: opacity 0.2s;
}
.btn-checkin-main:hover { opacity: 0.88; }

/* SECTION TITLE */
.section-title { font-size: 14px; font-weight: 700; color: var(--slate); margin: 20px 0 12px; }
.section-header-row { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; margin-bottom: 12px; }
.view-all { font-size: 12px; color: var(--indigo); font-weight: 600; }

/* FEATURE GRID */
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.feature-card {
  background: var(--white); border-radius: 16px;
  padding: 14px 12px; display: flex; align-items: center; gap: 12px;
  border: 1px solid #f1f5f9; cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
  transition: transform 0.15s, box-shadow 0.15s;
}
.feature-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.09); }
.feat-icon {
  width: 44px; height: 44px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 18px;
}
.feat-title { font-size: 12px; font-weight: 700; color: var(--slate); }
.feat-desc { font-size: 10px; color: #94a3b8; margin-top: 2px; }

/* HISTORY CARDS */
.history-card {
  background: var(--white); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 10px;
  border: 1px solid #f1f5f9;
}
.history-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.history-date { font-size: 11px; font-weight: 700; color: #475569; }
.feat-badge {
  background: #f1f5f9; border-radius: 6px;
  padding: 3px 8px; font-size: 10px; color: var(--indigo); font-weight: 700;
}
.history-times { display: flex; gap: 20px; }
.time-item { display: flex; align-items: center; gap: 8px; }
.time-item i { font-size: 15px; }
.time-sub { font-size: 10px; color: #94a3b8; }
.time-val { font-size: 13px; font-weight: 700; color: var(--slate); }

/* HOME FOOTER */
.home-footer { display: flex; flex-direction: column; align-items: center; margin-top: 28px; margin-bottom: 10px; gap: 8px; }

/* PAGE HEADER */
.page-header {
  background: var(--navy); margin: 0 -24px;
  padding: 24px 24px 16px;
  display: flex; align-items: center; gap: 14px;
}
.page-header h1 { color: #fff; font-size: 16px; font-weight: 700; }
.page-header.with-back { }
.btn-back {
  background: rgba(255,255,255,0.12); color: #fff;
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  transition: background 0.15s;
}
.btn-back:hover { background: rgba(255,255,255,0.2); }

/* LIST CONTAINER */
.list-container { padding: 16px 0; }
.request-card {
  background: var(--white); border-radius: 14px;
  padding: 16px; margin-bottom: 12px;
  border: 1px solid #f1f5f9; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.req-card-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.req-card-title { font-size: 13px; font-weight: 700; color: var(--slate); }
.req-card-date { font-size: 11px; color: #94a3b8; }
.req-card-user { font-size: 12px; color: #475569; margin-bottom: 4px; }
.req-card-sub { font-size: 11px; color: #94a3b8; }
.badge-approved {
  display: inline-block; background: #e6f4ea;
  color: var(--green); font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 6px; margin-top: 10px;
}

/* PROFILE */
.profile-card {
  background: var(--white); border-radius: 20px;
  padding: 32px 24px; margin-top: 20px;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: var(--shadow);
}
.profile-avatar {
  width: 96px; height: 96px; border-radius: 50%;
  background: #eef2ff; color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; border: 2px solid var(--indigo);
  box-shadow: 0 4px 20px rgba(79,70,229,0.15);
}
.profile-name { font-size: 22px; font-weight: 800; color: var(--slate); margin-top: 16px; }
.profile-nik { color: var(--indigo); font-size: 13px; font-weight: 600; margin-top: 4px; }
.profile-role-tag { color: var(--muted); font-size: 11px; font-weight: 600; margin-top: 4px; }
.profile-actions { width: 100%; margin-top: 32px; display: flex; flex-direction: column; gap: 12px; }
.btn-profile-blue {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #eef2ff; color: var(--indigo);
  font-weight: 700; font-size: 14px;
  padding: 14px; border-radius: 12px;
  transition: background 0.15s;
}
.btn-profile-blue:hover { background: #e0e7ff; }
.btn-profile-red {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #fef2f2; color: var(--red);
  font-weight: 700; font-size: 14px;
  padding: 14px; border-radius: 12px;
  transition: background 0.15s;
}
.btn-profile-red:hover { background: #fee2e2; }

/* FORM CARD */
.form-card {
  background: var(--white); border-radius: 20px;
  padding: 24px; margin-top: 20px;
  box-shadow: var(--shadow);
}
.form-section-title {
  font-size: 15px; font-weight: 700; color: var(--slate);
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.upload-area {
  border: 1.5px dashed #c7d2fe; border-radius: 12px;
  background: #e0e7ff;
  height: 90px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; color: var(--indigo);
  font-size: 12px; font-weight: 600;
  transition: background 0.15s;
}
.upload-area:hover { background: #c7d2fe; }
.upload-area i { font-size: 24px; }
.btn-success {
  width: 100%; height: 48px; border-radius: 12px;
  background: var(--green); color: #fff;
  font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px; transition: opacity 0.2s;
}
.btn-success:hover { opacity: 0.88; }
.btn-success:disabled { opacity: 0.6; pointer-events: none; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-box {
  background: var(--white); width: 100%; max-width: 640px;
  border-radius: 24px 24px 0 0;
  max-height: 92vh; overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-header {
  background: var(--navy);
  padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 24px 24px 0 0;
}
.modal-header h2 { color: #fff; font-size: 15px; font-weight: 700; }
.modal-back, .modal-refresh {
  color: #fff; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 16px;
  transition: background 0.15s;
}
.modal-back:hover, .modal-refresh:hover { background: rgba(255,255,255,0.12); }
.modal-header-simple {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.modal-header-simple h2 { font-size: 16px; font-weight: 700; }
.modal-header-simple button { color: #6b7280; font-size: 20px; }
.password-modal { padding: 0 24px 28px; border-radius: 24px; margin: 40px 16px; align-self: center; }

/* ABSENSI MODAL */
.absensi-modal { padding-bottom: 24px; }
.absensi-body { display: flex; flex-direction: column; }
.map-container {
  background: #f0f8ff; min-height: 130px;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.map-status { display: flex; flex-direction: column; align-items: center; color: #64748b; padding: 20px; text-align: center; }
.map-info { display: flex; align-items: center; gap: 14px; padding: 18px 24px; width: 100%; }
.map-pin { font-size: 32px; color: var(--red); }
.map-coords { font-size: 12px; font-weight: 700; color: var(--slate); }
.map-address { font-size: 11px; color: var(--muted); margin-top: 2px; }
.absensi-panel { display: flex; gap: 14px; padding: 16px; }
.camera-box {
  flex: 0 0 48%; background: #f1f5f9;
  border-radius: 14px; overflow: hidden;
  position: relative; min-height: 160px;
}
#camera-video { width: 100%; height: 160px; object-fit: cover; display: block; background: #000; }
.snap-btn {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: var(--indigo); color: #fff;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
#captured-photo { width: 100%; height: 160px; object-fit: cover; display: block; }
.retake-btn {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 5px 12px; border-radius: 8px;
}
.camera-error {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #94a3b8; font-size: 13px; gap: 6px;
}
.camera-error i { font-size: 28px; }
.info-panel { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.info-row { display: flex; align-items: flex-start; gap: 10px; }
.info-row > i { font-size: 18px; margin-top: 2px; flex-shrink: 0; }
.info-label { font-size: 10px; color: #94a3b8; }
.info-value { font-size: 13px; font-weight: 700; color: var(--slate); }
.badge-out { display: inline-block; background: #fce8e6; color: var(--red); font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 5px; margin-top: 3px; }
.badge-in  { display: inline-block; background: #e6f4ea; color: var(--green); font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 5px; margin-top: 3px; }
.btn-submit-absensi {
  width: 100%; height: 42px; border-radius: 11px;
  background: var(--indigo); color: #fff;
  font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity 0.2s;
}
.btn-submit-absensi:hover { opacity: 0.88; }
.btn-submit-absensi:disabled { opacity: 0.6; pointer-events: none; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff;
  padding: 12px 22px; border-radius: 50px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  z-index: 999; animation: fadeIn 0.3s ease;
  white-space: nowrap;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ===== SIDEBAR OVERLAY MOBILE ===== */
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 150;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { 
    position: fixed; left: -220px; top: 0; z-index: 160;
    transition: left 0.28s ease; height: 100vh;
  }
  .sidebar.open { left: 0; }
  .hamburger { display: flex; }
  .bottom-tabbar { display: flex; }
  .main-content { padding-bottom: 60px; }
  .tab-content { padding: 0 16px 32px; }
  .hero-header { margin: 0 -16px; padding-top: 60px; }
  .page-header { margin: 0 -16px; }
  .form-card { margin-top: 16px; }
  .feature-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .absensi-panel { flex-direction: column; }
  .camera-box { flex: none; min-height: 180px; }
  #camera-video, #captured-photo { height: 180px; }
  .password-modal { margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .modal-box { max-height: 88vh; }
}

@media (min-width: 769px) {
  .main-content { padding-top: 0; }
  .tab-content { padding-top: 28px; }
}
