/* ===== HABITS PAGE STYLES ===== */

/* ── Locked Admin Gate ── */
.habits-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top, rgba(108, 99, 255, 0.20), transparent 45%), var(--bg-primary);
}

.habits-gate-card {
  width: min(100%, 480px);
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}

.habits-gate-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(108, 99, 255, 0.14);
  color: var(--accent-light);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.habits-gate-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.2;
}

.habits-gate-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 22px;
}

.habits-gate-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.habits-gate-error {
  min-height: 20px;
  color: var(--rose);
  font-size: 13px;
  font-weight: 600;
}

.habits-gate .btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* ── View Toggle ── */
.view-toggle {
  display: flex;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
}

.view-btn {
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.view-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.view-btn:not(.active):hover {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
}

/* ── Header Row ── */
.habits-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.habits-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Calendar Navigation ── */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cal-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.cal-nav-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--glass-border-hover);
}

.cal-nav-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 180px;
  text-align: center;
}

/* ── Stats Strip ── */
.habits-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.habit-stat-item {
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition);
}

.habit-stat-item:hover {
  border-color: var(--glass-border-hover);
}

.habit-stat-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.habit-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Layout: Calendar + Sidebar ── */
.habits-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

#calendar-area {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* ── Monthly Calendar ── */
.calendar-container {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  width: 100%;
  max-width: 100%;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--glass-border);
}

.cal-weekday {
  padding: 10px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--glass-border);
  padding: 1px;
}

.cal-day {
  background: var(--bg-secondary);
  min-height: 90px;
  padding: 8px;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.cal-day:hover {
  background: rgba(108, 99, 255, 0.06);
}

.cal-day.other-month {
  opacity: 0.35;
}

.cal-day.today {
  background: rgba(108, 99, 255, 0.08);
}
  
.cal-day.today .day-num {
  background: var(--accent);
  color: white;
}

.cal-day.completed-day {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.16), rgba(108, 99, 255, 0.1));
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.cal-day.completed-day:hover {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.22), rgba(108, 99, 255, 0.14));
}

.cal-day.completed-day .day-num {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.cal-day.today.completed-day .day-num {
  background: linear-gradient(135deg, #10b981, #6c63ff);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}
  
.day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.day-habits {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.day-habit-dot {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-completion {
  position: absolute;
  bottom: 5px;
  right: 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.day-completion.all-done {
  color: var(--emerald);
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.2);
}

.day-badges-container {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  align-items: center;
  z-index: 4;
  pointer-events: none;
}

.day-complete-badge {
  position: static;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, var(--emerald), #2dd4bf);
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.day-note-badge {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  opacity: 0.95;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  flex-shrink: 0;
}

.day-bday-badge {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  flex-shrink: 0;
}

.day-evt-badge,
.day-match-badge {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  flex-shrink: 0;
}

/* ── Weekly View ── */
.weekly-grid {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  width: 100%;
  max-width: 100%;
}

.weekly-header {
  display: grid;
  grid-template-columns: 160px repeat(7, 1fr);
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.02);
}

.weekly-row-label {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  border-right: 1px solid var(--glass-border);
}

.weekly-day-header {
  padding: 12px 8px;
  text-align: center;
  border-right: 1px solid var(--glass-border);
}

.weekly-day-header:last-child { border-right: none; }

.weekly-day-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.weekly-day-date {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 2px;
}

.weekly-day-header.today .weekly-day-date {
  color: var(--accent-light);
}

.weekly-body {}

.weekly-habit-row {
  display: grid;
  grid-template-columns: 160px repeat(7, 1fr);
  border-bottom: 1px solid var(--glass-border);
}

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

.weekly-habit-name {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-right: 1px solid var(--glass-border);
}

.habit-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.habit-name-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weekly-cell {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background var(--transition);
}

.weekly-cell:last-child { border-right: none; }
.weekly-cell:hover { background: rgba(108, 99, 255, 0.06); }

.check-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: var(--transition);
  cursor: pointer;
  color: transparent;
  background: transparent;
}

.check-circle.checked {
  border-color: transparent;
  background: var(--emerald);
  color: white;
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.3);
}

.check-circle:hover:not(.checked) {
  border-color: var(--text-muted);
  color: var(--text-muted);
}

/* ── Daily View ── */
.daily-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.daily-header {
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  margin-bottom: 4px;
}

.daily-date-big {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.daily-date-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.daily-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-pill);
  margin-top: 16px;
  overflow: hidden;
}

.daily-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--emerald));
  border-radius: var(--radius-pill);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.daily-habit-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.daily-habit-item:hover {
  border-color: var(--glass-border-hover);
  background: var(--bg-card-hover);
}

.daily-habit-item.completed {
  border-color: rgba(52, 211, 153, 0.2);
  background: rgba(52, 211, 153, 0.04);
}

.daily-habit-icon {
  font-size: 22px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.daily-habit-info { flex: 1; }

.daily-habit-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.daily-habit-streak {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.daily-check-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  background: transparent;
  color: transparent;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.daily-check-btn.checked {
  background: var(--emerald);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 12px rgba(52, 211, 153, 0.35);
}

.daily-check-btn:not(.checked):hover {
  border-color: var(--emerald);
  color: var(--emerald);
}

/* ── Sidebar Habits List ── */
.habits-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-section {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 20px;
}

.sidebar-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.habit-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--glass-border);
}

.habit-list-item:last-child { border-bottom: none; }

.habit-list-icon {
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.habit-list-info { flex: 1; }
.habit-list-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.habit-list-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.habit-list-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: var(--transition);
}

.icon-btn:hover { background: var(--bg-card-hover); color: var(--text-secondary); }
.icon-btn.delete:hover { background: rgba(251,113,133,0.1); color: var(--rose); }

/* ── Streak Flame ── */
.streak-display {
  text-align: center;
  padding: 8px 0;
}

.streak-flame {
  font-size: 40px;
  animation: flameFlicker 1.5s ease-in-out infinite alternate;
}

@keyframes flameFlicker {
  from { transform: scale(1) rotate(-2deg); }
  to { transform: scale(1.08) rotate(2deg); }
}

.streak-count {
  font-size: 36px;
  font-weight: 800;
  color: var(--amber);
  letter-spacing: -0.03em;
  line-height: 1;
}

.streak-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* ── Heatmap ── */
.heatmap-container {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  transition: var(--transition);
}

.heatmap-cell:hover { transform: scale(1.3); }
.heatmap-cell.lvl-1 { background: rgba(108, 99, 255, 0.2); }
.heatmap-cell.lvl-2 { background: rgba(108, 99, 255, 0.45); }
.heatmap-cell.lvl-3 { background: rgba(108, 99, 255, 0.7); }
.heatmap-cell.lvl-4 { background: var(--accent); }

/* ── Day Modal ── */
.day-modal-date {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--glass-border);
}

.day-modal-habit {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--glass-border);
}

.day-modal-habit:last-of-type { border-bottom: none; }

.day-modal-habit-icon {
  font-size: 20px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.day-modal-habit-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.day-modal-check {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  background: transparent;
  color: transparent;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.day-modal-check.checked {
  background: var(--emerald);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 10px rgba(52, 211, 153, 0.3);
}

.day-modal-check:not(.checked):hover {
  border-color: var(--emerald);
  color: var(--emerald);
}

.day-modal-note {
  margin-top: 16px;
}

.day-modal-note textarea {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  resize: vertical;
  min-height: 180px;
  max-height: 450px;
  transition: var(--transition);
}

.day-modal-note textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.12);
  outline: none;
}

.day-modal-note textarea::placeholder { color: var(--text-muted); }

/* ── Add Habit Modal ── */
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}

.emoji-option {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.04);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.emoji-option:hover { background: rgba(255,255,255,0.08); }
.emoji-option.selected { border-color: var(--accent); background: rgba(108, 99, 255, 0.12); }

.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  outline: 3px solid transparent;
}

.color-option:hover { transform: scale(1.15); }
.color-option.selected { outline-color: white; outline-offset: 2px; }

.frequency-options {
  display: flex;
  gap: 8px;
}

.freq-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.freq-btn.active {
  background: rgba(108, 99, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent-light);
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .habits-layout { grid-template-columns: 1fr; }
  .habits-sidebar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .habits-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .habits-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .habit-stat-item { padding: 12px 14px; }
  .habit-stat-val { font-size: 20px; }
  .habits-sidebar { grid-template-columns: 1fr; }

  /* Monthly Calendar Horizontal Scroll on Mobile */
  .calendar-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: var(--radius-lg);
    display: block !important;
  }
  .calendar-weekdays,
  .calendar-grid {
    min-width: 680px !important;
    width: 100% !important;
  }
  .cal-day {
    min-height: 88px !important;
    padding: 8px 6px !important;
  }
  .dot-label {
    display: inline !important;
    font-size: 9.5px !important;
  }
  .day-completion {
    display: block !important;
  }

  /* Weekly Grid Horizontal Scroll on Mobile */
  .weekly-grid {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: var(--radius-lg);
    display: block !important;
  }
  .weekly-header,
  .weekly-body,
  .weekly-habit-row,
  .weekly-totals-row {
    min-width: 720px !important;
    width: 100% !important;
  }
  
  .habits-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .habits-header-left {
    justify-content: space-between;
    width: 100%;
  }
  .cal-nav-title {
    min-width: 130px;
    font-size: 14px;
  }
}

.calendar-container::-webkit-scrollbar,
.weekly-grid::-webkit-scrollbar {
  height: 6px;
}

.calendar-container::-webkit-scrollbar-thumb,
.weekly-grid::-webkit-scrollbar-thumb {
  background: rgba(108, 99, 255, 0.4);
  border-radius: 10px;
}



