/* ==========================================================================
   Home (modules/features/dashboard.js)
   A greeting, a box to ask Safi, then the biggest open deals and your tasks.
   Asking turns the page into a chat (.hm-chat); answers use aichat.js's
   .ai-chat-message styles from styles.css.
   ========================================================================== */

.hm-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 56px 24px 64px;
}

.hm-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hm-greeting {
  margin: 0 0 24px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* ── Ask Safi ──────────────────────────────────────────────────────────── */

.hm-ask {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-secondary);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hm-ask:focus-within {
  border-color: color-mix(in srgb, var(--color-primary) 55%, var(--border-color));
  box-shadow: 0 0 0 3px var(--color-primary-bg), 0 8px 24px rgba(16, 24, 40, 0.05);
}

.hm-ask .hm-ask-input {
  width: 100%;
  min-height: 72px;
  height: auto;
  padding: 16px 18px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--text-primary);
  resize: none;
  outline: none;
}

.hm-ask .hm-ask-input:focus {
  border: 0;
  box-shadow: none;
}

.hm-ask-input::placeholder {
  color: var(--text-muted);
}

.hm-ask-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 10px 18px;
}

.hm-ask-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.hm-ask-hint .hm-icon {
  width: 14px;
  height: 14px;
}

.hm-ask-send {
  margin-left: auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.hm-ask-send:disabled {
  opacity: 0.35;
  cursor: default;
}

/* "/" prompts: the panel's button and menu (aichat.js), placed for Home */
.hm-ask {
  position: relative;
}

.hm-ask-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.hm-ask-actions .hm-ask-send {
  margin-left: 0;
}

.hm-prompts-btn {
  width: 34px;
  height: 34px;
  margin-right: 0;
  border-width: 1px;
  border-radius: 9px;
}

/* Under the ask box near the top of Home, above the reply box at the bottom */
.hm-ask .hm-prompts-menu {
  top: calc(100% + 6px);
  bottom: auto;
  left: 0;
  right: 0;
}

.hm-ask--reply .hm-prompts-menu {
  top: auto;
  bottom: calc(100% + 8px);
}

.hm-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.hm-chip {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.hm-chip:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ── Sections ──────────────────────────────────────────────────────────── */

.hm-section {
  margin-top: 48px;
}

.hm-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.hm-section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hm-count {
  margin-left: 2px;
  font-weight: 500;
  color: var(--text-muted);
}

.hm-section-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hm-link,
.hm-icon-btn {
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.hm-link {
  padding: 0 8px;
}

.hm-icon-btn {
  width: 30px;
  display: grid;
  place-items: center;
  padding: 0;
}

.hm-link:hover,
.hm-icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.hm-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border-color);
}

.hm-list > li {
  border-bottom: 1px solid var(--border-color);
}

.hm-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 52px;
  padding: 8px 8px;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--text-primary);
}

button.hm-row {
  cursor: pointer;
  border-radius: 8px;
}

button.hm-row:hover {
  background: var(--bg-tertiary);
}

.hm-row-title {
  display: block;
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 550;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hm-row-sub {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Deals: name, stage, owner, value */
.hm-deal-main {
  flex: 1;
  min-width: 0;
}

.hm-stage,
.hm-owner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 140px;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 13.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

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

.hm-avatar {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

.hm-value {
  width: 96px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hm-faint {
  color: var(--text-muted);
}

/* Tasks: tick, title, due */
.hm-task {
  gap: 12px;
}

.hm-check {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.5px solid var(--border-color-strong, var(--text-muted));
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.hm-check .hm-icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.5;
}

.hm-check:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.hm-task.is-done .hm-check {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}

.hm-task-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  text-align: left;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}

.hm-task-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hm-task.is-done .hm-task-title {
  color: var(--text-muted);
  text-decoration: line-through;
}

.hm-due {
  flex-shrink: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.hm-due--today {
  color: #c27a0a;
  font-weight: 550;
}

.hm-due--late {
  color: #d14343;
  font-weight: 550;
}

/* ── Empty, loading, error ─────────────────────────────────────────────── */

.hm-empty {
  padding: 28px 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.hm-empty-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.hm-empty-text {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.hm-skeleton {
  height: 156px;
  border-top: 1px solid var(--border-color);
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 12px,
    var(--bg-tertiary) 12px 26px,
    transparent 26px 52px
  );
  opacity: 0.6;
}

.hm-error {
  margin: 0;
  padding: 16px 0;
  border-top: 1px solid var(--border-color);
  font-size: 13.5px;
  color: #d14343;
}

/* ── Chat ──────────────────────────────────────────────────────────────── */

/* The chat fills the space under the app header: a bar to get back, the
   conversation (which scrolls), and the reply box at the bottom */
.main-content:has(.hm-chat) {
  padding: 0;
}

.hm-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
}

.hm-chat-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
}

.hm-chat-home {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-left: 4px;
}

.hm-chat-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hm-chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 32px 24px 16px;
}

.hm-chat-messages {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
}

.hm-chat .ai-chat-bubble {
  font-size: 15px;
  line-height: 1.65;
}

.hm-chat .ai-chat-bubble p,
.hm-chat .ai-chat-bubble li {
  line-height: 1.65;
}

/* Headings follow the text size (styles.css), so they scale with it */

.hm-chat .ai-chat-message.user {
  max-width: 80%;
}

.hm-chat .ai-chat-message.user .ai-chat-bubble {
  padding: 10px 14px;
}

.hm-chat .ai-chat-message.ai {
  max-width: 100%;
}

.hm-chat .ai-chat-message.user + .ai-chat-message.ai,
.hm-chat .ai-chat-message.ai + .ai-chat-message.user {
  margin-top: 24px;
}

/* On a full page the answer's actions are always there, not only on hover */
.hm-chat .ai-chat-actions {
  margin-top: 6px;
  opacity: 1;
}

.hm-chat-foot {
  flex-shrink: 0;
  padding: 8px 24px 20px;
}

.hm-ask--reply {
  flex-direction: row;
  align-items: flex-end;
  max-width: 760px;
  margin: 0 auto;
  padding: 6px;
}

.hm-ask--reply .hm-ask-input {
  min-height: 40px;
  padding: 9px 10px 7px 12px;
}

.hm-ask--reply .hm-ask-send {
  flex-shrink: 0;
}

.hm-root :is(.hm-chip, .hm-link, .hm-icon-btn, .hm-row, .hm-check, .hm-task-title, .hm-ask-send):focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Phones ────────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .hm-page {
    padding: 20px 16px 48px;
  }

  .hm-greeting {
    font-size: 22px;
  }

  .hm-whatsnew {
    margin-bottom: 24px;
  }

  .hm-ask-hint {
    display: none;
  }

  .hm-owner {
    display: none;
  }

  .hm-stage {
    width: auto;
  }

  .hm-value {
    width: auto;
  }

  .hm-chat-title {
    display: none;
  }

  .hm-chat-bar {
    justify-content: space-between;
  }

  .hm-chat .ai-chat-message.user {
    max-width: 90%;
  }
}

/* Below 768px the bottom nav bar is showing: the chat ends above it */
@media (max-width: 767px) {
  .hm-chat {
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
    height: calc(100dvh - var(--header-height) - var(--bottom-nav-height));
  }

  .hm-chat-scroll {
    padding: 20px 16px 12px;
  }

  .hm-chat-foot {
    padding: 8px 16px 12px;
  }
}

.hm-ask--reply .hm-prompts-btn {
  flex-shrink: 0;
  margin-right: 6px;
}
