/* ========================================
   COMPONENTS.CSS - Reusable UI Components
   ======================================== */

/* ========================================
   DAY HEADER
   ======================================== */

.day-header {
  margin-bottom: 24px;
}

.day-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.day-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 13px;
}

.word-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(124, 92, 252, 0.2);
}

.week-badge {
  color: var(--text-muted);
  font-weight: 500;
}

/* ========================================
   SCORE CARDS
   ======================================== */

.score-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}

.score-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.score-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 12px 12px;
  width: 0%;
  background: transparent;
  transition: width 0.8s ease;
}

.score-card.work::after {
  background: var(--accent);
}

.score-card.health::after {
  background: var(--green);
}

.score-card.personal::after {
  background: var(--personal-accent);
}

.score-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.score-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.score-card.work .score-value {
  color: var(--accent);
}

.score-card.health .score-value {
  color: var(--green);
}

.score-card.personal .score-value {
  color: var(--personal-accent);
}

.score-target {
  font-size: 12px;
  color: var(--text-muted);
}

/* ========================================
   DAILY WIN
   ======================================== */

.daily-win {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}

.daily-win:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.win-status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.win-items {
  display: flex;
  gap: 12px;
  flex: 1;
  flex-wrap: wrap;
}

.win-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.win-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.win-check.done {
  border-color: var(--green);
  background: var(--green-soft);
}

.win-check.done::after {
  content: '✓';
  font-size: 11px;
  color: var(--green);
  font-weight: 700;
}

/* ========================================
   SECTION HEADERS
   ======================================== */

.section {
  margin-bottom: 20px;
}

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

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* ========================================
   STACK ITEMS
   ======================================== */

.stack-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.2s;
  cursor: pointer;
}

.stack-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.stack-item.completed {
  opacity: 0.5;
}

.stack-item.completed .stack-task {
  text-decoration: line-through;
}

.stack-rank {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
}

.stack-rank.health-rank {
  background: var(--green-soft);
  color: var(--green);
}

.stack-rank.personal-rank {
  background: var(--personal-glow);
  color: var(--personal-accent);
}

.stack-content {
  flex: 1;
  min-width: 0;
}

.stack-task {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  word-break: break-word;
}

.stack-why {
  font-size: 12px;
  color: var(--text-muted);
}

.stack-points {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  flex-shrink: 0;
}

/* ========================================
   SCHEDULE
   ======================================== */

.schedule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.schedule-time {
  font-weight: 600;
  color: var(--text-secondary);
  width: 80px;
  flex-shrink: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.schedule-dot.work {
  background: var(--accent);
}

.schedule-dot.health {
  background: var(--green);
}

.schedule-dot.personal {
  background: var(--personal-accent);
}

.schedule-dot.family {
  background: var(--amber);
}

.schedule-label {
  color: var(--text);
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* ========================================
   FLAGS
   ======================================== */

.flag-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--red-soft);
  border: 1px solid rgba(248, 113, 113, 0.15);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.flag-item:last-child {
  margin-bottom: 0;
}

.flag-icon {
  color: var(--red);
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
  font-weight: 700;
}

.flag-text {
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

.flag-text strong {
  color: var(--text);
  font-weight: 600;
}

/* ========================================
   EXPANDABLE SECTIONS
   ======================================== */

.context-section {
  margin-bottom: 8px;
}

.context-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  font-family: inherit;
  color: var(--text);
  text-align: left;
}

.context-trigger:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.context-trigger-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.context-trigger-label {
  font-size: 13px;
  font-weight: 500;
}

.context-trigger-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.context-arrow {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.context-body {
  display: none;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  margin-top: -10px;
  padding-top: 20px;
  animation: slideDown 0.2s ease;
}

.context-section.open .context-trigger {
  border-radius: 10px 10px 0 0;
  border-bottom-color: transparent;
}

.context-section.open .context-body {
  display: block;
}

.context-section.open .context-arrow {
  transform: rotate(90deg);
}

/* ========================================
   PIPELINE TABLE
   ======================================== */

.pipeline-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

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

.pipeline-name {
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.4;
}

.pipeline-stage {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.pipeline-amount {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ========================================
   HEALTH CARD
   ======================================== */

.health-card {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
}

.health-card-title {
  font-weight: 600;
  color: var(--green);
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.health-card ul {
  margin: 0;
  padding-left: 16px;
  list-style: disc;
}

.health-card li {
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 1.5;
}

/* ========================================
   TASK BACKLOG
   ======================================== */

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 13px;
  border-left: 3px solid var(--accent);
}

.task-item.done {
  opacity: 0.5;
  background: var(--surface);
}

.task-item.done .task-name {
  text-decoration: line-through;
}

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

.task-dot.high {
  background: var(--red);
}

.task-dot.medium {
  background: var(--amber);
}

.task-dot.low {
  background: var(--green);
}

.task-content {
  flex: 1;
  min-width: 0;
}

.task-name {
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

.task-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ========================================
   AREA HEALTH
   ======================================== */

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

.area-card {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
}

.area-status {
  font-weight: 600;
  margin-bottom: 4px;
}

.area-status.ok {
  color: var(--green);
}

.area-status.warning {
  color: var(--amber);
}

.area-status.critical {
  color: var(--red);
}

.area-name {
  color: var(--text-secondary);
  font-size: 11px;
}

/* ========================================
   EMPTY STATE
   ======================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 12px;
}

/* ========================================
   CHAT MESSAGES
   ======================================== */

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: slideUp 0.3s ease;
}

.chat-msg.rosalind {
  align-items: flex-start;
}

.chat-msg.user {
  align-items: flex-end;
}

.chat-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 16px;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-msg.rosalind .chat-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  color: var(--text-secondary);
}

.chat-msg.user .chat-bubble {
  background: var(--accent);
  border-radius: 12px 12px 4px 12px;
  color: white;
}

.chat-typing {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.4s infinite;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 80%, 100% { opacity: 0.5; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

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

@media (max-width: 900px) {
  .score-bar {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .score-card {
    padding: 12px;
  }

  .score-value {
    font-size: 22px;
  }

  .daily-win {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .win-items {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .day-header h1 {
    font-size: 20px;
  }

  .stack-item {
    padding: 12px 14px;
    gap: 10px;
  }

  .context-trigger {
    padding: 10px 12px;
  }

  .schedule-time {
    width: 70px;
    font-size: 11px;
  }

  .score-pill {
    padding: 4px 10px;
  }
}

@media (max-width: 480px) {
  .day-header h1 {
    font-size: 18px;
  }

  .day-meta {
    font-size: 12px;
    gap: 8px;
  }

  .score-bar {
    gap: 6px;
  }

  .score-card {
    padding: 10px;
  }

  .score-label {
    font-size: 10px;
  }

  .score-value {
    font-size: 18px;
  }

  .score-target {
    font-size: 11px;
  }

  .daily-win {
    padding: 12px;
  }

  .win-item {
    font-size: 12px;
  }

  .stack-item {
    padding: 10px 12px;
    gap: 8px;
  }

  .stack-rank {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .stack-task {
    font-size: 13px;
  }

  .stack-why {
    font-size: 11px;
  }

  .stack-points {
    font-size: 11px;
  }

  .context-trigger {
    padding: 10px;
    font-size: 12px;
  }

  .context-body {
    padding: 12px;
  }

  .chat-bubble {
    max-width: 90%;
    font-size: 12px;
  }

  .pipeline-row {
    flex-direction: column;
    padding: 10px 0;
  }

  .pipeline-amount {
    width: 100%;
    text-align: left;
  }

  .area-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   PAGE VIEW (non-dashboard pages)
   ======================================== */

.page-view {
  animation: fadeIn 0.25s ease;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 700px) {
  .page-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Filter bar ── */

.filter-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: var(--surface-2);
}

.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ── Stat bar ── */

.stat-bar {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.stat-number {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Task rows ── */

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

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

.task-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-checkbox.checked {
  background: var(--green);
  border-color: var(--green);
}

.task-checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.task-text {
  font-size: 13px;
  color: var(--text);
}

.task-text.done {
  text-decoration: line-through;
  opacity: 0.5;
}

/* ── Schedule rows (full page) ── */

.schedule-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.schedule-row-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 110px;
  flex-shrink: 0;
}

.schedule-row-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.schedule-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.schedule-row-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Note rows ── */

.note-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

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

.note-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.note-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.note-row-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.note-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.note-content {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.note-error {
  font-size: 12px;
  color: var(--red);
}

/* ── File rows ── */

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: opacity 0.2s;
}

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

.file-row:hover {
  opacity: 0.8;
}

.file-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

.file-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Archive rows ── */

.archive-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

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

.archive-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.archive-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.archive-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.archive-row-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.archive-expand {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  flex-shrink: 0;
}

.archive-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ── Progress bar ── */

.progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ── Goal list ── */

.goal-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.goal-list li {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.goal-list li:last-child {
  border-bottom: none;
}

.goal-list li::before {
  content: '•';
  color: var(--green);
  margin-right: 8px;
  font-weight: 700;
}

/* ── Faith check rows ── */

.faith-check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.faith-check-row:hover {
  opacity: 0.8;
}
