/* ============================================
   HABITS — Compact List with Sliders
   iOS-style rows, each habit = one row
   ============================================ */

/* === GREETING & HEADER === */
.habits-greeting {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text-primary, var(--text));
  letter-spacing: -0.01em;
}

.habits-progress-summary {
  font-size: var(--font-sm, 0.875rem);
  color: var(--text-secondary, var(--text-2));
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.habits-progress-summary.all-done {
  color: var(--success, #22c55e);
  font-weight: 600;
}

/* === OVERALL PROGRESS RING (hero section) === */
.habits-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: var(--bg-card, var(--surface));
  border-radius: var(--radius-lg, 16px);
  border: 1px solid var(--border-color, var(--border));
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.overall-ring-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.overall-ring {
  width: 80px;
  height: 80px;
  transform: rotate(-90deg);
}

.overall-ring-bg {
  fill: none;
  stroke: var(--bg-tertiary, var(--surface-3));
  stroke-width: 6;
}

.overall-ring-fill {
  fill: none;
  stroke: var(--primary-500, var(--primary));
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 289.03;
  stroke-dashoffset: 289.03;
  transition: stroke-dashoffset 0.8s cubic-bezier(.4,0,.2,1);
}

.overall-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.overall-ring-text .overall-pct {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-600, var(--primary));
  line-height: 1;
}

.overall-ring-text .overall-label {
  font-size: 0.65rem;
  color: var(--text-tertiary, var(--text-3));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.habits-hero-info h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.habits-hero-info p {
  font-size: 0.8rem;
  color: var(--text-secondary, var(--text-2));
}

/* === DATE NAVIGATION === */
.habits-date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.habits-date-nav .date-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, var(--text-2));
  background: var(--bg-card, var(--surface));
  border: 1px solid var(--border-color, var(--border));
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0;
}

.habits-date-nav .date-nav-btn:hover {
  background: var(--bg-tertiary, var(--surface-3));
  transform: scale(1.05);
}

.habits-date-nav .date-nav-btn:active {
  transform: scale(0.92);
}

.habits-date-nav .date-nav-btn .material-icons-round {
  font-size: 20px;
}

.habits-date-display {
  text-align: center;
  min-width: 140px;
}

.habits-date-display .date-label {
  font-weight: 700;
  font-size: 1rem;
  display: block;
}

.habits-date-display .date-full {
  font-size: 0.75rem;
  color: var(--text-tertiary, var(--text-3));
  display: block;
}


/* ============================================
   COMPACT HABIT ROWS — The Main Event
   ============================================ */

.habits-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* === Single Habit Row === */
.habit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-md, 12px);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
  position: relative;
  min-height: 52px;
}

.habit-row:hover {
  box-shadow: var(--shadow-sm);
}

.habit-row.completed {
  background: color-mix(in srgb, var(--success) 4%, var(--bg-card));
  border-color: color-mix(in srgb, var(--success) 20%, var(--border-color));
}

.habit-row.habit-just-completed {
  animation: rowCompletePulse 0.6s ease;
}

/* Exit animation */
.habit-row-exit {
  animation: cardExit 0.3s ease forwards;
  pointer-events: none;
}

/* === Row Left: icon + name + progress === */
.habit-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.habit-row-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  transition: all 0.3s ease;
  line-height: 1;
}

.habit-row-icon.icon-done {
  transform: scale(1.1);
  filter: saturate(1.3);
}

.habit-row-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.habit-row-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s ease;
  line-height: 1.2;
}

.habit-row-name.name-done {
  color: var(--success);
}

.habit-streak-inline {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--warning);
  margin-left: 4px;
}

.habit-row-progress {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* === Row Right: slider + checkbox + delete === */
.habit-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}


/* ============================================
   SLIDER — Custom Range Input
   ============================================ */

.habit-slider {
  --slider-color: #6366F1;
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 10px;
  border-radius: 5px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.habit-row.completed .habit-slider {
  opacity: 0.5;
}

/* Track */
.habit-slider::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(
    to right,
    var(--slider-color) 0%,
    var(--slider-color) calc(var(--val, 0) * 100%),
    var(--bg-tertiary) calc(var(--val, 0) * 100%),
    var(--bg-tertiary) 100%
  );
}

/* Thumb - WebKit */
.habit-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--slider-color);
  border: 3px solid var(--bg-card);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  margin-top: -7px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.habit-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.habit-slider::-webkit-slider-thumb:active {
  transform: scale(1.3);
}

/* Thumb - Firefox */
.habit-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--slider-color);
  border: 3px solid var(--bg-card);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.habit-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
}

.habit-slider::-moz-range-track {
  height: 10px;
  border-radius: 5px;
  background: var(--bg-tertiary);
}

.habit-slider::-moz-range-progress {
  height: 10px;
  border-radius: 5px;
  background: var(--slider-color);
}


/* ============================================
   CHECKBOX — Completion Toggle
   ============================================ */

.habit-check-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.habit-check-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.habit-check-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.habit-check-visual .material-icons-round {
  font-size: 24px;
  color: var(--text-tertiary);
  transition: all 0.2s ease;
}

.habit-check-wrap.checked .habit-check-visual .material-icons-round {
  color: var(--success);
  transform: scale(1.1);
}

.habit-check-wrap:hover .habit-check-visual .material-icons-round {
  color: var(--success);
  opacity: 0.7;
}

.habit-check-wrap.checked:hover .habit-check-visual .material-icons-round {
  opacity: 1;
}


/* ============================================
   DELETE BUTTON
   ============================================ */

.habit-row-delete {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  opacity: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.habit-row:hover .habit-row-delete {
  opacity: 0.5;
}

.habit-row-delete:hover {
  opacity: 1 !important;
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.habit-row-delete .material-icons-round {
  font-size: 16px;
}

/* On mobile, always show delete */
@media (max-width: 520px) {
  .habit-row-delete {
    opacity: 0.3;
  }
}


/* ============================================
   SHARE PROGRESS BUTTON
   ============================================ */

.share-progress-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  margin-top: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md, 12px);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.share-progress-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}

.share-progress-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.share-progress-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  box-shadow: none;
}

.share-progress-btn .material-icons-round {
  font-size: 20px;
}

.share-progress-btn.btn-success-flash {
  background: linear-gradient(135deg, var(--success), #059669);
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.4);
}


/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes rowCompletePulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}


/* ============================================
   ADD HABIT MODAL
   ============================================ */

.add-habit-modal-body {
  max-height: 65vh;
  overflow-y: auto;
}

.habit-catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.catalog-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--border-color, var(--border));
  border-radius: var(--radius-md, 12px);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-primary, var(--surface));
  position: relative;
}

.catalog-card:hover:not(.catalog-added) {
  border-color: var(--primary-300, var(--primary-light));
  background: var(--primary-50, var(--primary-bg));
}

.catalog-card.selected {
  border-color: var(--primary-500, var(--primary));
  background: var(--primary-50, var(--primary-bg));
  box-shadow: 0 0 0 3px var(--primary-100, rgba(79,70,229,0.15));
}

.catalog-added {
  opacity: 0.45;
  pointer-events: none;
}

.catalog-check {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  color: var(--success, #22c55e);
  font-weight: 700;
}

.catalog-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.catalog-card-name {
  font-weight: 500;
  font-size: 0.82rem;
}

/* Frequency selector */
.frequency-selector {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  background: var(--bg-tertiary, var(--surface-3));
  border-radius: 10px;
  padding: 4px;
}

.freq-btn {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary, var(--text-2));
  transition: all 0.2s ease;
}

.freq-btn.active {
  background: var(--primary-500, var(--primary));
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(79,70,229,0.3);
}

.freq-btn:hover:not(.active) {
  background: var(--bg-card, var(--surface));
}

/* Modal divider */
.modal-divider {
  height: 1px;
  background: var(--border-color, var(--border));
  margin: 16px 0;
}

/* Target input */
.target-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.target-input-group .form-input {
  width: 100px;
  text-align: center;
}

.target-unit {
  font-size: 0.85rem;
  color: var(--text-secondary, var(--text-2));
}

.btn-lg {
  padding: 14px 24px;
  font-size: 1rem;
  border-radius: 14px;
}


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

@media (max-width: 520px) {
  .habits-hero {
    padding: 14px;
    gap: 12px;
  }
  
  .overall-ring-wrap {
    width: 64px;
    height: 64px;
  }
  
  .overall-ring {
    width: 64px;
    height: 64px;
  }
  
  .overall-ring-text .overall-pct {
    font-size: 0.95rem;
  }

  .habit-row {
    padding: 8px 10px;
    gap: 8px;
  }

  .habit-row-icon {
    font-size: 20px;
    width: 24px;
  }

  .habit-row-name {
    font-size: 0.82rem;
  }

  .habit-slider {
    width: 64px;
  }

  .habit-check-visual .material-icons-round {
    font-size: 22px;
  }

  .habit-catalog-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .catalog-card {
    padding: 10px;
    gap: 8px;
  }
  
  .catalog-card-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }
  
  .catalog-card-name {
    font-size: 0.76rem;
  }
}

@media (min-width: 640px) {
  .habit-slider {
    width: 120px;
  }
  
  .habit-row {
    padding: 12px 16px;
  }
}

/* ============================================
   TABLET — 768px and above
   ============================================ */
@media (min-width: 768px) {
  .habit-slider {
    width: 140px;
  }

  /* Hero section - larger on tablet */
  .habits-hero {
    padding: 24px;
    gap: 24px;
    border-radius: var(--radius-xl, 20px);
  }

  .overall-ring-wrap {
    width: 100px;
    height: 100px;
  }

  .overall-ring {
    width: 100px;
    height: 100px;
  }

  .overall-ring-text .overall-pct {
    font-size: 1.35rem;
  }

  .habits-hero-info h3 {
    font-size: 1.15rem;
  }

  /* Habits in 2-column grid on tablet */
  .habits-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .habit-row {
    border-radius: var(--radius-lg, 14px);
    min-height: 68px;
  }

  .habit-row-icon {
    font-size: 26px;
    width: 32px;
  }

  .habit-row-name {
    font-size: 0.95rem;
  }

  /* Habit catalog grid - 3 columns on tablet */
  .habit-catalog-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .catalog-card {
    padding: 14px;
  }

  .catalog-card-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .catalog-card-name {
    font-size: 0.88rem;
  }

  /* Date nav - larger */
  .habits-date-nav {
    margin-bottom: 24px;
  }

  .habits-date-nav .date-nav-btn {
    width: 44px;
    height: 44px;
  }

  .habits-date-display .date-label {
    font-size: 1.1rem;
  }
}

/* ============================================
   DESKTOP — 1024px and above
   ============================================ */
@media (min-width: 1024px) {
  /* Greeting - larger on desktop */
  .habits-greeting {
    font-size: 1.75rem;
  }

  .habits-progress-summary {
    font-size: 1rem;
  }

  /* Hero section - premium desktop layout */
  .habits-hero {
    padding: 28px 32px;
    gap: 28px;
    border-radius: var(--radius-2xl, 24px);
  }

  .overall-ring-wrap {
    width: 110px;
    height: 110px;
  }

  .overall-ring {
    width: 110px;
    height: 110px;
  }

  .overall-ring-text .overall-pct {
    font-size: 1.5rem;
  }

  .habits-hero-info h3 {
    font-size: 1.25rem;
  }

  .habits-hero-info p {
    font-size: 0.9rem;
  }

  /* Habits - 3 columns on desktop */
  .habits-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }

  .habit-row {
    padding: 14px 18px;
    min-height: 76px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .habit-row-left {
    width: 100%;
  }

  .habit-row-right {
    width: 100%;
    justify-content: space-between;
    padding-top: 4px;
    border-top: 1px solid var(--border-color);
  }

  .habit-slider {
    width: 100%;
    flex: 1;
  }

  .habit-row-icon {
    font-size: 28px;
    width: 36px;
  }

  .habit-row-name {
    font-size: 1rem;
  }

  /* Catalog grid - 4 columns on desktop */
  .habit-catalog-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .catalog-card {
    padding: 16px;
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  .catalog-card-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  .catalog-card-name {
    font-size: 0.9rem;
  }

  /* Add modal - larger on desktop */
  .add-habit-modal-body {
    max-height: 70vh;
  }

  /* Date navigation */
  .habits-date-nav {
    gap: 24px;
    margin-bottom: 28px;
  }

  .habits-date-nav .date-nav-btn {
    width: 48px;
    height: 48px;
  }

  .habits-date-display .date-label {
    font-size: 1.2rem;
  }

  .habits-date-display .date-full {
    font-size: 0.85rem;
  }

  /* Share button */
  .share-progress-btn {
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ============================================
   LARGE DESKTOP — 1440px and above
   ============================================ */
@media (min-width: 1440px) {
  /* Habits - 4 columns on large desktop */
  .habits-list {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .habit-catalog-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
