/* ==========================================
   NATIVE MOBILE APP EXPERIENCE
   iOS & Android app-like interface
   ========================================== */

/* ===== STATUS BAR THEMING ===== */
:root {
  --status-bar-height: env(safe-area-inset-top, 0px);
  --bottom-nav-height: 80px;
  --app-header-height: 60px;
}

/* ===== FULL-SCREEN APP EXPERIENCE ===== */
@media (max-width: 767px) {
  /* Keep normal scrolling - just optimize it */
  body {
    -webkit-overflow-scrolling: touch;
  }
}

/* ===== NATIVE APP HEADER ===== */
.native-app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--app-header-height) + var(--status-bar-height));
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  z-index: 100;
  display: none;
  padding-top: var(--status-bar-height);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.dark .native-app-header {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 767px) {
  /* Don't show the native header - keep original header */
  .native-app-header {
    display: none !important;
  }
}

.native-app-logo {
  height: 36px;
  width: auto;
}

.native-app-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.native-header-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.native-header-btn:active {
  transform: scale(0.95);
  background: rgba(0, 0, 0, 0.08);
}

.dark .native-header-btn {
  background: rgba(255, 255, 255, 0.08);
}

.dark .native-header-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

/* ===== BOTTOM NAVIGATION BAR - REMOVED ===== */
.native-bottom-nav {
  display: none !important;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #00E5FF 0%, #00C4FF 100%);
  border-radius: 0 0 3px 3px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.active::before {
  width: 50%;
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-icon {
  width: 28px;
  height: 28px;
  transition: all 0.25s ease;
  filter: grayscale(1) opacity(0.6);
}

.nav-item.active .nav-icon {
  filter: grayscale(0) opacity(1);
  transform: scale(1.1);
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  transition: all 0.25s ease;
  letter-spacing: 0.02em;
}

.nav-item.active .nav-label {
  color: #00E5FF;
  font-weight: 700;
}

.dark .nav-label {
  color: #9CA3AF;
}

.dark .nav-item.active .nav-label {
  color: #00E5FF;
}

/* Badge for notifications */
.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 20px);
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ===== NATIVE-STYLE CARDS ===== */
@media (max-width: 767px) {
  #controls,
  #rates > div {
    border-radius: 20px !important;
    box-shadow: 
      0 4px 20px rgba(0, 0, 0, 0.06),
      0 0 0 1px rgba(0, 0, 0, 0.04) !important;
  }
  
  .dark #controls,
  .dark #rates > div {
    box-shadow: 
      0 4px 20px rgba(0, 0, 0, 0.3),
      0 0 0 1px rgba(255, 255, 255, 0.08) !important;
  }
}

/* ===== NATIVE HAPTIC FEEDBACK ===== */
@media (max-width: 767px) {
  button:active,
  a[role="button"]:active,
  .country-card:active,
  .corridor-tag:active {
    animation: haptic-tap 150ms ease-out;
  }
}

@keyframes haptic-tap {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== APP-LIKE TRANSITIONS ===== */
@media (max-width: 767px) {
  .page-transition-enter {
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .page-transition-exit {
    animation: slideOutLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-30%);
    opacity: 0;
  }
}

/* ===== HIDE BROWSER UI ===== */
@media (max-width: 767px) {
  /* Prevent text selection on UI elements only */
  .native-bottom-nav,
  .native-app-header,
  .nav-item {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* ===== SPLASH SCREEN ===== */
.app-splash {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #00E5FF 0%, #002CFF 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.app-splash.hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  width: 120px;
  height: 120px;
  animation: splash-bounce 1.5s ease-in-out infinite;
}

@keyframes splash-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

.splash-text {
  color: white;
  font-size: 24px;
  font-weight: 700;
  margin-top: 24px;
  letter-spacing: -0.02em;
}

.splash-loader {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin-top: 32px;
  overflow: hidden;
  position: relative;
}

.splash-loader::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: white;
  border-radius: 2px;
  animation: loader-slide 1.5s ease-in-out infinite;
}

@keyframes loader-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* ===== INSTALL PROMPT - NATIVE STYLE ===== */
@media (max-width: 767px) {
  .pwa-install-prompt {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 12px);
    left: 16px;
    right: 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 250, 251, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 
      0 8px 32px rgba(0, 0, 0, 0.12),
      0 0 0 1px rgba(0, 229, 255, 0.2);
    z-index: 90;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .dark .pwa-install-prompt {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 0.98) 100%);
  }
}

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