/* ============================================================
   ABSENSI PNS — main.css (Phase 06 PWA / Mobile Attendance)
   Responsive mobile-first styling for PNS attendance.
   Branding: E-PRESENSI DINAS KETAHANAN PANGAN KABUPATEN MUSI RAWAS UTARA.
   ============================================================ */

:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-muted: #4b5563;
  --color-primary: #1d4ed8;
  --color-primary-hover: #1e40af;
  --color-success: #15803d;
  --color-success-bg: #dcfce7;
  --color-warning: #b45309;
  --color-warning-bg: #fef3c7;
  --color-danger: #b91c1c;
  --color-danger-bg: #fee2e2;
  --color-border: #e5e7eb;
  --color-border-dark: #d1d5db;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  padding-bottom: 72px; /* Space for bottom navigation */
}

/* Offline Banner */
.offline-banner {
  background: var(--color-danger);
  color: #ffffff;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: none;
}
.offline-banner.active {
  display: block;
}

/* Official Government Branding Header */
.app-header {
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.branding-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 640px;
  margin: 0 auto;
}

.govt-logo-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1d4ed8, #1e3a8a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: bold;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.branding-text {
  display: flex;
  flex-direction: column;
}

.branding-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin: 0;
  line-height: 1.2;
}

.branding-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  line-height: 1.2;
}

.branding-location {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--color-muted);
  margin: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

/* Main Container */
.app-main {
  flex: 1;
  padding: 1rem;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
}

/* Status Cards */
.status-card {
  border-left: 5px solid var(--color-primary);
  position: relative;
  overflow: hidden;
}
.status-card.status-open {
  border-left-color: #b45309;
}
.status-card.status-completed {
  border-left-color: var(--color-success);
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}
.badge-info {
  background: #dbeafe;
  color: #1e40af;
}
.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.attendance-time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0;
  background: var(--color-bg);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
}

.time-item-label {
  font-size: 0.75rem;
  color: var(--color-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.time-item-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out, opacity 0.15s ease;
  text-align: center;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-warning {
  background: #d97706;
  color: #ffffff;
}
.btn-warning:hover:not(:disabled) {
  background: #b45309;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) {
  background: #e5e7eb;
}

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
}

/* Form inputs */
.form-group {
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--color-text);
}
.form-input {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-sm);
  background: #ffffff;
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

/* Scanner View */
.scanner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.viewfinder-wrapper {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000000;
  margin: 1rem auto;
  box-shadow: var(--shadow-md);
}

.viewfinder-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.viewfinder-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  height: 70%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.viewfinder-reticle::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #3b82f6;
  box-shadow: 0 0 8px #3b82f6;
  animation: scanSweep 2s infinite ease-in-out;
}

@keyframes scanSweep {
  0% { top: 0%; opacity: 0.8; }
  50% { top: 100%; opacity: 0.8; }
  100% { top: 0%; opacity: 0.8; }
}

.viewfinder-overlay-msg {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* GPS Advisory Box */
.gps-advisory-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-top: 1rem;
  width: 100%;
  font-size: 0.875rem;
}
.gps-advisory-box.warning {
  background: var(--color-warning-bg);
  border-color: #fcd34d;
  color: #92400e;
}
.gps-advisory-box.success {
  background: var(--color-success-bg);
  border-color: #86efac;
  color: #166534;
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.03);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--color-muted);
  font-size: 0.75rem;
  font-weight: 600;
  flex: 1;
  height: 100%;
}
.bottom-nav-item.active {
  color: var(--color-primary);
}
.bottom-nav-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

/* Utility alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.alert-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid #fca5a5;
}
.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid #86efac;
}

.text-muted { color: var(--color-muted); }
.text-danger { color: var(--color-danger); }
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
