/* =====================================================
   SahiHisab — Mobile Dashboard Styles
   Floating tab bar, Aaj Ka Summary, Quick Actions
   ===================================================== */

/* ─── Floating Tab Bar ────────────────────────────── */
.floating-tabbar {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: 14px;
  right: 14px;
  height: 60px;
  background: var(--card);
  border-radius: 20px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  z-index: 999;
  box-shadow: 0 4px 24px hsla(210, 30%, 20%, 0.08), 0 0 0 1px hsla(210, 25%, 88%, 0.4);
}

.floating-tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.floating-tabbar-item .material-symbols-rounded {
  font-size: 1.35rem;
  color: var(--text-secondary);
  transition: color 150ms ease;
}

.floating-tabbar-item span:last-child {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.69rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 150ms ease;
}

.floating-tabbar-item.active .material-symbols-rounded {
  color: var(--primary);
}

.floating-tabbar-item.active span:last-child {
  color: var(--primary);
  font-weight: 600;
}

.floating-tabbar-fab {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px hsla(200, 80%, 44%, 0.3);
  transition: transform 150ms ease, box-shadow 150ms ease;
  flex-shrink: 0;
  margin: 0 4px;
}

.floating-tabbar-fab:active {
  transform: scale(0.92);
}

.floating-tabbar-fab .material-symbols-rounded {
  font-size: 1.5rem;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.floating-tabbar-fab.open .material-symbols-rounded {
  transform: rotate(45deg);
}

/* Hide old bottom-nav (replaced by floating tabbar) */
.bottom-nav {
  display: none !important;
}

/* Hide floating tabbar on desktop (sidebar handles navigation) */
@media (min-width: 769px) {
  .floating-tabbar {
    display: none !important;
  }

  .quick-create-sheet,
  .quick-create-backdrop {
    display: none !important;
  }
}

/* ─── Mobile Stat Cards 2x2 Grid ─────────────────── */
.stats-grid-mobile {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card-mobile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 100ms ease;
}

.stat-card-mobile:active {
  transform: scale(0.97);
}

.stat-card-mobile-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-mobile-icon .material-symbols-rounded {
  font-size: 1.1rem;
}

.stat-card-mobile-value {
  font-family: 'Inter', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--foreground);
  line-height: 1.2;
}

.stat-card-mobile-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ─── Payment Dues Alert (Mobile) ─────────────────── */
.payment-dues-alert {
  background: hsl(0, 70%, 97%);
  border: 1px solid hsl(0, 70%, 90%);
  border-radius: 16px;
  padding: 14px 16px;
}

.payment-dues-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.payment-dues-header .material-symbols-rounded {
  font-size: 1.1rem;
  color: var(--destructive);
}

.payment-dues-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--destructive);
}

.payment-dues-badge {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--destructive);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.69rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.payment-dues-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid hsl(0, 70%, 90%);
}

.payment-dues-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.payment-dues-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--foreground);
}

.payment-dues-detail {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.payment-dues-amount {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--destructive);
  flex-shrink: 0;
}

/* ─── Mobile text truncation ────────────────── */
@media (max-width: 768px) {
  .stat-card-mobile-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ─── Phase 5 Verfication Fixes ────────────────── */
/* Fix 1: Aaj Ka Summary Desktop Layout */
.aaj-ka-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.aaj-summary-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid currentColor;
  border-radius: 16px;
  padding: 20px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aaj-summary-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.aaj-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.aaj-summary-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  /* Fix 1/Fix 3: Aaj Ka Summary strictly 2x2 grid mobile override */
  body .aaj-ka-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* Phase 5/12: Dashboard upcoming bookings space-between & no overflow */
  body .dash-grid .client-row {
    display: flex;
    justify-content: space-between;
  }
  
  body .dash-grid .client-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body .dash-grid .client-name,
  body .dash-grid .client-phone {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .dash-grid .client-balance {
    display: block;
    flex-shrink: 0;
    margin-left: 8px;
  }

  /* Fix 3: Analytics page stat cards to 2-col with no overflow */
  body .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-card {
    min-width: 0;
    overflow: hidden;
  }
  .stat-card > div,
  .stat-value,
  .stat-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
/* =====================================================
   Phase 15: Final 375px Fixes (Orders, Analytics, Tooltips, Toggles)
   ===================================================== */

@media (max-width: 768px) {
  /* Fix 1: Orders stat cards text truncating */
  body #ordersList ~ .stats-grid .stat-label, 
  body .stats-grid .stat-label {
    white-space: normal;
    line-height: 1.2;
    font-size: clamp(0.65rem, 2vw, 0.8rem);
  }

  /* Fix 2: Orders filter pills wrapping 2 rows */
  body .wi-filters, 
  body [data-filter] {
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body .wi-filters::-webkit-scrollbar,
  body [data-filter]::-webkit-scrollbar {
    display: none;
  }
  body .d-flex.gap-sm.mb-xl {
    flex-wrap: nowrap;
  }

  /* Fix 3: Analytics header period pills */
  body [data-period] {
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  body .d-flex.gap-sm.mb-xl {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body .d-flex.gap-sm.mb-xl::-webkit-scrollbar {
    display: none;
  }
}

/* Fix 4: Tooltip text invisible in dark mode */
body.dark-mode .tooltip-icon[data-tooltip]::after,
body.dark-mode .tooltip-icon:hover::after,
body.dark-mode .tooltip-icon:focus::after,
body.dark-mode .tooltip-icon.tooltip-active::after {
  background: var(--card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Fix 5: Settings Toggle slider broken */
body .toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin: 0;
}
body .toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
body .toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border);
  transition: .3s;
  border-radius: 24px;
}
body .toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
body .toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}
body .toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}
body.dark-mode .toggle-switch input:checked + .toggle-slider,
body.dark-mode .toggle-switch input:not(:checked) + .toggle-slider {
  background-color: var(--card);
  border: 1px solid var(--border);
}
body.dark-mode .toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
  border-color: var(--primary);
}
