/* ============================================================
   FITZONE GYM ERP — ENHANCED GLOBAL CSS (APPEND TO MAIN.CSS)
   Offline Banner · Page Layout · Sidebar Fix · Typography
   ============================================================ */

/* ─── APP BODY LAYOUT (Sidebar + Main) ─────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
  position: relative;
}

/* ─── SIDEBAR OVERLAY (mobile backdrop) ─────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-height);
  background: rgba(15, 23, 42, 0.45);
  z-index: 29;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeInBackdrop 0.2s ease;
}

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

/* ─── SIDEBAR SCROLL BEHAVIOUR ──────────────────────────────── */
.app-sidebar {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 transparent;
}

/* Sidebar Brand Logo Area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.15rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  text-decoration: none;
  margin-bottom: 0.25rem;
}

/* Collapsed sidebar — hide text, keep icons */
.app-sidebar.collapsed .nav-text,
.app-sidebar.collapsed .nav-badge,
.app-sidebar.collapsed .sidebar-section-title,
.app-sidebar.collapsed .sidebar-brand span:not(:first-child) {
  display: none;
}

.app-sidebar.collapsed .sidebar-nav {
  padding: 1rem 0.5rem;
}

.app-sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem;
}

/* ─── OFFLINE STATUS BANNER ─────────────────────────────────── */
#offlineStatusBar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(90deg, #92400E 0%, #B45309 100%);
  color: #FEF3C7;
  font-size: 0.83rem;
  font-weight: 700;
  padding: 0.55rem 1.5rem;
  text-align: center;
  border-bottom: 2px solid #F59E0B;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.3);
  animation: slideDown 0.3s ease;
}

#offlineStatusBar.visible {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

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

/* ─── SYNC BADGE OFFLINE STATE ──────────────────────────────── */
.sync-status-badge.offline {
  background: var(--warning-bg);
  color: #92400E;
  border-color: #FDE68A;
}

.sync-status-badge.offline .status-dot {
  background: #F59E0B;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

/* ─── INSTALL PWA BUTTON ────────────────────────────────────── */
#pwaInstallBtn {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
}

#pwaInstallBtn.visible {
  display: inline-flex;
}

#pwaInstallBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.5);
}

/* ─── PAGE LAYOUT IMPROVEMENTS ──────────────────────────────── */

/* Table base styles (all pages) */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

table thead th {
  padding: 0.75rem 1rem;
  background: var(--bg-surface-secondary);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s ease;
}

table tbody tr:hover {
  background: var(--bg-surface-secondary);
}

table tbody td {
  padding: 0.7rem 1rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

table tbody tr:last-child {
  border-bottom: none;
}

/* Badge improvements */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.badge-success  { background: var(--success-bg);  color: #065F46; border: 1px solid var(--success-border); }
.badge-danger   { background: var(--danger-bg);   color: #991B1B; border: 1px solid var(--danger-border); }
.badge-warning  { background: var(--warning-bg);  color: #92400E; border: 1px solid var(--warning-border); }
.badge-info     { background: var(--info-bg);     color: #0C4A6E; border: 1px solid var(--info-border); }
.badge-secondary{ background: var(--bg-surface-secondary); color: var(--text-muted); border: 1px solid var(--border-color); }
.badge-primary  { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary-border); }

/* Input / Form consistent style */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--bg-surface);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 1rem;
  padding-right: 2.2rem;
  cursor: pointer;
}

textarea.form-control {
  min-height: 90px;
  resize: vertical;
}

/* Page heading standard */
.page-heading {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.025em;
}

.page-subheading {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Stat card accent */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-float);
}

.stat-card-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.stat-card-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-heading);
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ─── MOBILE BOTTOM NAV ──────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.5rem 0;
}

.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  min-width: 56px;
}

.mobile-nav-link svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.mobile-nav-link.active {
  color: var(--primary);
}

.mobile-nav-link:active {
  background: var(--bg-surface-secondary);
}

/* ─── RESPONSIVE BREAKPOINTS ─────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  .page-content {
    padding: 1.25rem;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: -100%;
    width: var(--sidebar-width) !important;
    transition: left 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-modal);
    z-index: 30;
  }

  .app-sidebar.open {
    left: 0;
  }

  .app-sidebar.open + .sidebar-backdrop,
  .sidebar-backdrop.visible {
    display: block;
  }

  .header-search {
    display: none;
  }

  .page-content {
    padding: 0.85rem;
    padding-bottom: 5rem; /* space for mobile bottom nav */
  }

  .mobile-bottom-nav {
    display: block;
  }

  .app-main {
    height: calc(100vh - var(--header-height));
  }

  .dash-quick-btn {
    padding: 0.85rem 0.5rem;
    font-size: 0.8rem;
  }

  .dash-quick-btn > div:first-child {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  :root {
    --header-height: 56px;
    --sidebar-width: 280px;
  }

  .brand-logo {
    font-size: 1.05rem;
  }

  .app-header {
    padding: 0 1rem;
  }

  .page-heading {
    font-size: 1.25rem;
  }
}

/* ─── PWA INSTALL PROMPT TOAST ───────────────────────────────── */
#pwaInstallToast {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: #1E293B;
  color: #F8FAFC;
  padding: 0.9rem 1.35rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 360px;
  width: calc(100% - 2rem);
  gap: 0.75rem;
  align-items: center;
  animation: toastSlideInUp 0.3s ease;
}

#pwaInstallToast.visible {
  display: flex;
}

@keyframes toastSlideInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
