/* ============================================
   SteveDave Dashboard V2 — Base CSS
   Mobile-first, dark theme, no dependencies
   ============================================ */

:root {
  --bg-primary: #1A1A2E;
  --bg-card: #16213E;
  --bg-card-alt: #0F3460;
  --bg-input: #1e2a4a;
  --text-primary: #E2E8F0;
  --text-secondary: #A0AEC0;
  --text-muted: #718096;
  --accent-blue: #4A9EFF;
  --accent-purple: #9F7AEA;
  --status-green: #38A169;
  --status-amber: #D69E2E;
  --status-red: #E53E3E;
  --status-green-bg: rgba(56,161,105,0.15);
  --status-amber-bg: rgba(214,158,46,0.15);
  --status-red-bg: rgba(229,62,62,0.15);
  --border: rgba(255,255,255,0.08);
  --border-focus: rgba(74,158,255,0.5);
  --tab-height: 64px;
  --header-height: 48px;
  --card-radius: 12px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ======= LAYOUT ======= */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh; /* fallback */
}

#header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 100;
}

#header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

#refresh-indicator {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

#refresh-indicator.refreshing {
  color: var(--accent-blue);
  animation: pulse 1s infinite;
}

#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ======= TAB BAR ======= */
#tab-bar {
  height: var(--tab-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  scroll-snap-type: x mandatory;
  -ms-overflow-style: none;
  scrollbar-width: none;
  z-index: 100;
}

#tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font);
  cursor: pointer;
  flex-shrink: 0;
  scroll-snap-align: start;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.tab-btn:active {
  background: rgba(255,255,255,0.05);
}

.tab-btn.active {
  color: var(--accent-blue);
  background: rgba(74,158,255,0.08);
}

.tab-btn .tab-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
}

.tab-btn .tab-label {
  font-size: 9px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 68px;
  text-align: center;
}

/* ======= TAB PANELS ======= */
.tab-panel {
  display: none;
  padding: 12px 12px 8px 12px;
  min-height: 100%;
}

.tab-panel.active { display: block; }

/* ======= CARDS ======= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 14px;
  margin-bottom: 12px;
}

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

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

/* ======= STATUS BADGES ======= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-up, .badge-ok, .badge-green {
  background: var(--status-green-bg);
  color: var(--status-green);
}

.badge-warn, .badge-amber {
  background: var(--status-amber-bg);
  color: var(--status-amber);
}

.badge-down, .badge-crit, .badge-red {
  background: var(--status-red-bg);
  color: var(--status-red);
}

.badge-unknown {
  background: rgba(255,255,255,0.08);
  color: var(--text-muted);
}

/* ======= STAT GRID ======= */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-item {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.stat-value.urgent { color: var(--status-red); }
.stat-value.week { color: var(--status-amber); }
.stat-value.soon { color: var(--status-green); }
.stat-value.backlog { color: var(--text-muted); }

/* ======= TASK LIST ======= */
.task-list {
  list-style: none;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

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

.task-dot.urgent { background: var(--status-red); }
.task-dot.week { background: var(--status-amber); }
.task-dot.soon { background: var(--status-green); }
.task-dot.backlog { background: var(--text-muted); }
.task-dot.completed { background: var(--text-muted); }

.task-text {
  flex: 1;
  color: var(--text-primary);
  line-height: 1.4;
}

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

.task-due {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ======= PROGRESS BAR ======= */
.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-fill.ok { background: var(--status-green); }
.progress-fill.warn { background: var(--status-amber); }
.progress-fill.crit { background: var(--status-red); }

/* ======= METRIC ROW ======= */
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.metric-label { color: var(--text-secondary); }
.metric-value { font-weight: 600; color: var(--text-primary); }

/* ======= ALERTS BANNER ======= */
#alerts-banner {
  background: var(--status-red-bg);
  border: 1px solid var(--status-red);
  border-radius: var(--card-radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  display: none;
}

#alerts-banner.visible { display: block; }

#alerts-banner .alert-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--status-red);
  margin-bottom: 6px;
}

#alerts-banner .alert-item {
  font-size: 12px;
  color: var(--text-primary);
  padding: 2px 0;
}

/* ======= FORMS ======= */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--border-focus);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: 8px;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active { opacity: 0.8; transform: scale(0.98); }

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  width: 100%;
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  width: 100%;
}

.btn-success {
  background: var(--status-green);
  color: #fff;
  width: 100%;
}

/* ======= COUNTDOWN ======= */
.countdown-block {
  text-align: center;
  padding: 12px 0;
}

.countdown-days {
  font-size: 48px;
  font-weight: 900;
  color: var(--accent-blue);
  line-height: 1;
}

.countdown-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ======= PLACEHOLDER ======= */
.placeholder-panel {
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
}

.placeholder-panel .placeholder-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.placeholder-panel .placeholder-text {
  font-size: 13px;
  color: var(--text-muted);
}

.placeholder-panel .placeholder-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}

/* ======= WORKFLOW LIST ======= */
.workflow-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.workflow-item:last-child { border-bottom: none; }
.workflow-name { color: var(--text-primary); flex: 1; }
.workflow-status { font-size: 11px; }

/* ======= AGENT ROSTER ======= */
.agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.agent-emoji {
  font-size: 22px;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.agent-info { flex: 1; }
.agent-name { font-size: 14px; font-weight: 700; }
.agent-role { font-size: 11px; color: var(--text-muted); }

.agent-model {
  font-size: 11px;
  color: var(--accent-blue);
  text-align: right;
  white-space: nowrap;
}

/* ======= ERROR / SKELETON ======= */
.panel-error {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.panel-error .error-icon { font-size: 24px; margin-bottom: 6px; }

/* ======= UTILITIES ======= */
.text-green { color: var(--status-green); }
.text-amber { color: var(--status-amber); }
.text-red { color: var(--status-red); }
.text-muted { color: var(--text-muted); }
.text-blue { color: var(--accent-blue); }
.text-small { font-size: 12px; }
.text-center { text-align: center; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mb-0 { margin-bottom: 0; }

.dot-green { color: var(--status-green); }
.dot-amber { color: var(--status-amber); }
.dot-red { color: var(--status-red); }

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

.divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ======= HEALTH LOG SUCCESS ======= */
.success-flash {
  background: var(--status-green-bg);
  border: 1px solid var(--status-green);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--status-green);
  margin-bottom: 12px;
  display: none;
}

.success-flash.visible { display: block; }

/* ======= SCROLL HINT ======= */
.scroll-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0 10px;
}

/* ======= HEALTH TAB — special tab button ======= */
.tab-btn-special { color: #48BB78; }
.tab-btn-special .tab-icon { filter: drop-shadow(0 0 4px #48BB78); }
.tab-btn-special.active { color: #48BB78; background: rgba(72,187,120,0.12); }

/* ======= HEALTH — card-health-hero ======= */
.card-health-hero {
  border-color: #48BB78;
  border-width: 2px;
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(72,187,120,0.06) 100%);
}
.badge-grace {
  background: #48BB78;
  color: #000;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* ======= RX TRACKER ======= */
.rx-list { display: flex; flex-direction: column; gap: 0; }
.rx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.rx-row:last-child { border-bottom: none; }
.rx-checkbox {
  width: 20px;
  height: 20px;
  accent-color: #48BB78;
  cursor: pointer;
  flex-shrink: 0;
}

/* ======= RX ALERT BADGE on tab button ======= */
.rx-alert-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  background: var(--status-amber);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.tab-btn { position: relative; }

/* ======= TASK INTERACTIVE (checkboxes + cross-off) ======= */
.task-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-blue);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 3px;
}
.task-done .task-text {
  text-decoration: line-through;
  opacity: 0.4;
}
.task-title-toggle { cursor: pointer; }
.task-title-toggle:hover { color: var(--accent-blue); }
.task-detail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-top: 4px;
  transition: all 0.15s ease;
}
.task-meta-tag {
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  color: var(--text-muted);
}

/* ======= QUICK WINS CARD ======= */
.card-quick-wins { border-color: rgba(214,158,46,0.4); }

/* ======= WARREN FINANCE ======= */
.warren-rec-row {
  display: flex;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.warren-rec-row:last-child { border-bottom: none; }

/* ======= ACCORDION ======= */
.accordion-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.accordion-chevron { color: var(--text-muted); font-size: 11px; }
.accordion-body {
  display: none;
  padding-top: 10px;
}
.accordion-body.open { display: block; }

/* ======= YOUTUBE CHANNEL GRID ======= */
.channel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.channel-card {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 12px 10px;
  text-align: center;
}
.channel-icon { font-size: 24px; margin-bottom: 4px; }
.channel-name { font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.channel-tag { font-size: 10px; color: var(--text-muted); }

/* ======= RESPONSIVE: tablet/desktop bonus ======= */
@media (min-width: 600px) {
  .stat-grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  .tab-btn {
    min-width: 80px;
  }
}

@media (min-width: 960px) {
  #content {
    max-width: 720px;
    margin: 0 auto;
  }

  #tab-bar {
    justify-content: center;
  }
}
