/* =====================================================
   site.css — Modern Premium Mobile-First UI
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kantumruy+Pro:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --primary-rgb: 99, 102, 241;
  
  --success: #10b981;
  --success-hover: #059669;
  --success-light: rgba(16, 185, 129, 0.12);
  
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);
  
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.12);
  
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --border-color: #e2e8f0;
  --radius-lg: 1.25rem;
  --radius-md: 0.85rem;
  --radius-sm: 0.5rem;
  
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 15px 35px rgba(15, 23, 42, 0.12);
  
  --font-sans: 'Kantumruy Pro', 'Noto Sans Khmer', 'Khmer OS', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.125rem;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.75;
  padding-bottom: env(safe-area-inset-bottom, 0);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

a {
  transition: all 0.2s ease;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
}

@media (min-width: 768px) {
  .page-title {
    font-size: 2.4rem;
  }
}

/* ---------- Layout Elements ---------- */
.app-header {
  background-color: var(--bg-header) !important;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 1030;
}

.app-main {
  min-height: calc(100dvh - 72px - 64px);
}

.app-footer {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
}

/* ---------- Cards (Glassmorphism inspired) ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-body {
  padding: 1.5rem;
}

@media (min-width: 768px) {
  .card-body {
    padding: 2rem;
  }
}

/* ---------- Buttons & Inputs ---------- */
.btn {
  min-height: 48px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
  background: transparent;
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
  background-color: var(--primary-light);
  border-color: var(--primary);
}

.btn-outline-secondary {
  color: var(--text-muted);
  border-color: var(--border-color);
  background: transparent;
}

.btn-outline-secondary:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

.form-control, .form-select {
  min-height: 48px;
  font-family: var(--font-sans);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: #ffffff;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  outline: none;
}

.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-main);
  margin-bottom: 0.45rem;
}

/* ---------- Badges & Status ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 700;
  border-radius: 50rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.pending {
  background-color: var(--warning-light);
  color: var(--warning);
}

.status-badge.approved {
  background-color: var(--success-light);
  color: var(--success);
}

.status-badge.rejected {
  background-color: var(--danger-light);
  color: var(--danger);
}

/* ---------- Navigation ---------- */
.navbar-brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary) !important;
  letter-spacing: -0.03em;
}

.nav-link {
  color: var(--text-muted) !important;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem !important;
  transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--primary) !important;
  background-color: var(--primary-light);
}

/* ---------- Mobile Responsive List & Timeline ---------- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

.history-item:active {
  transform: scale(0.99);
}

@media (min-width: 576px) {
  .history-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.history-reason {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.history-dates {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* ---------- QR Scanner Viewport ---------- */
.scanner-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.scanner-box {
  position: relative;
  background-color: #0b0f19;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 4/3;
  width: 100%;
  max-width: 450px;
  margin: 0 auto;
  border: 2px solid #1e293b;
}

.scanner-video-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  text-align: center;
  padding: 1.5rem;
  z-index: 1;
}

.scanner-laser {
  position: absolute;
  left: 5%;
  right: 5%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--success), transparent);
  box-shadow: 0 0 15px var(--success), 0 0 5px var(--success);
  z-index: 4;
  animation: scanLaser 2.2s infinite ease-in-out;
  pointer-events: none;
  opacity: 0.85;
}

.scanner-target-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  height: 240px;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 2000px rgba(11, 15, 25, 0.6);
  z-index: 3;
  pointer-events: none;
}

.scanner-target-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--success);
  border-style: solid;
  pointer-events: none;
}

.scanner-target-corner.top-left {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
  border-top-left-radius: 6px;
}
.scanner-target-corner.top-right {
  top: -2px;
  right: -2px;
  border-width: 3px 3px 0 0;
  border-top-right-radius: 6px;
}
.scanner-target-corner.bottom-left {
  bottom: -2px;
  left: -2px;
  border-width: 0 0 3px 3px;
  border-bottom-left-radius: 6px;
}
.scanner-target-corner.bottom-right {
  bottom: -2px;
  right: -2px;
  border-width: 0 3px 3px 0;
  border-bottom-right-radius: 6px;
}

@keyframes scanLaser {
  0% { top: 15%; }
  50% { top: 85%; }
  100% { top: 15%; }
}

/* Success Card overlay */
.scan-success-card {
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- Grid Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.primary { background-color: var(--primary-light); color: var(--primary); }
.stat-icon.success { background-color: var(--success-light); color: var(--success); }
.stat-icon.warning { background-color: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background-color: var(--danger-light); color: var(--danger); }

.stat-details {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* ---------- Mobile bottom drawers/modal sheets ---------- */
.mobile-drawer-trigger {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.drawer-modal .modal-content {
  border-radius: var(--radius-lg);
  border: none;
  box-shadow: var(--shadow-lg);
}

@media (max-width: 575.98px) {
  .drawer-modal .modal-dialog {
    margin: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
  }
  .drawer-modal .modal-content {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    animation: slideUp 0.3s cubic-bezier(0.32, 0.94, 0.6, 1) forwards;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.btn-mobile-full {
  width: 100%;
}