/* ==========================================================================
   CAPWAKTU WEB CAMERA & PRESENSI PWA (EXACT ANDROID REPLICA)
   Color System from Android: BrandOrange (#FF6D00), DarkCard (#151F32),
   WatermarkAccent (#FDE047 / #FFD700), EmeraldGreen (#22C55E)
   ========================================================================== */

:root {
  --bg-dark: #000000;
  --bg-card: rgba(21, 31, 50, 0.95);
  --bg-card-subtle: rgba(30, 41, 59, 0.85);
  --brand-orange: #FF6D00;
  --brand-orange-light: #FF9E40;
  --brand-orange-dark: #E65100;
  --color-green: #22C55E;
  --color-amber: #F59E0B;
  --color-gold: #FFD700;
  --color-yellow: #FDE047;
  --color-purple: #A855F7;
  --color-blue: #2979FF;
  --color-red: #EF4444;
  --text-white: #FFFFFF;
  --text-gray: #CBD5E1;
  --text-muted: #94A3B8;
  --border-color: rgba(255, 255, 255, 0.18);
  --border-orange: rgba(255, 109, 0, 0.6);
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #000000;
  color: var(--text-white);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#app-container {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================================
   CAMERA VIEWFINDER
   ========================================================================== */
.camera-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  z-index: 1;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(1);
  -webkit-transform: scaleX(1);
  -webkit-transform-style: preserve-3d;
  -webkit-backface-visibility: hidden;
  will-change: filter, -webkit-filter, transform;
}

#camera-video.flipped {
  transform: scaleX(-1);
  -webkit-transform: scaleX(-1);
}

/* Efek Kamera Wajah Bersih (Live Beauty Soft-Skin Diffusion & Glow) */
#beauty-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 245, 248, 0.32) 0%, rgba(255, 230, 240, 0.18) 50%, rgba(255, 255, 255, 0.05) 100%);
  mix-blend-mode: soft-light;
  -webkit-mix-blend-mode: soft-light;
  backdrop-filter: blur(8px) brightness(1.18) saturate(1.12);
  -webkit-backdrop-filter: blur(8px) brightness(1.18) saturate(1.12);
  opacity: 0;
  transition: opacity 0.15s ease-out;
  z-index: 1;
}

.pill-btn.beauty-active {
  background: rgba(236, 72, 153, 0.28) !important;
  border-color: #F472B6 !important;
  color: #FBCFE8 !important;
  box-shadow: 0 0 10px rgba(244, 114, 182, 0.35);
}

/* Rule of Thirds Grid */
.camera-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
  z-index: 2;
}

.camera-grid.active {
  display: block;
}

.grid-line-h1 { position: absolute; top: 33.33%; left: 0; width: 100%; height: 1px; background: rgba(255, 255, 255, 0.28); }
.grid-line-h2 { position: absolute; top: 66.66%; left: 0; width: 100%; height: 1px; background: rgba(255, 255, 255, 0.28); }
.grid-line-v1 { position: absolute; left: 33.33%; top: 0; width: 1px; height: 100%; background: rgba(255, 255, 255, 0.28); }
.grid-line-v2 { position: absolute; left: 66.66%; top: 0; width: 1px; height: 100%; background: rgba(255, 255, 255, 0.28); }

/* Shutter White Flash */
#flash-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 99;
  transition: opacity 0.1s ease-out;
}

#flash-overlay.flashing {
  opacity: 1;
}

/* Torch Full Screen Glow */
#torch-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  pointer-events: none;
  display: none;
  z-index: 3;
}

#torch-overlay.active {
  display: block;
}

/* Self Timer Countdown Overlay */
#countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#countdown-overlay.active {
  display: flex;
}

.countdown-number {
  font-size: 110px;
  font-weight: 900;
  color: #FFD700;
  text-shadow: 0 4px 20px rgba(0,0,0,0.8);
  animation: countdown-pop 1s infinite;
}

@keyframes countdown-pop {
  0% { transform: scale(0.6); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   TOP BAR (HORIZONTAL SCROLLING - EXACT LIKE ANDROID)
   ========================================================================== */
.top-bar-wrapper {
  position: relative;
  z-index: 10;
  width: 100%;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 70%, rgba(0,0,0,0) 100%);
  padding-top: env(safe-area-inset-top, 10px);
}

.top-bar-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.top-bar-scroll::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 12px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.15s;
}

.pill-btn:active {
  transform: scale(0.94);
  background: rgba(255, 109, 0, 0.3);
}

.pill-btn.active {
  background: rgba(255, 109, 0, 0.35);
  border-color: var(--brand-orange);
  color: #FF9E40;
}

.icon-round-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.15s;
}

.icon-round-btn:active {
  transform: scale(0.92);
  background: var(--brand-orange);
}

.icon-round-btn.active {
  background: rgba(255, 235, 59, 0.3);
  border-color: #FFEB3B;
  color: #FFEB3B;
}

/* GPS Status Sub-Header */
.gps-sub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 14px 6px 14px;
}

.gps-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--text-gray);
  font-weight: 500;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--color-green);
  box-shadow: 0 0 8px var(--color-green);
  animation: pulse-anim 1.5s infinite;
}

.pulse-dot.searching {
  background-color: var(--color-amber);
  box-shadow: 0 0 8px var(--color-amber);
}

@keyframes pulse-anim {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

/* ==========================================================================
   WATERMARK STAMP OVERLAY (EXACT ANDROID STYLING)
   ========================================================================== */
.watermark-container {
  position: absolute;
  bottom: 146px;
  left: 12px;
  right: 12px;
  z-index: 10;
  pointer-events: none;
}

/* Themes matching WatermarkStyle.kt */
.watermark-card {
  background: rgba(18, 18, 18, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  display: flex;
  gap: 12px;
  align-items: center;
  transition: all 0.25s;
}

/* Style: OFFICIAL_GOLD */
.watermark-card.style-gold {
  background: rgba(22, 18, 10, 0.90);
  border: 1.8px solid #FFD700;
}

/* Style: SAFETY_K3 */
.watermark-card.style-k3 {
  background: rgba(12, 22, 14, 0.90);
  border: 1.8px solid #76FF03;
}

/* Style: CORPORATE_BLUE */
.watermark-card.style-blue {
  background: rgba(10, 20, 36, 0.90);
  border: 1.8px solid #2979FF;
}

/* Style: GLASSMORPHISM */
.watermark-card.style-glass {
  background: rgba(30, 40, 55, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.5);
}

.wm-text-col {
  flex: 1;
  min-width: 0;
}

.wm-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wm-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-yellow);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wm-org {
  font-size: 11.5px;
  font-weight: 600;
  color: #FFFFFF;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wm-notes {
  font-size: 10.5px;
  font-weight: 600;
  color: #60A5FA;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wm-time {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--color-green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-top: 3px;
}

.wm-address {
  font-size: 10px;
  color: var(--text-gray);
  margin-top: 2px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wm-coords {
  font-size: 9.5px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-top: 2px;
}

.wm-seal {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--color-green);
  margin-top: 4px;
}

/* Watermark Mini-Map / QR */
.wm-side-box {
  width: 76px;
  height: 76px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--color-yellow);
  position: relative;
  flex-shrink: 0;
  background: #1E293B;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.wm-side-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wm-map-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--color-red);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0,0,0,0.8);
}

/* ==========================================================================
   BOTTOM CONTROLS (EXACT ANDROID REPLICA)
   ========================================================================== */
.bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px calc(env(safe-area-inset-bottom, 12px) + 12px) 16px;
  background: linear-gradient(0deg, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.4) 65%, rgba(0,0,0,0) 100%);
}

/* Mode Selector: MASUK | KELUAR ISTIRAHAT | KEMBALI KERJA | PULANG | TUGAS LUAR | IJIN */
.mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 5px 8px;
  border-radius: 24px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.mode-selector::-webkit-scrollbar {
  display: none;
}

.mode-pill {
  padding: 6px 14px;
  border-radius: 18px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.mode-pill.active[data-mode="MASUK"] {
  background: var(--color-green);
  color: #fff;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

.mode-pill.active[data-mode="KELUAR_ISTIRAHAT"] {
  background: #F97316;
  color: #fff;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4);
}

.mode-pill.active[data-mode="KEMBALI_KERJA"] {
  background: #06B6D4;
  color: #fff;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.4);
}

.mode-pill.active[data-mode="PULANG"] {
  background: var(--color-amber);
  color: #fff;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.mode-pill.active[data-mode="TUGAS_LAPANGAN"] {
  background: var(--color-purple);
  color: #fff;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.4);
}

.mode-pill.active[data-mode="IJIN"] {
  background: #6366F1;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* Shutter Row */
.shutter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 360px;
  padding: 0 10px;
}

/* Shutter Button (Dual Ring - Exact Android) */
.shutter-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: transparent;
  border: 4px solid #FFFFFF;
  padding: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.shutter-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6D00, #FF9E40);
  box-shadow: 0 4px 15px rgba(255, 109, 0, 0.5);
  transition: transform 0.1s;
}

.shutter-btn:active {
  transform: scale(0.92);
}

.shutter-btn:active .shutter-inner {
  transform: scale(0.85);
}

/* Gallery Thumb Button */
.gallery-thumb-btn {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid var(--border-color);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.gallery-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Import Gallery Stamp Button */
.import-stamp-btn {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid var(--border-color);
  color: #FDE047;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.import-stamp-btn span {
  font-size: 8.5px;
  font-weight: 700;
  color: #fff;
  margin-top: 1px;
}

/* ==========================================================================
   BOTTOM SHEETS & MODALS (EXACT ANDROID BOTTOM SHEETS)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
}

.bottom-sheet {
  background: var(--bg-card);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border: 1px solid var(--border-color);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
  margin: 10px auto 4px auto;
}

.sheet-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.sheet-close-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
}

.sheet-body {
  padding: 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Grid for Templates / Styles */
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.sheet-grid-item {
  background: rgba(30, 41, 59, 0.6);
  border: 1.5px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: all 0.2s;
}

.sheet-grid-item.selected {
  border-color: var(--brand-orange);
  background: rgba(255, 109, 0, 0.15);
}

.sheet-grid-item:active {
  transform: scale(0.96);
}

.sheet-item-icon {
  font-size: 24px;
}

.sheet-item-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.sheet-item-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Form controls */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: #fff;
  font-size: 13px;
  outline: none;
}

.form-input:focus {
  border-color: var(--brand-orange);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #FF6D00, #EA580C);
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255, 109, 0, 0.4);
}

.btn-secondary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

/* iOS PWA Step Instructions */
@keyframes pulse-subtle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.ios-instruction-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ios-step-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px;
}

.ios-step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-orange), #F59E0B);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(255, 109, 0, 0.4);
}

.ios-step-info {
  flex: 1;
}

.ios-step-title {
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 3px;
}

.ios-step-desc {
  font-size: 11.5px;
  color: var(--text-gray);
  line-height: 1.5;
}

.ios-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 2px 6px;
  margin: 0 2px;
  vertical-align: middle;
}
