/* habits.css — Habits section in Insights tab (v6-mini-app-s5) */

/* ── Section wrapper ────────────────────────────────────────────────────── */

.habits-section-wrapper {
  /* Sits below the Reports section in the Insights scrollable view. */
  margin-top: 0;
}

.habits-section {
  padding: 16px 16px 8px;
}

.habits-section__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tg-theme-text-color, #000);
  margin: 0 0 12px;
}

/* ── Loading skeleton ───────────────────────────────────────────────────── */

.habits-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.habits-skeleton__row {
  height: 52px;
  border-radius: 10px;
  background: var(--tg-theme-secondary-bg-color, #f1f1f1);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ── Error & empty states ───────────────────────────────────────────────── */

.habits-error {
  font-size: 13px;
  color: var(--cl-error, #FF3B30);
  padding: 8px 0;
  margin: 0;
}

.habits-empty {
  font-size: 13px;
  color: var(--tg-theme-hint-color, #888);
  line-height: 1.4;
  padding: 4px 0 8px;
  margin: 0;
}

/* ── Habit list ─────────────────────────────────────────────────────────── */

.habits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.habits-item {
  background: var(--tg-theme-bg-color, #fff);
  border-radius: 10px;
  overflow: visible; /* allow menu to overflow */
  position: relative;
}

.habits-item--editing {
  background: var(--tg-theme-secondary-bg-color, #f7f7f7);
}

/* ── View row ───────────────────────────────────────────────────────────── */

.habits-item__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 52px;
}

/* Confidence dot (AC7) */
.habits-item__dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

/* Body: alias → expansion + meta */
.habits-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 4px;
  font-size: 14px;
  line-height: 1.35;
}

.habits-item__alias {
  font-weight: 600;
  color: var(--tg-theme-text-color, #000);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.habits-item__arrow {
  color: var(--tg-theme-hint-color, #888);
  flex-shrink: 0;
  font-size: 12px;
}

.habits-item__expansion {
  color: var(--tg-theme-text-color, #000);
  flex: 1;
  min-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.habits-item__meta {
  width: 100%;
  font-size: 11px;
  color: var(--tg-theme-hint-color, #888);
  display: flex;
  gap: 4px;
  margin-top: 1px;
}

.habits-item__event-type {
  text-transform: capitalize;
}

.habits-item__last-used {
  opacity: 0.8;
}

/* ── Overflow menu button ───────────────────────────────────────────────── */

.habits-item__menu-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 18px;
  line-height: 1;
  color: var(--tg-theme-hint-color, #888);
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

.habits-item__menu-btn:active {
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

/* ── Overflow menu dropdown ─────────────────────────────────────────────── */

.habits-item__menu {
  position: absolute;
  right: 8px;
  top: calc(100% - 4px);
  z-index: 100;
  background: var(--tg-theme-bg-color, #fff);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  min-width: 120px;
}

.habits-item__menu-action {
  display: block;
  width: 100%;
  padding: 11px 16px;
  font-size: 14px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tg-theme-text-color, #000);
  -webkit-tap-highlight-color: transparent;
}

.habits-item__menu-action:active {
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

.habits-item__menu-action--danger {
  color: var(--cl-error, #FF3B30);
}

/* ── Edit row ───────────────────────────────────────────────────────────── */

.habits-item__edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  min-height: 52px;
}

.habits-item__edit-input {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--tg-theme-hint-color, #ccc);
  background: var(--tg-theme-bg-color, #fff);
  color: var(--tg-theme-text-color, #000);
  outline: none;
}

.habits-item__edit-input:focus {
  border-color: var(--tg-theme-button-color, #0088cc);
  box-shadow: 0 0 0 2px rgba(0, 136, 204, 0.15);
}

.habits-item__cancel-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  font-size: 14px;
  color: var(--tg-theme-hint-color, #888);
  border-radius: 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.habits-item__cancel-btn:active {
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}
