/**
 * HEALIST DASHBOARD - Design 4 Prestige
 * ======================================
 * Dashboard layout with top header, sidebar, main content, footer.
 * PWA: Safe area insets for notched devices
 */

/* ============================================
   TOP HEADER BAR - Dark Navy
   ============================================ */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--header-bg);
  color: var(--brand-text-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
  z-index: 1001;
  border-bottom: 1px solid var(--header-border);
  box-sizing: border-box;
}

.top-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.hamburger-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: var(--space-12);
  height: var(--space-12);
  background: none;
  border: none;
  color: var(--brand-text-light);
  cursor: pointer;
  border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
  padding: var(--space-1);
}

.hamburger-btn .hamburger-icon {
  font-size: var(--text-2xl);
  line-height: 1;
}

.hamburger-btn .hamburger-text {
  font-size: 8px;
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.top-header .brand-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: 0;
}

.top-header .brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.top-header .brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.top-header .brand-name {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
  color: var(--brand-text-light);
  letter-spacing: var(--tracking-wider);
}

.top-header .brand-name span {
  color: var(--brand-secondary);
}

.top-header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.top-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-title {
  text-align: right;
}

.header-title h1 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: var(--font-medium);
  color: var(--brand-text-light);
  margin: 0;
}

.header-title p {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */
.dashboard {
  display: flex;
  flex-direction: column;
  height: 100vh;           /* FIXED height — prevents body scroll */
  overflow: hidden;         /* viewport boundary — no page-level scrollbar */
  background: var(--brand-surface-elevated);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-content {
  flex: 1;
  min-height: 0;                    /* allow flex shrink below content */
  display: flex;                     /* nested flex column */
  flex-direction: column;
  overflow: hidden;                  /* no scroll on main-content itself */
  margin-left: 0;
  margin-top: var(--header-height);
  padding: 0 var(--space-10) 0 var(--space-10);
  transition: margin-left var(--transition-slow);
}

.main-content.sidebar-visible {
  margin-left: var(--sidebar-width);
}

/* ============================================
   DASHBOARD WELCOME HEADING
   ============================================ */
.main-content h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--brand-primary-dark);
  margin-bottom: 24px;
}

/* ============================================
   STATS GRID - Health Metrics
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--brand-surface);
  border-radius: 12px;
  padding: var(--space-6);
  border: 1px solid var(--brand-border);
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.06);
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 12px 12px 0 0;
}

.stat-card:hover {
  box-shadow: 0 6px 20px rgba(30, 58, 95, 0.12);
  transform: translateY(-2px);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--brand-text-muted);
  margin-bottom: var(--space-2);
}

.stat-value,
.stat-number {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: var(--font-semibold);
  color: var(--brand-primary-dark);
  margin-bottom: var(--space-1);
}

.stat-change {
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.stat-change.positive {
  color: var(--color-success);
}

.stat-change.negative {
  color: var(--color-error);
}

/* ============================================
   CONTENT GRID - Two Column Layout
   ============================================ */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

/* CARDS → defined in healist-components.css */

/* ============================================
   DATA TABLE / NUTRITION LIST
   ============================================ */
.data-table {
  width: 100%;
}

.data-row {
  display: flex;
  align-items: center;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--brand-border);
  min-height: 44px; /* PWA: Touch target */
}

.data-row:last-child {
  border-bottom: none;
}

.data-icon {
  width: var(--space-12);
  height: var(--space-12);
  background: var(--data-icon-bg);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-right: var(--space-4);
  flex-shrink: 0;
}

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

.data-title {
  font-weight: var(--font-semibold);
  margin-bottom: 2px;
  color: var(--brand-primary-dark);
}

.data-subtitle {
  font-size: var(--text-sm);
  color: var(--brand-text-muted);
}

.data-value {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--brand-primary-dark);
}

.data-unit {
  font-size: var(--text-sm);
  color: var(--brand-text-muted);
  margin-left: 2px;
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.quick-actions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-left: 4px solid var(--brand-primary);
  box-shadow: 0 1px 3px rgba(30, 58, 95, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.quick-action:hover {
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.10);
  border-left-color: var(--brand-secondary);
}

.quick-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--brand-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.quick-action-text {
  flex: 1;
}

.quick-action-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  color: var(--brand-primary-dark);
}

.quick-action-desc {
  font-size: 12px;
  color: var(--brand-text-muted);
  margin-top: 2px;
}

/* ============================================
   AI NUTRITIONIST SECTION
   ============================================ */
.ai-chat-container {
  padding: var(--space-6);
}

.ai-chat-container .welcome-message {
  margin-bottom: 0;
}

.ai-chat-container .welcome-message h4 {
  font-family: var(--font-heading);
  font-size: calc(var(--text-xl) * 1.25);
  font-weight: var(--font-semibold);
  color: var(--brand-primary-dark);
  margin: 0 0 var(--space-2) 0;
}

.ai-chat-container .welcome-message p {
  color: var(--brand-text-muted);
  font-size: var(--text-lg);
  margin: 0;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: var(--space-2) 0 var(--space-4) 0;
}

.ai-chat-container .form-group {
  margin-top: var(--space-4);
}

.form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  min-height: 44px; /* PWA: Touch target */
  -webkit-tap-highlight-color: transparent;
}

.form-radio input[type="radio"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  flex-shrink: 0;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

.form-radio span {
  font-size: var(--text-base);
  color: var(--brand-text);
}

.ai-chat-attribution {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--brand-text-placeholder);
  margin-top: var(--space-2);
}

.ai-chat-container .btn-primary {
  background: var(--brand-primary);
  color: var(--brand-text-light);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  padding: var(--space-4) var(--space-8);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  max-width: var(--form-max-width);
}

.ai-chat-container .btn-primary:hover:not(:disabled) {
  background: var(--brand-primary-light);
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.ai-chat-container .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================
   PAGE FOOTER
   ============================================ */
.page-footer {
  flex-shrink: 0;           /* never compress in flex layout */
  padding: var(--space-5) var(--space-10);
  border-top: 1px solid var(--footer-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--footer-bg);
  font-size: var(--text-sm);
  color: var(--footer-text);
  /* PWA: Safe area for bottom */
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0));
}

.footer-copyright {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.footer-links {
  display: flex;
  gap: var(--space-6);
}

.footer-links a {
  color: var(--footer-text);
  text-decoration: none;
  transition: color var(--transition);
  min-height: 44px; /* PWA: Touch target */
  display: flex;
  align-items: center;
}

.footer-links a:hover {
  color: var(--brand-primary);
}

/* ============================================
   RESPONSIVE - PWA Mobile
   ============================================ */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .main-content {
    margin-left: 240px;
    padding: 0 var(--space-6) 0 var(--space-6);
  }

  .page-footer {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .top-header {
    padding: 0 var(--space-4);
    padding-top: env(safe-area-inset-top, 0);
  }
  
  .top-header .brand-name {
    font-size: var(--text-xl);
  }
  
  .header-title h1 {
    font-size: var(--text-base);
  }

  .header-title p {
    font-size: 10px;
  }
  
  .main-content {
    margin-left: 0;
    margin-top: var(--header-height);
    padding: 0 var(--space-4) 0 var(--space-4);
  }

  .page-footer {
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-4);
    text-align: center;
  }
  
  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-4);
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }
  
  .stat-value,
  .stat-number {
    font-size: var(--text-4xl);
  }
  
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.summary-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--brand-border);
}

.summary-section h4 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--brand-primary);
  margin-bottom: var(--space-3);
}

.summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.summary-list li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--brand-border);
}

.summary-list li:last-child {
  border-bottom: none;
}

.status-badge {
  font-size: var(--text-sm);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  margin-left: var(--space-2);
}

.status-badge.on_track,
.status-badge.achieved,
.status-badge.completed {
  background: var(--color-success-light);
  color: var(--color-success-dark);
}

.status-badge.in_progress {
  background: var(--color-info-light);
  color: var(--color-info-dark);
}

.status-badge.not_started {
  background: var(--brand-surface-elevated);
  color: var(--brand-text-muted);
}

.placeholder-prompt {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  background: var(--brand-surface-elevated);
  border-radius: var(--radius-md);
}

.placeholder-prompt p {
  color: var(--brand-text-muted);
  margin-bottom: var(--space-4);
}

.quick-action.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================
   DASHBOARD STATS - Real Data Display
   ============================================ */

.stat-card .stat-value {
  font-size: var(--text-5xl);
  font-weight: var(--font-semibold);
  color: var(--brand-primary);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: var(--text-sm);
  color: var(--brand-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-1);
}

.stat-card .stat-change {
  font-size: var(--text-sm);
  margin-top: var(--space-2);
}

.stat-card .stat-change.positive {
  color: var(--color-success);
}

.stat-card .stat-change.negative {
  color: var(--color-error);
}

/* Placeholder state */
.stat-card .stat-value.placeholder {
  color: var(--brand-text-muted);
  font-size: var(--text-3xl);
}

/* ============================================
   TODAY'S NUTRITION - Data Table
   ============================================ */

.data-table {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.data-row {
  display: flex;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--brand-border);
}

.data-row:last-child {
  border-bottom: none;
}

.data-icon {
  font-size: var(--text-3xl);
  width: var(--space-10);
  flex-shrink: 0;
}

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

.data-title {
  font-weight: var(--font-medium);
  color: var(--brand-text);
}

.data-subtitle {
  font-size: var(--text-sm);
  color: var(--brand-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-value {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--brand-primary);
  margin-left: var(--space-4);
}

.data-unit {
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  color: var(--brand-text-muted);
  margin-left: 2px;
}


/* ============================================
   QUICK ACTIONS GRID — D4S (single definition above, no duplicate)
   ============================================ */

.quick-action.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.quick-action-desc {
  font-size: var(--text-sm);
  color: var(--brand-text-muted);
}


/* ============================================
   PLACEHOLDER PROMPTS
   ============================================ */

.placeholder-prompt {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  background: var(--brand-surface-elevated);
  border-radius: var(--brand-radius);
}

.placeholder-prompt p {
  color: var(--brand-text-muted);
  margin-bottom: var(--space-4);
}

.placeholder-prompt .btn {
  margin-top: var(--space-2);
}


/* ============================================
   HEALTH SUMMARY MODAL
   ============================================ */

.health-summary-content {
  padding: 0 var(--space-1);
}

.summary-header {
  text-align: center;
  padding: var(--space-5);
  background: var(--brand-surface-elevated);
  border-radius: var(--brand-radius);
  margin-bottom: var(--space-5);
}

.summary-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--brand-border);
}

.summary-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.summary-section h4 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--brand-primary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.summary-list li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--brand-border);
}

.summary-list li:last-child {
  border-bottom: none;
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}

.data-grid > div {
  padding: var(--space-2);
  background: var(--brand-surface-elevated);
  border-radius: var(--brand-radius-sm);
}


/* ============================================
   STATUS BADGES
   ============================================ */

.status-badge {
  font-size: var(--text-xs);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  margin-left: var(--space-2);
  text-transform: capitalize;
}

.status-badge.on_track,
.status-badge.achieved,
.status-badge.completed {
  background: var(--color-success-light);
  color: var(--color-success-dark);
}

.status-badge.in_progress {
  background: var(--color-info-light);
  color: var(--color-info-dark);
}

.status-badge.not_started,
.status-badge.pending {
  background: var(--brand-surface-elevated);
  color: var(--brand-text-muted);
}

.status-badge.at_risk,
.status-badge.behind {
  background: var(--color-warning-light);
  color: var(--color-warning-dark);
}


/* ============================================
   LOG HYDRATION MODAL
   ============================================ */

.hydration-quick-buttons {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.hydration-quick-buttons .btn {
  flex: 1;
  min-width: 60px;
}

.hydration-result {
  text-align: center;
  padding: var(--space-5);
}

.hydration-result .success-icon {
  font-size: var(--text-6xl);
  margin-bottom: var(--space-4);
}

.hydration-result .percent-display {
  margin-top: var(--space-4);
  padding: var(--space-3);
  background: var(--brand-surface-elevated);
  border-radius: var(--brand-radius);
}

.hydration-result .percent-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
  color: var(--brand-primary);
}


/* ============================================
   AI CHAT ATTRIBUTION
   ============================================ */

.ai-chat-attribution {
  text-align: right;
  font-size: var(--text-xs);
  color: var(--brand-text-muted);
  margin-top: var(--space-1);
  font-style: italic;
}


/* ============================================
   MODAL IMPROVEMENTS
   ============================================ */

.modal-large {
  max-width: 800px;
  width: 95%;
}

.modal-body {
  max-height: calc(90vh - 140px);
  overflow-y: auto;
}

/* .modal-header, .modal-footer → defined in healist-modals.css */


/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 480px) {
  .stat-card .stat-value {
    font-size: var(--text-3xl);
  }

  .quick-action {
    padding: var(--space-3) var(--space-3);
  }

  .quick-action-icon {
    font-size: var(--text-2xl);
    width: var(--space-8);
  }

  .data-value {
    font-size: var(--text-lg);
  }
  
  .modal-large {
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
  }
}
