/**
 * HEALIST SIDEBAR - Design 4 Prestige
 * ====================================
 * Dark navy sidebar with gold accents.
 * PWA: Optimized for touch targets (44px minimum)
 */

/* ============================================
   SIDEBAR CONTAINER
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  padding: var(--space-8) 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--header-height);
  left: calc(-1 * var(--sidebar-width));
  height: calc(100vh - var(--header-height));
  z-index: 1000;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: left 0.3s ease;
  box-shadow: none;
}

.sidebar.mobile-open {
  left: 0;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

/* ============================================
   SIDEBAR BRAND
   ============================================ */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-7) var(--space-8);
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: var(--space-6);
}

.sidebar-brand .brand-mark {
  width: var(--space-10);
  height: var(--space-10);
  background: linear-gradient(135deg, var(--brand-secondary) 0%, var(--brand-secondary-light) 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  color: var(--brand-primary-dark);
  font-weight: var(--font-bold);
  font-family: var(--font-heading);
  flex-shrink: 0;
}

.sidebar-brand .brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.sidebar-brand .brand-wordmark {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: var(--font-semibold);
  color: var(--brand-primary-dark);
  letter-spacing: var(--tracking-wider);
}

.sidebar-brand .brand-wordmark span {
  color: var(--brand-secondary);
}

/* ============================================
   SIDEBAR NAVIGATION
   ============================================ */
.sidebar-nav {
  flex: 1;
  padding: 0 var(--space-4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-section {
  margin-bottom: var(--space-8);
}

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--brand-text-muted);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-3);
}

/* Nav Item - PWA: 44px touch target */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-3);
  min-height: 44px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  transition: all var(--transition);
  margin-bottom: var(--space-1);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  -webkit-tap-highlight-color: transparent; /* PWA: Remove tap highlight */
}

.nav-item:hover {
  color: var(--sidebar-text-hover);
  background: var(--sidebar-hover-bg);
}

.nav-item.active {
  color: var(--sidebar-text-active);
  background: var(--sidebar-active-bg);
  border-left: 2px solid var(--brand-secondary);
  margin-left: -2px;
}

.nav-icon {
  font-size: var(--text-xl);
  width: var(--space-6);
  text-align: center;
  flex-shrink: 0;
}

.nav-text {
  white-space: nowrap;
}

/* ============================================
   SIDEBAR FOOTER - User Profile
   ============================================ */
.sidebar-footer {
  padding: var(--space-6) var(--space-4) 0;
  border-top: 1px solid var(--sidebar-border);
  margin: 0 var(--space-4);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  min-height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.user-profile:hover {
  background: var(--sidebar-hover-bg);
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-secondary), var(--brand-secondary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-bold);
  font-size: var(--text-base);
  color: var(--brand-primary-dark);
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: var(--font-semibold);
  font-size: var(--text-base);
  color: var(--brand-primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-tier {
  font-size: var(--text-xs);
  color: var(--brand-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  font-weight: var(--font-semibold);
}

/* ============================================
   RESPONSIVE - PWA Mobile
   ============================================ */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: -280px;
    height: calc(100vh - var(--header-height));
    transition: left var(--transition-slow);
    box-shadow: none;
  }
  
  .sidebar.mobile-open {
    left: 0;
    box-shadow: var(--shadow-xl);
  }
  
  .mobile-sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-fixed) - 1);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
  }
  
  .mobile-sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
  }
}

/* ============================================
   SIDEBAR COLLAPSE TOGGLE
   ============================================ */

.sidebar-collapse-btn {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  width: var(--space-7);
  height: var(--space-7);
  border-radius: 50%;
  background: var(--sidebar-hover-bg);
  border: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  font-size: var(--text-lg);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-brand .brand-wordmark,
.sidebar.collapsed .sidebar-footer {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: var(--space-3);
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
  font-size: var(--text-2xl);
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 0 var(--space-3) var(--space-8);
}

/* Adjust main content when sidebar collapsed */
.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

/* ============================================
   AI CONSULT — Elevated CTA Button
   ============================================ */
.ai-cta {
  margin: var(--space-4) var(--space-4) var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-light));
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
  width: calc(100% - var(--space-8));
}

.ai-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(30, 58, 95, 0.4);
}

.ai-cta-icon {
  font-size: var(--text-xl);
}

.ai-cta-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

/* Hide CTA details when sidebar collapsed */
.sidebar.collapsed .ai-cta {
  justify-content: center;
  padding: var(--space-3);
  margin: var(--space-4) var(--space-2) var(--space-2);
  width: calc(100% - var(--space-4));
}

.sidebar.collapsed .ai-cta span:not(.ai-cta-icon) {
  display: none;
}

/* ============================================
   NAV BADGE — Coming Soon
   ============================================ */
.nav-badge-soon {
  font-size: 9px;
  background: var(--color-warning-light);
  color: var(--color-warning-dark);
  padding: 2px var(--space-2);
  border-radius: var(--radius);
  font-weight: var(--font-semibold);
  margin-left: auto;
}

/* ============================================
   SBM CREDITS DISPLAY — Sidebar Footer
   ============================================ */
.sbm-credits {
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  border-radius: var(--radius);
  background: var(--sidebar-hover-bg);
  cursor: pointer;
  transition: all var(--transition);
}

.sbm-credits:hover {
  background: rgba(30, 58, 95, 0.08);
}

.sbm-credits-bar {
  height: 6px;
  background: rgba(30, 58, 95, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.sbm-credits-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-secondary), var(--brand-secondary-light));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.sbm-credits-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--brand-primary-dark);
  font-weight: var(--font-medium);
}

.sbm-credits-plan {
  color: var(--brand-secondary);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  font-size: 10px;
}

.sbm-credits-unlimited .sbm-credits-label {
  justify-content: space-between;
}

/* ============================================
   VIEW MY PLAN MODAL — Credit Details
   ============================================ */
.vpm-modal {
  max-width: 560px;
  max-height: 85vh;
}

.vpm-body {
  overflow-y: auto;
  max-height: calc(85vh - 120px);
}

.vpm-credits-summary {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-light));
  border-radius: var(--radius-lg);
  color: white;
  margin-bottom: var(--space-6);
}

.vpm-credits-big {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: var(--font-bold);
  line-height: 1;
  color: var(--brand-secondary-light);
}

.vpm-credits-sub {
  font-size: var(--text-sm);
  opacity: 0.85;
  margin-top: var(--space-2);
}

.vpm-credits-bar-lg {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin: var(--space-4) auto 0;
  max-width: 300px;
}

.vpm-credits-fill-lg {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-secondary), var(--brand-secondary-light));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.vpm-credits-reset {
  font-size: var(--text-xs);
  opacity: 0.65;
  margin-top: var(--space-2);
}

.vpm-section {
  margin-bottom: var(--space-6);
}

.vpm-section-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--brand-primary-dark);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.vpm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.vpm-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-weight: var(--font-semibold);
  color: var(--brand-primary-dark);
  border-bottom: 2px solid var(--color-border);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.vpm-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border-light, rgba(0,0,0,0.06));
  color: var(--brand-text);
}

.vpm-table tr:last-child td {
  border-bottom: none;
}

.vpm-locked td {
  color: var(--color-text-muted, #999);
}

.vpm-check {
  color: var(--brand-primary);
  font-weight: var(--font-semibold);
  font-size: var(--text-xs);
}

.vpm-lock {
  color: var(--brand-secondary);
  font-weight: var(--font-semibold);
  font-size: var(--text-xs);
  cursor: pointer;
}

.vpm-tier-summary {
  background: var(--color-surface-alt, #f8f9fa);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.vpm-tier-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  color: var(--brand-text);
}

.vpm-tier-row + .vpm-tier-row {
  border-top: 1px solid var(--color-border-light, rgba(0,0,0,0.06));
}

.vpm-tier-name {
  font-weight: var(--font-semibold);
  color: var(--brand-primary-dark);
}

/* Hide credits in collapsed sidebar */
.sidebar.collapsed .sbm-credits {
  display: none;
}