/* Custom styles and enhancements for Restaurant Employee Clock-In App */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  /* Prevent pull-to-refresh bounce on mobile while keeping smooth scroll */
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
  /* Safe area insets for iPhone notch & home indicator bar */
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  margin: 0;
  overflow-x: hidden;
  max-width: 100vw;
}

.font-serif-title {
  font-family: var(--font-serif);
}

/* Tabular numbers for digital clock and timer (prevents number jitter) */
.font-mono, #live-clock, #shift-duration-timer {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Glassmorphism card effect */
.glass-card {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.08), 0 0 1px 1px rgba(0, 0, 0, 0.02);
}

/* Pulsing radar effect for location indicator */
@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.2;
  }
  100% {
    transform: scale(0.95);
    opacity: 0.8;
  }
}

.pulse-radar {
  animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Mobile Fast-Tap Button Micro-interactions (removes 300ms tap delay) */
.btn-press {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, background-color 0.12s ease-out;
  cursor: pointer;
}

.btn-press:active {
  transform: scale(0.96);
}

/* Glow effects for buttons */
.glow-emerald {
  box-shadow: 0 8px 20px -4px rgba(16, 185, 129, 0.35);
}
.glow-emerald:hover, .glow-emerald:active {
  box-shadow: 0 12px 25px -4px rgba(16, 185, 129, 0.45);
}

.glow-rose {
  box-shadow: 0 8px 20px -4px rgba(244, 63, 94, 0.35);
}
.glow-rose:hover, .glow-rose:active {
  box-shadow: 0 12px 25px -4px rgba(244, 63, 94, 0.45);
}

/* iOS Safari auto-zoom prevention: inputs & selects must have at least 16px font size on mobile */
@media screen and (max-width: 768px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Animations for Mobile Bottom Sheets and Dialogs */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0.5;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-slide-up {
  animation: slideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in {
  animation: fadeIn 0.2s ease-out forwards;
}

/* ============================================================
   RESPONSIVE NAVIGATION ARCHITECTURE (DESKTOP TOP / MOBILE BOTTOM)
   ============================================================ */

/* Header Container & Logout Button Flex Safeguards */
header {
  max-width: 100vw;
  overflow-x: clip;
}

#btn-logout-trigger {
  flex-shrink: 0 !important;
}

/* Header Role & Trial Plan Badges:
   - STRICTLY HIDDEN on mobile & tablet viewports (< 1280px) to give brand title & logout full space.
   - Visible on desktop screens (>= 1280px) when logged in. */
@media screen and (max-width: 1279px) {
  #header-role-pill,
  #header-plan-pill {
    display: none !important;
  }
}

/* 1. Header Desktop Nav:
   - Hidden on mobile phones (< 768px) and in native mobile apps.
   - Displayed in top header on desktop/tablet web app (>= 768px). */
#header-desktop-nav {
  display: none !important;
}

@media screen and (min-width: 768px) {
  body:not(.is-native-app) #header-desktop-nav:not(.hidden) {
    display: flex !important;
    align-items: center;
    gap: 0.375rem;
  }
}

/* 2. Mobile Bottom Navigation Dock:
   - Displayed fixed at bottom on mobile phones (< 768px) and in native mobile apps.
   - STRICTLY HIDDEN on desktop web-app (>= 768px). */
#mobile-bottom-nav,
.mobile-dock {
  display: block !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 50 !important;
  background-color: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border-top: 1px solid rgba(231, 229, 228, 0.95) !important;
  box-shadow: 0 -4px 25px -3px rgba(0, 0, 0, 0.1) !important;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem)) !important;
  margin: 0 !important;
}

/* Hide mobile bottom dock on widescreen desktop (>= 768px) unless in native app */
@media screen and (min-width: 768px) {
  body:not(.is-native-app) #mobile-bottom-nav,
  body:not(.is-native-app) .mobile-dock {
    display: none !important;
  }
}

/* When logged out, hide mobile dock */
#mobile-bottom-nav.hidden,
.mobile-dock.hidden {
  display: none !important;
}

/* Ensure main content does not get overlapped by bottom navigation dock on mobile */
@media screen and (max-width: 767px) {
  main {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0.5rem)) !important;
  }

  /* Sheet modals scroll padding above safe area */
  #billing-modal .glass-card,
  #settings-modal .glass-card,
  #team-modal .glass-card,
  #history-modal .glass-card,
  #onboarding-modal .glass-card {
    padding-bottom: max(2rem, env(safe-area-inset-bottom, 2rem)) !important;
  }
}

/* In native mobile app container, always add bottom padding for mobile dock */
body.is-native-app main {
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0.5rem)) !important;
}

body.is-native-app #billing-modal .glass-card,
body.is-native-app #settings-modal .glass-card,
body.is-native-app #team-modal .glass-card,
body.is-native-app #history-modal .glass-card,
body.is-native-app #onboarding-modal .glass-card {
  padding-bottom: max(2rem, env(safe-area-inset-bottom, 2rem)) !important;
}

/* Hide mobile bottom dock whenever ANY modal sheet or dialog is open */
body:has(#billing-modal:not(.hidden)) #mobile-bottom-nav,
body:has(#settings-modal:not(.hidden)) #mobile-bottom-nav,
body:has(#team-modal:not(.hidden)) #mobile-bottom-nav,
body:has(#history-modal:not(.hidden)) #mobile-bottom-nav,
body:has(#farewell-modal:not(.hidden)) #mobile-bottom-nav,
body:has(#confirm-modal:not(.hidden)) #mobile-bottom-nav,
body:has(#trial-expired-modal:not(.hidden)) #mobile-bottom-nav,
body:has(#onboarding-modal:not(.hidden)) #mobile-bottom-nav {
  display: none !important;
}

/* Sheet modals:
   Elevate z-index above the mobile dock and provide proper backdrop layering */
#billing-modal,
#settings-modal,
#team-modal,
#history-modal,
#onboarding-modal {
  z-index: 70 !important;
}

/* System and action dialogs (Farewell, Confirm, Loading, Trial Expired):
   Elevate z-index above all sheets and dock, and center cleanly on all viewports */
#farewell-modal,
#confirm-modal,
#loading-overlay,
#trial-expired-modal {
  z-index: 100 !important;
}

#farewell-modal:not(.hidden),
#confirm-modal:not(.hidden) {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 1rem !important;
}

#farewell-modal .glass-card,
#confirm-modal .glass-card {
  border-radius: 1.5rem !important;
  margin: auto !important;
  max-height: calc(100dvh - 2rem) !important;
  overflow-y: auto !important;
  padding-bottom: 1.75rem !important;
  max-width: 24rem !important;
  width: 100% !important;
}

/* Native mobile app always shows bottom dock and hides top nav */
body.is-native-app #mobile-bottom-nav:not(.hidden),
body.is-native-app .mobile-dock:not(.hidden) {
  display: block !important;
}

body.is-native-app #header-desktop-nav {
  display: none !important;
}

/* Billing & Subscription:
   - Supported across Desktop Web and Mobile (Native Apps & Mobile Viewports) with dynamic 15% store fee pricing
   - Hidden when element has .hidden class. */
#mobile-nav-billing.hidden,
#settings-billing-section.hidden,
#billing-modal.hidden {
  display: none !important;
}

/* Mobile Nav Dock Buttons */
.mobile-dock-btn {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 1 1 0% !important;
  min-height: 48px !important;
  min-width: 44px !important;
  padding: 4px 2px !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  color: #78716c !important;
  text-decoration: none !important;
  -webkit-tap-highlight-color: transparent !important;
  transition: color 0.15s ease-out, transform 0.1s ease-out !important;
}

.mobile-dock-btn.active,
.mobile-dock-btn.text-amber-600 {
  color: #d97706 !important;
}

.mobile-dock-btn.hidden {
  display: none !important;
}

.mobile-dock-btn:active {
  transform: scale(0.92) !important;
}

.mobile-dock-btn svg {
  width: 20px !important;
  height: 20px !important;
}

.mobile-dock-btn span {
  font-size: 10px !important;
  line-height: 1.2 !important;
  margin-top: 2px !important;
}

/* Standard Touch Target (Apple HIG & Material 44x44px minimum) */
.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Smooth modal touch scrolling */
.modal-scroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Custom minimal scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.4);
  border-radius: 9999px;
}

/* Universal hidden utility override (ensures .hidden always strictly hides elements regardless of responsive display utilities) */
.hidden {
  display: none !important;
}

/* Punch Sync Badge (Optimistic UI & Jitter Queue) */
.sync-badge-syncing {
  background-color: rgba(254, 243, 199, 0.8) !important;
  color: #92400e !important;
  border: 1px solid rgba(251, 191, 36, 0.7) !important;
}
.sync-badge-syncing .sync-dot {
  background-color: #f59e0b !important;
  animation: sync-pulse 1.2s infinite ease-in-out;
}
.sync-badge-synced {
  background-color: rgba(209, 250, 229, 0.8) !important;
  color: #065f46 !important;
  border: 1px solid rgba(110, 231, 183, 0.7) !important;
}
.sync-badge-synced .sync-dot {
  background-color: #10b981 !important;
}
.sync-badge-queued {
  background-color: rgba(239, 246, 255, 0.85) !important;
  color: #1e40af !important;
  border: 1px solid rgba(147, 197, 253, 0.7) !important;
}
.sync-badge-queued .sync-dot {
  background-color: #3b82f6 !important;
}
@keyframes sync-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
