/* ============================================================
   mobile-overrides.css — Acordly Mobile PWA Responsive Styles
   ============================================================ */

/* Bottom navigation bar — hidden on desktop */
.mobile-bottom-nav {
  display: none;
}

/* Mobile header — hidden on desktop (Tailwind md:hidden handles it too) */
.mobile-header-bar {
  display: none;
}

/* ============================================================
   Mobile breakpoint: max-width 768px
   ============================================================ */
@media (max-width: 768px) {

  /* --- Hide desktop sidebar --- */
  aside.desktop-sidebar {
    display: none !important;
  }

  /* --- Remove left margin that desktop sidebar creates --- */
  main.flex-1 {
    margin-left: 0 !important;
  }

  /* --- Show mobile bottom nav --- */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    z-index: 9999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  }

  /* Bottom nav items */
  .mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;
    padding: 6px 4px 2px;
    min-width: 56px;
    border-radius: 8px;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }

  .mobile-bottom-nav a.active {
    color: #2563eb;
  }

  .mobile-bottom-nav a svg {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
    flex-shrink: 0;
  }

  /* --- Content area: bottom padding for nav bar --- */
  main.flex-1,
  .view.active {
    padding-bottom: 80px !important;
  }

  /* --- Mobile header bar --- */
  .mobile-header-bar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 9998;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 16px;
    align-items: center;
    gap: 12px;
    min-height: 52px;
  }

  .mobile-header-bar .mobile-header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    flex: 1;
  }

  .mobile-header-bar button {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    color: #374151;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-header-bar button:active {
    background: #f3f4f6;
  }

  /* --- Off-canvas sidebar overlay --- */
  .mobile-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-drawer-overlay.open {
    display: block;
    opacity: 1;
  }

  /* --- Off-canvas sidebar drawer --- */
  .mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: #ffffff;
    z-index: 10001;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

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

  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(to right, #f9fafb, #ffffff);
  }

  .mobile-drawer-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
  }

  .mobile-drawer-header button {
    padding: 8px;
    border-radius: 8px;
    border: none;
    background: none;
    color: #6b7280;
    cursor: pointer;
  }

  /* --- Make modals full-screen on mobile --- */
  .modal-content,
  [id*="modal"] > div:first-child {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  /* --- Touch-friendly tap targets --- */
  button,
  a,
  select {
    min-height: 44px;
  }

  input,
  textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* --- Tables scroll horizontally --- */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Cards stack vertically --- */
  .grid {
    grid-template-columns: 1fr !important;
  }

  /* --- Reduce padding on mobile --- */
  .view.active {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* --- Global search bar: full width on mobile --- */
  #global-search-container {
    left: 0 !important;
    position: relative !important;
  }

  /* --- Fix the existing mobile header from index.html --- */
  main.flex-1 {
    padding-top: 0 !important;
  }

  /* --- FAB adjustment for bottom nav --- */
  .fab-container,
  [class*="fab"] {
    bottom: 80px !important;
  }

  /* --- Smooth scrolling for mobile --- */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Prevent horizontal overflow --- */
  body {
    overflow-x: hidden;
  }
}

/* ============================================================
   Small phones (max-width: 380px)
   ============================================================ */
@media (max-width: 380px) {
  .mobile-bottom-nav a {
    font-size: 9px;
    min-width: 48px;
    padding: 6px 2px 2px;
  }

  .mobile-bottom-nav a svg {
    width: 20px;
    height: 20px;
  }
}
