/* =========================================================
   dashboard.css — Analytics Dashboard Styles
   ========================================================= */

/* Use global styles & theme tokens from style.css */
@import url('style.css');

body {
  padding-bottom: 40px; /* Reset padding for non-floating dashboard */
}

/* Header Enhancements */
.dashboard-header {
  box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.dashboard-title {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

/* View Selector Pill */
.view-selector-pill {
  background: var(--bg-input);
  border-radius: 100px;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

.view-pill-btn {
  background: transparent;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text3);
  padding: 6px 18px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.view-pill-btn:hover {
  color: var(--text);
}

.view-pill-btn.active {
  background: var(--text);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Header profile badge */
.active-profile-badge {
  background: var(--bg2);
  padding: 6px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
}

/* Dashboard Grid Layouts */
.dashboard-content {
  padding: 24px 16px;
  max-width: 800px; /* Slightly wider for double stats cards and calendar grid */
}

.dashboard-view-section {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Navigation Row */
.nav-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.nav-arrow-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.nav-arrow-btn:hover:not(:disabled) {
  background: var(--bg2);
  border-color: var(--text3);
  transform: scale(1.05);
}

.nav-arrow-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-range-label {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  min-width: 180px;
  text-align: center;
}

/* Stats Cards (Glassmorphism & Harmonic Colors) */
.dashboard-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.db-stat-card {
  padding: 16px;
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.015);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.db-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.03);
}

.db-stat-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  order: 1;
}

.db-stat-value {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 4px;
  order: 3;
}

.db-stat-unit {
  font-size: 0.75rem;
  font-weight: 600;
}

.db-stat-desc {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 4px;
  order: 2;
}

/* Premium Colors */
.glass-purple {
  background: linear-gradient(135deg, rgba(245, 243, 255, 0.7) 0%, rgba(237, 233, 254, 0.85) 100%);
  border: 1px solid #DDD6FE;
  color: #5B21B6;
}
.glass-purple .db-stat-title { color: #7C3AED; }
.glass-purple .db-stat-desc { color: #4C1D95; }
.glass-purple .db-stat-value { color: #6D28D9; }

.glass-green {
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.7) 0%, rgba(209, 250, 229, 0.85) 100%);
  border: 1px solid #A7F3D0;
  color: #065F46;
}
.glass-green .db-stat-title { color: #059669; }
.glass-green .db-stat-desc { color: #047857; }
.glass-green .db-stat-value { color: #059669; }

.glass-blue {
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.7) 0%, rgba(219, 234, 254, 0.85) 100%);
  border: 1px solid #BFDBFE;
  color: #1E40AF;
}
.glass-blue .db-stat-title { color: #2563EB; }
.glass-blue .db-stat-desc { color: #1E3A8A; }
.glass-blue .db-stat-value { color: #2563EB; }

.glass-red {
  background: linear-gradient(135deg, rgba(254, 242, 242, 0.7) 0%, rgba(254, 226, 226, 0.85) 100%);
  border: 1px solid #FECACA;
  color: #991B1B;
}
.glass-red .db-stat-title { color: #DC2626; }
.glass-red .db-stat-desc { color: #7F1D1D; }
.glass-red .db-stat-value { color: #DC2626; }

/* Chart Cards */
.db-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.01);
  position: relative;
}

.chart-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 240px;
}

.month-chart-wrapper {
  height: 260px;
}

/* SVG Chart Elements & Tooltips */
.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-bar {
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-bar:hover {
  filter: brightness(0.92);
}

/* Interactive SVG Chart Tooltip (Floating Card) */
.chart-tooltip-box {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.06), 0 8px 16px -6px rgba(0,0,0,0.04);
  font-size: 0.78rem;
  color: var(--text);
  z-index: 1000;
  pointer-events: none;
  min-width: 140px;
  display: none;
  animation: tooltipShow 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes tooltipShow {
  from { opacity: 0; transform: scale(0.96) translateY(4px); }
  to { opacity: 1; transform: scale(1) none; }
}

.tooltip-date {
  font-weight: 700;
  color: var(--text3);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  display: block;
}

.tooltip-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.tooltip-item:last-child {
  margin-bottom: 0;
}

.tooltip-val {
  font-weight: 700;
}

/* Horizontal Macro Progress Bars */
.macros-breakdown-container {
  display: flex;
  flex-direction: column;
}

.macro-bar-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
}

.macro-g-val {
  color: var(--text3);
  font-size: 0.75rem;
}

.macro-bar-track {
  height: 8px;
  background: var(--bg-input);
  border-radius: 100px;
  overflow: hidden;
}

.macro-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.carbs-bg { background: var(--carbs); }
.protein-bg { background: var(--protein); }
.fat-bg { background: var(--fat); }

/* Year View: 3x4 mini-calendars */
.year-nav-row {
  margin-bottom: 16px;
}

.year-label-title {
  font-weight: 850;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.year-calendars-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.mini-month-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.015);
  display: flex;
  flex-direction: column;
}

.mini-month-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  text-align: center;
  margin-bottom: 10px;
  letter-spacing: 0.08em;
  word-spacing: 0.1em;
}

.mini-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  text-align: center;
}

.mini-weekday {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text3);
  padding: 2px 0;
  text-transform: uppercase;
}

.mini-day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 50%;
  position: relative;
  transition: all 0.2s ease;
  user-select: none;
  height: 22px;
  width: 22px;
  margin: 0 auto;
}

/* Year calendar circle streaks */
.mini-day-cell.greyed {
  color: var(--text3);
  opacity: 0.45;
  background: transparent;
  border: 1px solid transparent;
}

.mini-day-cell.active-streak {
  cursor: pointer;
}

.mini-day-cell.active-streak:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

.mini-day-cell.excess {
  border: 1.5px solid var(--red) !important;
  color: #B91C1C;
  background: #FFE4E6 !important;
  font-weight: 700;
}

.mini-day-cell.deficit {
  border: 1.5px solid var(--green) !important;
  color: #047857;
  background: #D1FAE5 !important;
  font-weight: 700;
}

.mini-day-cell.empty-pad {
  visibility: hidden;
}

.metric-summary-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: var(--r-md);
  text-align: center;
}

/* RESPONSIVE LAYOUTS */
@media (max-width: 768px) {
  .year-calendars-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 500px) {
  .dashboard-content {
    padding: 16px 8px;
  }
  
  .dashboard-header {
    height: auto !important;
    padding: 10px 8px !important;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .header-left, .header-right {
    justify-content: space-between;
  }
  
  .header-center {
    display: flex;
    justify-content: center;
  }
  
  .view-selector-pill {
    width: 100%;
    justify-content: space-between;
  }
  
  .view-pill-btn {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    font-size: 0.78rem;
  }
  
  .active-profile-badge {
    width: 100%;
    justify-content: center;
  }
  
  .db-stat-desc {
    font-size: 1.35rem;
  }
  
  .year-calendars-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  
  .mini-month-card {
    padding: 10px;
  }
  
  .mini-day-cell {
    height: 20px;
    width: 20px;
    font-size: 0.65rem;
  }
}
