/* ═══════════════════════════════════════════════
   Hábitos – tracker de hábitos y rachas
   ═══════════════════════════════════════════════ */

.hab-card {
  margin-bottom: 1.25rem;
}

.hab-summary-row {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hab-summary-kpi {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
}

.hab-stat {
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.hab-stat-ratio {
  font-size: 1.5rem;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hab-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
}

.hab-summary-empty {
  font-size: 0.8rem;
  margin: 0.35rem 0 0;
  padding: 0;
}

.hab-streak {
  font-size: 0.875rem;
  color: var(--accent);
  margin-top: 0.2rem;
}

.hab-today-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.hab-today-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.hab-today-item input {
  width: 1.1rem;
  height: 1.1rem;
}

.hab-form-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.hab-input {
  flex: 1;
  max-width: 280px;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
}

.hab-input:focus {
  outline: none;
  border-color: var(--accent);
}

.hab-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hab-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

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

.hab-item-name {
  flex: 1;
  font-size: 0.95rem;
}

.hab-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hab-btn-delete {
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hab-btn-delete:hover {
  color: var(--danger, #ef4444);
}

/* ── Streak dots ────────────────────────────────── */
.hab-streak-dots {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 0.25rem;
}

.hab-dot-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  width: 12px;
  text-align: center;
}

.hab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.hab-dot.done {
  background: var(--success, #22c55e);
}

/* ── Heatmap anual ──────────────────────────── */
.hab-heat-cell {
  cursor: default;
  transition: opacity 0.1s;
}

.hab-heat-cell:hover {
  opacity: 0.75;
}

.hab-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 0.75rem;
}

.hab-heat-legend-cell {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
}

/* ── Week table ──────────────────────────────── */
.hab-week-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 480px;
}

.hab-week-table th {
  padding: 0.4rem 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}

.hab-week-table th.is-today {
  color: var(--accent);
  border-color: var(--accent-border);
}

.hab-week-habit-col {
  text-align: left !important;
  min-width: 120px;
}

.hab-week-day-col {
  width: 64px;
}

.hab-week-table td {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

.hab-week-name {
  text-align: left !important;
  font-size: 0.875rem;
}

.hab-week-cell {
  text-align: center !important;
}

.hab-week-cb {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Stats per habit ────────────────────────── */
.hab-stats-panel {
  padding: 0.5rem 0.75rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  margin-top: -1px;
  border: 1px solid var(--border);
  border-top: none;
  margin-bottom: 0.35rem;
}

.hab-stats-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.hab-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-align: center;
}

.hab-stat-item strong {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--accent);
}

/* ── Category badge ─────────────────────────── */
.hab-cat-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  margin-left: 0.35rem;
  white-space: nowrap;
}

/* ── Streak badge ───────────────────────────── */
.hab-streak-badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  margin-left: 0.35rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ── Category filter row ────────────────────── */
.hab-cat-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.hab-cat-filter {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: none;
  cursor: pointer;
  transition: all 0.12s;
}

.hab-cat-filter:hover {
  border-color: var(--accent);
  color: var(--text);
}

.hab-cat-filter.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Habit form selects ─────────────────────── */
.hab-select {
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
}

.hab-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Today panel header ─────────────────────── */
.hab-hoy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.hab-hoy-header h3 {
  margin: 0;
}

.hab-date-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .hab-week-table { min-width: 480px; }
  .hab-week-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .hab-heatmap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .hab-heatmap svg { min-width: 600px; }
  .hab-stats-row { flex-wrap: wrap; }
  .hab-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .hab-tab-btn { flex-shrink: 0; }
}

@media (max-width: 480px) {
  .hab-stats-row { flex-direction: column; }
  .hab-stat-item { width: 100%; }
}
