/* ==============================================================================
 * 007 PRO - QR Code Staff Attendance & Time-Based Payroll System
 * Comprehensive Responsive Design System (All Devices & Screen Resolutions)
 * ==============================================================================
 * Supports:
 * - 📱 Extra Small Mobile (320px - 375px: iPhone SE, Galaxy Fold, Small Androids)
 * - 📱 Standard Mobile (375px - 480px: iPhone 13/14/15/16, Galaxy S-series, Pixels)
 * - 📱 Large Phones / Phablets (480px - 767px: Pro Max, Ultra, Small Tablets)
 * - 📟 Tablets / iPads (768px - 1023px: iPad Mini, iPad Air, iPad Pro 11", Tablets)
 * - 💻 Laptops & Desktops (1024px - 1439px: MacBooks, Standard Laptops)
 * - 🖥️ Large & Ultra-wide Displays (>= 1440px: 2K, 4K, Ultra-wide Desktops)
 * ============================================================================== */

/* ==============================================================================
 * 1. GLOBAL RESETS & TOUCH ENHANCEMENTS
 * ============================================================================== */
html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* Smooth Touch Scrolling for All Scrollable Elements */
.table-responsive,
.v19-table-wrapper,
.content-area,
.mobile-modal-card,
#scanner-staff-list-preview,
.main-wrapper {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Custom Scrollbars for Modern Webkit Browsers */
.table-responsive::-webkit-scrollbar,
.v19-table-wrapper::-webkit-scrollbar,
.mobile-modal-card::-webkit-scrollbar,
#scanner-staff-list-preview::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track,
.v19-table-wrapper::-webkit-scrollbar-track,
.mobile-modal-card::-webkit-scrollbar-track,
#scanner-staff-list-preview::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb,
.v19-table-wrapper::-webkit-scrollbar-thumb,
.mobile-modal-card::-webkit-scrollbar-thumb,
#scanner-staff-list-preview::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  transition: background 0.2s ease;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.v19-table-wrapper::-webkit-scrollbar-thumb:hover,
.mobile-modal-card::-webkit-scrollbar-thumb:hover,
#scanner-staff-list-preview::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 185, 129, 0.45);
}

/* Prevent image and video overflow */
img, video, canvas {
  max-width: 100%;
  height: auto;
}

/* Touch-friendly Minimum Tap Target */
button, 
.btn, 
.nav-item, 
.mobile-nav-btn, 
.form-control,
select,
input[type="date"],
input[type="time"] {
  min-height: 40px;
}

/* Menu Toggle Button (Header Hamburger) */
.menu-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  width: 38px;
  height: 38px;
  min-height: 38px;
  min-width: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
  user-select: none;
}

.menu-toggle-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.menu-toggle-btn:active {
  transform: scale(0.94);
}

@media (max-width: 767px) {
  .menu-toggle-btn {
    display: flex !important;
  }
}

/* Mobile Slide-Out Navigation Drawer */
.mobile-drawer-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 280;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-drawer-backdrop.active {
  display: block;
  opacity: 1;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 310px;
  max-width: 86vw;
  background: rgba(15, 20, 34, 0.98);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 290;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)) 16px;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.75);
  overflow-y: auto;
}

.mobile-nav-drawer.active {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-close-drawer {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted, #94a3b8);
  width: 32px;
  height: 32px;
  min-height: 32px;
  min-width: 32px;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-close-drawer:hover {
  color: #ffffff;
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.4);
}

.drawer-nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  margin-top: 6px;
  padding-right: 2px;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--text-muted, #94a3b8);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  user-select: none;
}

.drawer-nav-item:hover {
  color: #ffffff;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  transform: translateX(3px);
}

.drawer-nav-item.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(5, 150, 105, 0.15) 100%);
  color: #ffffff;
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
  font-weight: 700;
}

.drawer-nav-item .icon {
  font-size: 1.25rem;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ==============================================================================
 * 2. MOBILE BOTTOM NAVIGATION (Hidden on Desktop >= 768px, Visible on Mobile < 768px)
 * ============================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 14, 23, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: clamp(0.68rem, 2.4vw, 0.74rem);
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm, 8px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 52px;
  text-align: center;
  user-select: none;
}

.mobile-nav-btn .icon {
  font-size: 1.25rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

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

.mobile-nav-btn.active {
  color: var(--primary, #10b981);
  font-weight: 700;
}

.mobile-nav-btn.active .icon {
  transform: translateY(-2px);
}

.mobile-nav-btn.scan-primary-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff !important;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  min-height: 50px;
  min-width: 50px;
  padding: 0;
  margin-top: -20px;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45), 0 0 0 4px var(--bg-main, #0a0e17);
  border: none;
  justify-content: center;
}

.mobile-nav-btn.scan-primary-btn .icon {
  font-size: 1.45rem;
}

.mobile-nav-btn.scan-primary-btn span:last-child {
  display: none;
}

.mobile-nav-btn.scan-primary-btn:active {
  transform: scale(0.92);
}

/* ==============================================================================
 * 3. UNIVERSAL MODAL SYSTEM (Responsive Bottom Sheet on Mobile & Centered on Desktop)
 * ============================================================================== */
.mobile-modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 250;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.mobile-modal-backdrop.active {
  display: flex;
}

.mobile-modal-card {
  background: var(--bg-card-solid, #121826);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), 0 0 30px rgba(16, 185, 129, 0.12);
  animation: modalPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 767px) {
  .mobile-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .mobile-modal-card {
    border-radius: 24px 24px 0 0;
    max-width: 100%;
    max-height: 92vh;
    padding: 20px 18px calc(24px + env(safe-area-inset-bottom, 0px)) 18px;
    animation: slideUpModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-bottom: none;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  }
}

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

/* ==============================================================================
 * 4. BREAKPOINT: LARGE DESKTOP & 4K SCREENS (>= 1440px)
 * ============================================================================== */
@media (min-width: 1440px) {
  .content-area {
    padding: 32px 48px;
    max-width: 1800px;
    margin: 0 auto;
  }

  .scanner-grid {
    max-width: 780px;
  }

  .v19-layout-container {
    grid-template-columns: 350px 1fr;
    gap: 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .badges-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

/* ==============================================================================
 * 5. BREAKPOINT: STANDARD DESKTOP (1024px to 1439px)
 * ============================================================================== */
@media (min-width: 1024px) and (max-width: 1439px) {
  .sidebar {
    width: 260px;
  }

  .content-area {
    padding: 24px 28px;
  }

  .v19-layout-container {
    grid-template-columns: 310px 1fr;
    gap: 18px;
  }

  .scanner-grid {
    max-width: 660px;
  }
}

/* ==============================================================================
 * 6. BREAKPOINT: TABLETS & IPADS (768px to 1023px)
 * ============================================================================== */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar {
    width: 220px;
    padding: 18px 12px;
  }

  .brand-logo {
    gap: 8px;
    padding-bottom: 16px;
    margin-bottom: 14px;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .brand-text h1 {
    font-size: 1.05rem;
  }

  .nav-item {
    padding: 10px 12px;
    font-size: 0.88rem;
    gap: 10px;
  }

  .top-bar {
    padding: 14px 20px;
  }

  .content-area {
    padding: 20px 20px;
  }

  .v19-layout-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .v19-left-sidebar {
    position: static;
    width: 100%;
  }

  .scanner-grid {
    max-width: 580px;
    margin: 0 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .gps-inputs-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .admin-pin-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .tutorial-steps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==============================================================================
 * 7. BREAKPOINT: ALL MOBILE DEVICES (< 768px)
 * ============================================================================== */
@media (max-width: 767px) {
  /* Hide Desktop Sidebar on Mobile */
  .sidebar {
    display: none !important;
  }

  /* Show Mobile Bottom Navigation */
  .mobile-bottom-nav {
    display: flex !important;
  }

  /* Main Wrapper Layout */
  .main-wrapper {
    height: 100vh;
    overflow-y: auto;
    width: 100%;
  }

  /* Top Bar Header Responsive */
  .top-bar {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: nowrap;
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(10, 14, 23, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .top-bar-left {
    flex: 1;
    min-width: 0;
  }

  .page-title {
    min-width: 0;
  }

  .page-title h2 {
    font-size: clamp(0.92rem, 3.8vw, 1.15rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
  }

  .page-title p {
    font-size: 0.74rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin-top: 2px;
  }

  .top-bar-right {
    gap: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  .user-auth-badge {
    padding: 3px 8px !important;
    gap: 6px !important;
    font-size: 0.76rem !important;
  }

  .user-auth-badge #top-bar-user-name {
    display: none; /* Hide admin username text on small screens to save space */
  }

  .btn-logout-small {
    padding: 2px 6px !important;
    font-size: 0.72rem !important;
  }

  .live-clock-card {
    display: flex !important;
    padding: 4px 8px !important;
    min-width: auto !important;
    gap: 6px !important;
    border-radius: 8px !important;
  }

  .clock-icon {
    font-size: 0.95rem !important;
  }

  .clock-details {
    min-width: auto !important;
    text-align: right;
  }

  .clock-time {
    font-size: clamp(0.78rem, 2.6vw, 0.88rem) !important;
    font-weight: 700 !important;
  }

  .clock-date {
    display: none !important; /* Hide clock subtitle on mobile */
  }

  /* Content Area Padding with Safe-Area Insets for Bottom Nav */
  .content-area {
    padding: 12px 10px calc(76px + env(safe-area-inset-bottom, 0px)) 10px;
    width: 100%;
    box-sizing: border-box;
  }

  /* Glass Card Responsive Padding */
  .glass-card {
    padding: 14px 12px;
    border-radius: 16px;
    margin-bottom: 16px;
  }

  .card-header {
    margin-bottom: 14px;
    gap: 8px;
  }

  .card-title {
    font-size: 1rem;
    gap: 8px;
  }

  .card-title .icon {
    font-size: 1.15rem;
  }

  /* ==========================================================================
   * 7.1 SCANNER VIEW RESPONSIVE (MOBILE)
   * ========================================================================== */
  .scanner-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }

  .scanner-box {
    padding: 14px 12px;
    border-radius: 16px;
  }

  .scanner-box h3 {
    font-size: 1.05rem !important;
  }

  #scanner-instruction {
    font-size: 0.78rem !important;
    line-height: 1.35 !important;
  }

  .action-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
    max-width: 100%;
  }

  .btn-action-type {
    padding: 10px 8px;
    min-height: 48px;
    border-radius: 12px;
  }

  .action-btn-icon {
    font-size: 1.1rem;
  }

  .action-btn-title {
    font-size: 0.88rem;
  }

  .action-btn-sub {
    font-size: 0.68rem;
  }

  .action-selected-pill {
    font-size: 0.62rem;
    padding: 1px 6px;
  }

  .scan-mode-indicator-banner {
    padding: 6px 12px;
    font-size: 0.8rem;
    margin-bottom: 10px !important;
  }

  .camera-wrapper {
    height: clamp(270px, 78vw, 360px);
    max-width: 100%;
    border-radius: 14px;
    margin: 0 auto 10px auto;
  }

  .scanner-overlay {
    width: 200px;
    height: 200px;
  }

  .reticle-corner {
    width: 26px;
    height: 26px;
  }

  .scanner-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    max-width: 100%;
  }

  .scanner-actions .btn {
    min-height: 40px;
    padding: 8px 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    border-radius: 10px;
  }

  /* Scanner Today's Summary & Mini Stats */
  #scanner-stats-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
    width: 100% !important;
  }

  #scanner-stats-grid .stat-card {
    padding: 10px 10px !important;
    gap: 8px !important;
    border-radius: 10px !important;
  }

  #scanner-stats-grid .stat-icon-wrapper {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.1rem !important;
    border-radius: 8px !important;
  }

  #scanner-stats-grid .stat-value {
    font-size: clamp(0.95rem, 3.5vw, 1.25rem) !important;
  }

  #scanner-stats-grid .stat-label {
    font-size: 0.72rem !important;
  }

  /* ==========================================================================
   * 7.2 LOGS VIEW RESPONSIVE (UI ដូច Python v1.9)
   * ========================================================================== */
  .v19-layout-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
  }

  .v19-left-sidebar {
    width: 100%;
    position: static;
    padding: 16px 14px;
    border-radius: 16px;
    gap: 12px;
  }

  .v19-panel-title {
    font-size: 1.05rem;
    padding-bottom: 10px;
  }

  .time-inputs-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .time-inputs-row .form-group {
    margin-bottom: 10px;
  }

  .btn-v19-add {
    padding: 11px 14px;
    font-size: 0.9rem;
  }

  /* 4 Action Buttons Stack -> 2x2 Grid on Mobile */
  .v19-action-buttons-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 12px;
    margin-top: 4px;
  }

  .btn-v19-unauthorized,
  .btn-v19-leave,
  .btn-v19-extraday,
  .btn-v19-dayoff {
    padding: 9px 8px;
    font-size: 0.78rem;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .v19-sidebar-hint {
    font-size: 0.74rem;
    padding: 8px 10px;
  }

  /* Summary KPI Card */
  .v19-summary-card {
    padding: 12px 10px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    border-radius: 12px;
  }

  .v19-sum-item {
    font-size: 0.78rem;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
  }

  .v19-sum-item.total-pay-highlight {
    grid-column: 1 / -1;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.88rem;
  }

  /* Filter Bar Controls on Mobile */
  .v19-filter-bar {
    padding: 12px 10px;
    border-radius: 12px;
  }

  .v19-filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .v19-filter-controls .filter-group {
    flex: 1 1 calc(50% - 6px);
    min-width: 120px;
  }

  .v19-filter-controls .filter-group:first-child {
    flex: 1 1 100%; /* Search input takes 100% width on top */
  }

  .filter-input-sm {
    width: 100%;
    min-width: 0 !important;
    padding: 7px 10px;
    font-size: 0.82rem;
    height: 38px;
  }

  .v19-filter-actions-inline {
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
    gap: 6px !important;
    margin-left: 0 !important;
    margin-top: 6px !important;
  }

  .v19-filter-actions-inline .btn {
    width: 100%;
    padding: 8px 6px;
    font-size: 0.76rem;
    justify-content: center;
    white-space: nowrap;
  }

  /* Bulk Actions Bar */
  .v19-bulk-actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }

  .bulk-action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 4px;
    width: 100%;
  }

  .btn-bulk-action,
  .btn-bulk-delete,
  .btn-bulk-cancel {
    padding: 6px 4px;
    font-size: 0.72rem;
    text-align: center;
    justify-content: center;
  }

  /* Data Tables Mobile Styling */
  .v19-table th,
  .v19-table td {
    padding: 8px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .v19-table-footer {
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
    padding: 10px 12px;
  }

  .pagination-wrapper {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* ==========================================================================
   * 7.3 LEAVE REQUEST & RESPONSE VIEWS RESPONSIVE (MOBILE)
   * ========================================================================== */
  #leave-tab-date-section {
    padding: 10px 12px !important;
  }

  #leave-tab-date-section > div:first-child {
    gap: 8px !important;
  }

  /* Leave Response Top KPI Grid */
  #view-leave-response .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  #view-leave-response .stat-card {
    padding: 10px 10px !important;
  }

  #view-leave-response .stat-icon-wrapper {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.1rem !important;
  }

  #view-leave-response .stat-value {
    font-size: clamp(1rem, 3.8vw, 1.3rem) !important;
  }

  #view-leave-response .stat-label {
    font-size: 0.72rem !important;
  }

  #lr-highlight-banner {
    padding: 10px 12px !important;
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  #lr-bulk-actions-bar {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px !important;
  }

  /* ==========================================================================
   * 7.4 STAFF DIRECTORY & BADGES VIEW RESPONSIVE (MOBILE)
   * ========================================================================== */
  .badges-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .staff-card-item {
    width: 100%;
  }

  .staff-id-badge {
    padding: 16px;
    max-width: 320px;
    margin: 0 auto;
  }

  /* ==========================================================================
   * 7.5 SETTINGS VIEW RESPONSIVE (MOBILE)
   * ========================================================================== */
  .settings-container {
    gap: 14px;
  }

  .settings-card {
    padding: 14px 12px !important;
  }

  .settings-actions-grid {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .settings-actions-grid .btn {
    width: 100%;
    justify-content: center;
  }

  .gps-inputs-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .gps-actions-grid {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .gps-actions-grid .btn {
    width: 100%;
    justify-content: center;
    margin-left: 0 !important;
  }

  .admin-pin-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .tutorial-steps-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  /* Toast Notification Positioning on Mobile */
  .toast-container {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: 10px;
    left: 10px;
  }

  .toast {
    min-width: unset;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.85rem;
  }
}

/* ==============================================================================
 * 8. BREAKPOINT: EXTRA SMALL MOBILE SCREENS (< 400px - iPhone SE, Fold Outer)
 * ============================================================================== */
@media (max-width: 399px) {
  .mobile-bottom-nav {
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-nav-btn {
    padding: 4px 4px;
    font-size: 0.65rem;
    gap: 2px;
    min-width: 44px;
  }

  .mobile-nav-btn .icon {
    font-size: 1.15rem;
  }

  .mobile-nav-btn.scan-primary-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin-top: -16px;
  }

  .mobile-nav-btn.scan-primary-btn .icon {
    font-size: 1.3rem;
  }

  .top-bar {
    padding: 8px 10px;
  }

  .page-title h2 {
    font-size: 0.88rem;
  }

  .page-title p {
    display: none; /* Hide date in header on ultra-small screens */
  }

  .btn-action-type {
    padding: 8px 4px;
    min-height: 44px;
  }

  .action-btn-title {
    font-size: 0.78rem;
  }

  .action-btn-sub {
    font-size: 0.62rem;
  }

  .scanner-actions .btn {
    font-size: 0.74rem;
    padding: 6px 4px;
  }

  .v19-summary-card {
    grid-template-columns: 1fr 1fr;
  }

  .v19-filter-controls .filter-group {
    flex: 1 1 100%;
  }

  #view-leave-response .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .v19-action-buttons-stack {
    grid-template-columns: 1fr;
  }

  #leave-tab-date-section > div:first-child {
    grid-template-columns: 1fr !important;
  }
}

/* ==============================================================================
 * 9. DEDICATED STAFF SCAN & LEAVE PORTAL (?mode=scan, ?mode=leave, /scan, /leave)
 * ============================================================================== */
body.mode-staff-portal,
body.mode-scan-only,
body.mode-leave-only {
  background: radial-gradient(circle at 50% -10%, rgba(16, 185, 129, 0.12) 0%, rgba(11, 15, 25, 0.98) 60%), #0b0f19;
  min-height: 100vh;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

body.mode-staff-portal .sidebar,
body.mode-scan-only .sidebar,
body.mode-leave-only .sidebar,
body.mode-staff-portal .mobile-bottom-nav,
body.mode-scan-only .mobile-bottom-nav,
body.mode-leave-only .mobile-bottom-nav {
  display: none !important;
}

body.mode-staff-portal .main-wrapper,
body.mode-scan-only .main-wrapper,
body.mode-leave-only .main-wrapper {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 auto !important;
}

body.mode-staff-portal .top-bar,
body.mode-scan-only .top-bar,
body.mode-leave-only .top-bar {
  padding: 10px 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  width: 100% !important;
  background: rgba(11, 15, 25, 0.88) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

body.mode-staff-portal .top-bar-left .page-title h2,
body.mode-scan-only .top-bar-left .page-title h2,
body.mode-leave-only .top-bar-left .page-title h2 {
  display: none !important;
}

body.mode-staff-portal #live-date,
body.mode-scan-only #live-date,
body.mode-leave-only #live-date {
  font-size: clamp(0.74rem, 2.6vw, 0.88rem) !important;
  font-weight: 600 !important;
  margin: 0 !important;
}

body.mode-staff-portal .live-clock-card,
body.mode-scan-only .live-clock-card,
body.mode-leave-only .live-clock-card {
  padding: 4px 10px !important;
  border-radius: 10px !important;
  background: rgba(15, 23, 42, 0.75) !important;
  border: 1px solid rgba(16, 185, 129, 0.25) !important;
}

body.mode-staff-portal .clock-time,
body.mode-scan-only .clock-time,
body.mode-leave-only .clock-time {
  font-size: clamp(0.82rem, 2.8vw, 0.95rem) !important;
  color: #34d399 !important;
}

body.mode-staff-portal .staff-portal-bar,
body.mode-scan-only .staff-portal-bar,
body.mode-leave-only .staff-portal-bar {
  display: flex !important;
  justify-content: center;
  align-items: center;
  padding: 8px 12px 0 12px !important;
  margin: 0 auto 10px auto !important;
  width: 100% !important;
  max-width: 500px !important;
}

body.mode-staff-portal .staff-nav-tabs,
body.mode-scan-only .staff-nav-tabs,
body.mode-leave-only .staff-nav-tabs {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 6px !important;
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  padding: 4px !important;
  border-radius: 100px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  width: 100% !important;
}

body.mode-staff-portal .btn-staff-tab,
body.mode-scan-only .btn-staff-tab,
body.mode-leave-only .btn-staff-tab {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 9px 8px !important;
  border-radius: 100px !important;
  border: none !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  font-size: clamp(0.76rem, 2.6vw, 0.88rem) !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  white-space: nowrap !important;
}

body.mode-staff-portal .btn-staff-tab.active,
body.mode-scan-only .btn-staff-tab.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45) !important;
}

body.mode-staff-portal .btn-staff-tab.leave-tab.active,
body.mode-leave-only .btn-staff-tab.leave-tab.active {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.45) !important;
}

body.mode-staff-portal .content-area,
body.mode-scan-only .content-area,
body.mode-leave-only .content-area {
  padding: 8px 12px 28px 12px !important;
  max-width: 540px !important;
  margin: 0 auto !important;
}

/* ==============================================================================
 * 10. PRINT OPTIMIZATIONS
 * ============================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .sidebar,
  .mobile-bottom-nav,
  .top-bar,
  .scanner-box,
  .scanner-actions,
  .action-type-selector,
  .v19-left-sidebar,
  .v19-filter-bar,
  .v19-bulk-actions-bar,
  .btn,
  .toast-container,
  .mobile-modal-backdrop {
    display: none !important;
  }

  .main-wrapper {
    height: auto !important;
    overflow: visible !important;
  }

  .content-area {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .glass-card {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .badges-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }

  .staff-id-badge {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    page-break-inside: avoid !important;
  }

  .v19-table {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .v19-table th,
  .v19-table td {
    border: 1px solid #cccccc !important;
    color: #000000 !important;
    background: #ffffff !important;
  }
}
