/* ==========================================================================
   DAILY HABIT SYSTEM - COMPONENTS (MOBILE-FIRST OPTIMIZED)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Today View - Compact Unified Hero Dashboard Card
   -------------------------------------------------------------------------- */
.today-header {
  margin-bottom: 1.25rem;
}

.today-hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  position: relative;
  overflow: hidden;
}

.today-hero-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 140px;
  height: 100%;
  background: radial-gradient(circle at 100% 0%, var(--primary-subtle), transparent 70%);
  pointer-events: none;
}

/* Hero Top Row: Date Navigation & Streak Pill */
.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.hero-date-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.btn-hero-nav {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.btn-hero-nav:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.hero-date-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hero-date-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  line-height: 1;
}

.hero-date-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-today-reset {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--primary-subtle);
  color: var(--primary-text);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-today-reset:hover {
  background: var(--primary);
  color: #ffffff;
}

.hero-streak-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--streak-fire-subtle);
  border: 1px solid rgba(255, 107, 53, 0.25);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.hero-streak-pill .streak-icon {
  font-size: 1.1rem;
  animation: flameFlicker 2s infinite ease-in-out;
}

@keyframes flameFlicker {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(4deg); }
}

.hero-streak-val {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--streak-fire);
  line-height: 1;
}

/* Hero Bottom Row: Progress Ring & Motivation */
.hero-bottom-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-subtle);
}

.hero-ring-wrapper {
  position: relative;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.progress-ring {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.progress-ring-bg {
  stroke: var(--bg-surface-subtle);
}

.progress-ring-fill {
  stroke: var(--primary);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1), stroke var(--transition-normal);
}

.progress-ring-fill.all-complete {
  stroke: var(--success);
}

.hero-ring-text {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-percent {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-main);
}

.hero-progress-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.hero-headline {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.hero-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Filter Bar (Single Horizontal Row on Mobile)
   -------------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.time-filters {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.filter-chip {
  padding: 0.35rem 0.65rem;
  min-width: 38px;
  height: 34px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  cursor: pointer;
}

.filter-chip[data-filter="all"] {
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
}

.filter-chip:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.filter-chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.time-icon-morning {
  display: block;
  pointer-events: none;
  stroke: var(--text-main);
}

.filter-chip:hover .time-icon-morning {
  stroke: var(--text-main);
}

.filter-chip.active .time-icon-morning {
  stroke: #ffffff;
}

.btn-add-habit-compact {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Habit Cards List (Spacious & Clean Multi-Row Layout)
   -------------------------------------------------------------------------- */
.habits-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.habit-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.05rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
  position: relative;
  border-left: 5px solid var(--habit-color, var(--primary));
}

.habit-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-medium);
}

.habit-card.completed {
  background: var(--bg-surface-subtle);
  border-color: var(--border-subtle);
}

.habit-card.completed .habit-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Top Identity Row */
.habit-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.habit-identity {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.habit-icon-box {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--habit-color-subtle, var(--primary-subtle));
  color: var(--habit-color, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.habit-info-col {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.habit-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.3;
  word-break: break-word;
}

.habit-tags-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.habit-category-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.habit-freq-text {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.habit-desc-text {
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.habit-streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 800;
  color: var(--streak-fire);
  background: var(--streak-fire-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  flex-shrink: 0;
  border: 1px solid rgba(255, 107, 53, 0.2);
}

/* Bottom Action Bar */
.habit-card-bottom {
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-subtle);
}

/* Boolean Action */
.boolean-action-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.habit-status-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Stepper Action */
.stepper-action-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.habit-mini-progress {
  width: 100%;
  height: 4px;
  background: var(--bg-surface-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.habit-mini-progress-fill {
  height: 100%;
  background: var(--habit-color, var(--primary));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.stepper-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.stepper-value-label {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.stepper-count-bold {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.stepper-target-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stepper-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-step {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-subtle);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 800;
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.btn-step:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--border-medium);
}

.btn-step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Timer Action */
.timer-action-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.timer-display-col {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.timer-time {
  font-family: var(--font-family-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.timer-goal-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timer-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-timer-toggle {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all var(--transition-fast);
}

.btn-timer-toggle:hover {
  background: var(--primary);
  color: #ffffff;
}

.btn-timer-toggle.running {
  background: var(--warning);
  color: #ffffff;
}

/* Unified Check Action Button */
.btn-habit-check {
  padding: 0.42rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: all var(--transition-bounce);
  cursor: pointer;
  white-space: nowrap;
}

.btn-habit-check:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}

.btn-habit-check:active {
  transform: scale(0.96);
}

.btn-habit-check.is-done {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.btn-habit-check.is-done:hover {
  background: var(--success-hover);
  border-color: var(--success-hover);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  background: var(--bg-surface);
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.empty-icon {
  font-size: 2.5rem;
}

.empty-title {
  font-size: var(--font-size-base);
  font-weight: 700;
}

.empty-desc {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  max-width: 320px;
}

/* --------------------------------------------------------------------------
   Insights & Analytics Tab Components
   -------------------------------------------------------------------------- */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-footer {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Heatmap Grid */
.heatmap-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.heatmap-scroll-wrapper {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  width: max-content;
}

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--bg-surface-subtle);
  transition: transform var(--transition-fast);
  cursor: pointer;
}

.heatmap-cell:hover {
  transform: scale(1.3);
  z-index: 10;
}

.heatmap-cell[data-level="0"] { background: var(--bg-surface-subtle); }
.heatmap-cell[data-level="1"] { background: hsl(158, 60%, 75%); }
.heatmap-cell[data-level="2"] { background: hsl(158, 65%, 55%); }
.heatmap-cell[data-level="3"] { background: hsl(158, 70%, 42%); }
.heatmap-cell[data-level="4"] { background: hsl(158, 80%, 30%); }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.heatmap-legend-cells {
  display: flex;
  gap: 3px;
}

.heatmap-legend-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* Weekly Trend Bar Chart */
.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.chart-svg-container {
  width: 100%;
  height: 180px;
  margin-top: 0.75rem;
}

/* --------------------------------------------------------------------------
   Habit Management List View
   -------------------------------------------------------------------------- */
.manage-habits-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.manage-habit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-xs);
  gap: 0.75rem;
}

.manage-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.manage-item-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* Confetti Celebration Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
}
