/* ==============================================================================
   ASG FINTRACK - EDGE-TO-EDGE MOBILE SUBSYSTEM (Android & iOS)
   Dedicated Mobile Architecture • Zero Impact on Desktop / PC Layout
   ============================================================================== */

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --mobile-bottom-nav-height: 64px;
}

/* 1. True Edge-to-Edge Screen Container for Mobile Viewports */
@media (max-width: 767px) {
  html, body {
    width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  }

  .mobile-edge-viewport {
    display: flex;
    flex-direction: column;
    width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100vw;
    position: relative;
    padding-top: var(--sat);
    padding-bottom: calc(var(--mobile-bottom-nav-height) + var(--sab) + 16px);
    padding-left: var(--sal);
    padding-right: var(--sar);
    box-sizing: border-box;
    background: #090e1a;
  }

  [data-theme="light"] .mobile-edge-viewport {
    background: #f8fafc;
  }

  /* Sticky Glassmorphic Top Header */
  .mobile-top-header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(9, 14, 26, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  [data-theme="light"] .mobile-top-header {
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  }

  /* Floating Bottom Navigation Bar (Tactile iOS/Android Style) */
  .mobile-bottom-bar-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    padding: 0 12px calc(max(var(--sab), 8px));
    pointer-events: none;
  }

  .mobile-bottom-bar {
    pointer-events: auto;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    height: var(--mobile-bottom-nav-height);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 26px;
    box-shadow: 0 14px 40px -6px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 6px;
  }

  [data-theme="light"] .mobile-bottom-bar {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 14px 35px -6px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: transparent;
    border: none;
    padding: 5px 0;
    color: #94a3b8;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
  }

  [data-theme="light"] .mobile-nav-btn {
    color: #64748b;
  }

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

  .mobile-nav-btn.active {
    color: #06b6d4;
    font-weight: 800;
  }

  .mobile-nav-btn .nav-icon {
    font-size: 19px;
    transition: transform 0.2s;
  }

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

  /* Center Elevated Quick Add Button */
  .mobile-fab-center {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 900;
    border: 3px solid rgba(15, 23, 42, 0.95);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5), 0 0 12px rgba(139, 92, 246, 0.4);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: -16px;
    flex-shrink: 0;
  }

  [data-theme="light"] .mobile-fab-center {
    border: 3px solid #ffffff;
    box-shadow: 0 6px 18px rgba(6, 182, 212, 0.4);
  }

  .mobile-fab-center:active {
    transform: scale(0.9) rotate(45deg);
    box-shadow: 0 2px 10px rgba(6, 182, 212, 0.7);
  }

  /* Horizontal Snap-Scroll Carousel */
  .mobile-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    padding: 2px 16px 8px;
    scrollbar-width: none;
  }

  .mobile-carousel::-webkit-scrollbar {
    display: none;
  }

  .mobile-carousel-item {
    flex: 0 0 230px;
    max-width: 250px;
    scroll-snap-align: start;
  }

  /* Universal Modal & Drawer Scroll Lock */
  html.modal-open,
  body.modal-open,
  html.modal-open .mobile-edge-viewport,
  body.modal-open .mobile-edge-viewport {
    overflow: hidden !important;
    touch-action: none !important;
    overscroll-behavior: none !important;
  }

  html.modal-open main,
  body.modal-open main {
    overflow: hidden !important;
    touch-action: none !important;
  }

  /* Mobile Sheet Bottom Modal */
  .mobile-bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    animation: fadeInBg 0.25s ease-out;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
  }

  .mobile-bottom-sheet-content {
    background: #0f172a;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px 28px 0 0;
    padding: 16px 20px calc(max(var(--sab), 16px) + 12px);
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    animation: slideUpSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overscroll-behavior: contain !important;
  }

  [data-theme="light"] .mobile-bottom-sheet-content {
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);
  }

  .mobile-sheet-drag-handle {
    width: 36px;
    height: 4px;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.3);
    margin: 0 auto 16px;
  }

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

  @keyframes fadeInBg {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* Enhanced Mobile Typography Scaling & High Readability */
  .mobile-edge-viewport {
    font-size: 15px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
  }

  /* Boost tiny text to readable sizes */
  .mobile-edge-viewport .text-\[8\.5px\],
  .mobile-edge-viewport .text-\[9px\],
  .mobile-edge-viewport .text-\[9\.5px\],
  .mobile-edge-viewport .text-\[10px\],
  .mobile-edge-viewport .text-\[10\.5px\] {
    font-size: 12px !important;
    line-height: 1.4 !important;
  }

  .mobile-edge-viewport .text-\[11px\],
  .mobile-edge-viewport .text-\[11\.5px\] {
    font-size: 13px !important;
    line-height: 1.4 !important;
  }

  .mobile-edge-viewport .text-xs {
    font-size: 13.5px !important;
    line-height: 1.45 !important;
  }

  .mobile-edge-viewport .text-sm {
    font-size: 15px !important;
    line-height: 1.45 !important;
  }

  .mobile-edge-viewport .text-base {
    font-size: 16.5px !important;
    line-height: 1.4 !important;
  }

  .mobile-edge-viewport input,
  .mobile-edge-viewport select,
  .mobile-edge-viewport textarea {
    font-size: 14.5px !important;
  }

  .mobile-nav-btn {
    font-size: 11.5px !important;
    font-weight: 700 !important;
  }

  .mobile-nav-btn .nav-icon {
    font-size: 20px !important;
  }
}

/* 2. Desktop Preservation: Ensure mobile-specific styles NEVER bleed into Desktop (>= 768px) */
@media (min-width: 768px) {
  .mobile-only-block {
    display: none !important;
  }
}

