/* =============================================
   StayPro — Mobile Responsive Styles
   Applies to screens <= 768px (phones / small tablets)
   ============================================= */

/* Hidden on desktop */
.mobile-bottom-nav {
  display: none;
}

.mobile-only {
  display: none !important;
}

/* ============================================
   TABLET + PHONE  (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {

  .mobile-only {
    display: block !important;
  }

  .desktop-only {
    display: none !important;
  }

  /* ── Body ── */
  body {
    overflow: hidden;
  }

  /* ── Sidebar: hidden slide-in overlay ── */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 270px !important;
    z-index: 9999 !important;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  }

  /* hide desktop collapse button */
  .sidebar-toggle {
    display: none !important;
  }

  /* ── Backdrop ── */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9998;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .sidebar-backdrop.visible {
    display: block;
  }

  /* ── Main wrapper ── */
  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  body.sidebar-collapsed .main-wrapper {
    margin-left: 0 !important;
  }

  /* ── Header ── */
  .header {
    padding: 0 14px;
    height: 54px;
    flex-shrink: 0;
  }

  .page-title {
    font-size: 16px !important;
  }

  .breadcrumb {
    display: none !important;
  }

  .search-box,
  .world-clock,
  .hotel-selector {
    display: none !important;
  }

  .header-right {
    gap: 6px;
  }

  /* ── Main content: fills remaining space, scrolls vertically ── */
  /* CRITICAL: height must stop ABOVE the 64px bottom nav or it blocks taps */
  .main-content,
  #mainContent {
    flex: 1;
    min-height: 0;
    /* flex shrink fix */
    max-height: calc(100dvh - 54px - 64px) !important;
    /* viewport - header - bottom nav */
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 12px !important;
    padding-bottom: 20px !important;
  }

  /* ── KPI Grid: 2 columns ── */
  .kpi-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .kpi-card {
    padding: 12px 10px !important;
    min-height: 80px;
  }

  .kpi-value {
    font-size: 20px !important;
  }

  .kpi-label {
    font-size: 10px !important;
  }

  .kpi-icon {
    font-size: 18px !important;
  }

  .kpi-change {
    font-size: 10px !important;
  }

  /* ── Cards ── */
  .card {
    padding: 14px !important;
    border-radius: 12px;
  }

  .card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .card-title {
    font-size: 14px !important;
  }

  .section-actions {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  /* ── Grid layouts collapse to 1 col ── */
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr !important;
  }

  /* ── Tabs: horizontal scroll ── */
  .tabs {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding-bottom: 4px;
  }

  .tab {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px !important;
    padding: 8px 12px !important;
  }

  /* ── Tables: horizontal scroll wrapper ── */
  .table-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .table-container table {
    min-width: 600px;
  }

  th,
  td {
    padding: 8px 10px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }

  /* ── Charts ── */
  .chart-container {
    height: 180px !important;
    overflow: hidden;
  }

  /* ── Chess board: horizontal scroll ── */
  .chess-board-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Modals: slide up from bottom ── */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    padding-bottom: 64px !important;
  }

  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: calc(90vh - 64px);
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Notification panel ── */
  .notif-list {
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Dropdowns ── */
  .dropdown-menu {
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Forms: prevent iOS auto-zoom ── */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* ── Buttons ── */
  .btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* ── Bottom Navigation Bar ── */
  /* MUST be last and have highest z-index */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 64px;
    /* Higher than sidebar (9999) so it's always tappable */
    z-index: 10000 !important;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0);
    /* Ensure clicks always go through */
    pointer-events: all !important;
  }

  .mob-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
    transition: color 0.18s;
    padding: 6px 2px 2px;
    pointer-events: all !important;
  }

  .mob-nav-btn span {
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
  }

  .mob-nav-btn.active {
    color: var(--accent);
  }

  .mob-nav-btn:active {
    background: var(--accent-glow);
  }
}

/* ============================================
   SMALL PHONE  (max-width: 430px)
   ============================================ */
@media (max-width: 430px) {
  .kpi-value {
    font-size: 17px !important;
  }

  .kpi-label {
    font-size: 9px !important;
  }

  .mob-nav-btn span {
    font-size: 9px;
  }

  .header {
    height: 50px;
  }

  .page-title {
    font-size: 14px !important;
  }
}