/* PTpro — Mobile responsive styles
   Applied on screens narrower than 768px (phones and small tablets)
   Include this after shared.js injects SHARED_CSS in each page */

@media (max-width: 768px) {

  /* Hide desktop sidebar nav, show bottom tab bar instead */
  .nav {
    display: none !important;
  }

  body {
    flex-direction: column;
    padding-bottom: 64px; /* space for bottom tab bar */
  }

  .main {
    min-height: calc(100vh - 64px);
  }

  /* Topbar: tighter on mobile */
  .topbar {
    padding: 12px 16px;
  }
  .topbar-title {
    font-size: 15px;
  }
  .topbar-sub {
    font-size: 11px;
  }

  /* Content padding */
  .content {
    padding: 14px 16px;
  }

  /* KPI row: 2x2 grid on mobile */
  .kpi-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }
  .kpi-val {
    font-size: 22px;
  }

  /* Two-col grids collapse to single column */
  .g2, .g3, .g4, .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Client layout: full width single panel */
  .clients-layout,
  .builder,
  .planner,
  .nut-layout,
  .lib-layout,
  .ci-layout {
    grid-template-columns: 1fr;
  }

  /* Hide secondary sidebar panels on mobile by default */
  .client-sidebar,
  .lib-sidebar,
  .ci-sidebar {
    display: none;
  }

  /* Library: stack panels */
  .lib-panel,
  .nut-right,
  .sidebar-panel {
    border-top: 0.5px solid var(--border);
    border-right: none;
  }

  /* Calendar: horizontal scroll on small screens */
  .cal-grid, .day-heads {
    min-width: 560px;
  }
  .cal-wrap {
    overflow-x: auto;
  }

  /* Tables: allow horizontal scroll */
  .log-table {
    font-size: 12px;
  }
  .log-table td, .log-table th {
    padding: 8px 8px;
  }

  /* Cards: full bleed */
  .card {
    border-radius: var(--radius);
  }

  /* Buttons: full width on mobile forms */
  .action-bar, .footer-bar {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .action-bar .btn, .footer-bar .btn {
    flex: 1;
    min-width: 0;
    text-align: center;
    justify-content: center;
  }

  /* Exercise grid: 2 columns */
  .grid-area {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px;
  }

  /* Bottom tab bar */
  .bottom-tab-bar {
    display: flex !important;
  }
}

/* Bottom tab navigation bar — hidden on desktop */
.bottom-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg);
  border-top: 0.5px solid var(--border);
  z-index: 100;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text2);
  font-size: 10px;
  font-weight: 600;
  padding: 8px 2px;
  border-radius: var(--radius);
  transition: color 0.12s;
  position: relative;
}

.tab-item.active {
  color: var(--text);
}

.tab-item svg {
  opacity: 0.5;
  transition: opacity 0.12s;
}

.tab-item.active svg {
  opacity: 1;
}

.tab-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  background: #E24B4A;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 8px;
  min-width: 14px;
  text-align: center;
}

/* Safe area padding for iPhone notch/home indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-tab-bar {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(64px + env(safe-area-inset-bottom));
  }
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
}
