/* =============================================
   Components — ALL values from variables.css
   Zero hardcoded px for font-size.
   Zero hardcoded hex for colors.
   ============================================= */


/* ===========================================
   Stat Cards (4-up grid)
   =========================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  padding: var(--space-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--accent);
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.stat-card.warn::before { background: var(--sunshine); }
.stat-card.crit::before { background: var(--sriracha); }

.stat-num {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.stat-card.warn .stat-num { color: var(--badge-warn-text); }
.stat-card.crit .stat-num { color: var(--badge-crit-text); }

.stat-label {
  font-size: var(--text-sm);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: var(--space-xs);
  font-weight: 600;
  opacity: 0.7;
}


/* ===========================================
   Tables
   =========================================== */
.data-table {
  width: calc(100% - var(--space-3xl));
  border-collapse: collapse;
  margin: 0 var(--space-lg) var(--space-lg);
}

.data-table th {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  color: var(--text);
}

.data-table tr:hover {
  background: var(--accent-dim);
}

/* Empty table state */
.data-table-empty {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
  font-size: var(--text-sm);
}


/* ===========================================
   Chat Messages
   =========================================== */
.chat-area {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 200px;
  flex: 1;
  overflow-y: auto;
}

.msg {
  max-width: 75%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  font-size: var(--text-md);
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}

.msg-user {
  background: var(--accent);
  color: var(--accent-on);
  align-self: flex-end;
  border-bottom-right-radius: 0;
}

.msg-agent {
  background: var(--bg-card);
  color: var(--text);
  align-self: flex-start;
  border: 1px solid var(--border);
  border-bottom-left-radius: 0;
}

.msg-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Context usage bar */
.context-bar {
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text);
  font-weight: 500;
}

.context-track {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

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

/* Chat input */
.chat-input {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
}

.chat-input input {
  flex: 1;
  background: var(--bg-input);
  border: 2px solid var(--border);
  color: var(--text);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: var(--text-base);
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input input:focus { border-color: var(--accent); }

.chat-input button {
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: var(--text-sm);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition-fast);
}

.chat-input button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}


/* ===========================================
   Buttons
   =========================================== */
.btn {
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  font-size: var(--text-xs);
  padding: var(--space-sm) var(--space-lg);
}

.btn:hover { opacity: 0.9; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-on);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--sriracha);
  color: var(--sriracha);
}

.btn-danger:hover {
  background: var(--badge-crit-bg);
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--text-sm);
}

.btn-run {
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
}


/* ===========================================
   Badges
   =========================================== */
.badge {
  display: inline-block;
  padding: 1px var(--space-sm);
  border-radius: 2px;
  font-size: var(--text-sm);
  font-weight: 600;
}

.badge-ok   { background: var(--badge-ok-bg);   color: var(--badge-ok-text); }
.badge-warn { background: var(--badge-warn-bg); color: var(--badge-warn-text); }
.badge-crit { background: var(--badge-crit-bg); color: var(--badge-crit-text); }

.badge-info {
  background: rgba(107, 92, 255, 0.15);
  color: var(--azure);
}


/* ===========================================
   Severity Bars
   =========================================== */
.severity-bars {
  padding: 0 var(--space-lg) var(--space-lg);
}

.severity-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.severity-label {
  font-size: var(--text-sm);
  font-weight: 600;
  min-width: 60px;
  color: var(--text-muted);
}

.severity-track {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

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

/* Severity color helpers */
.severity-fill--crit { background: var(--sriracha); }
.severity-fill--high { background: var(--sunshine); }
.severity-fill--med  { background: var(--azure); }
.severity-fill--low  { background: var(--text-muted); }

.severity-count {
  font-size: var(--text-xs);
  font-weight: 600;
  min-width: 50px;
  text-align: right;
  color: var(--text);
}

.severity-count--crit { color: var(--sriracha); }
.severity-count--high { color: var(--sunshine); }
.severity-count--med  { color: var(--azure); }


/* ===========================================
   Memory Cards
   =========================================== */
.memory-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
}

.memory-search {
  flex: 1;
  position: relative;
}

.memory-search input {
  width: 100%;
  padding: var(--space-sm) var(--space-md) var(--space-sm) var(--space-3xl);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-xs);
  outline: none;
}

.memory-search input:focus { border-color: var(--accent); }

.memory-search-icon {
  position: absolute;
  left: var(--space-md);
  top: var(--space-sm);
  color: var(--text-muted);
  font-size: var(--text-xs);
  pointer-events: none;
}

.memory-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: 0 var(--space-lg) var(--space-lg);
}

.memory-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
}

.memory-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  flex-wrap: wrap;
}

.memory-type {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px var(--space-sm);
  border-radius: 2px;
  text-transform: uppercase;
}

.memory-type-fact         { background: rgba(107, 92, 255, 0.15); color: var(--azure); }
.memory-type-preference   { background: var(--accent-dim);         color: var(--accent); }
.memory-type-correction   { background: var(--badge-crit-bg);      color: var(--sriracha); }
.memory-type-relationship { background: var(--badge-warn-bg);      color: var(--sunshine); }
.memory-type-decision     { background: rgba(25, 52, 65, 0.15);   color: var(--forest); }
.memory-type-mistake      { background: var(--badge-crit-bg);      color: var(--sriracha); }
.memory-type-generic      { background: rgba(76, 75, 84, 0.15);   color: var(--text-muted); }

.memory-content {
  font-weight: 600;
  font-size: var(--text-md);
}

.memory-confidence {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.memory-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.memory-meta strong { color: var(--text); }


/* ===========================================
   Modals
   =========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: 700;
}

.modal-body { padding: var(--space-xl); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--border);
}


/* ===========================================
   Toast Notifications
   =========================================== */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-base);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  pointer-events: auto;
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

.toast.success { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid var(--sunshine); }
.toast.error   { border-left: 3px solid var(--sriracha); }
.toast.info    { border-left: 3px solid var(--azure); }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
  font-size: var(--text-md);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(var(--space-xl)); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(var(--space-xl)); }
}


/* ===========================================
   Empty States
   =========================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-4xl);
  color: var(--text-muted);
  text-align: center;
  min-height: 200px;
}

.empty-state-icon {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-lg);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--text);
}

.empty-state-desc {
  font-size: var(--text-base);
  max-width: 360px;
  line-height: 1.5;
}

.empty-state-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-lg);
  opacity: 0.7;
}


/* ===========================================
   Skeleton Loaders
   =========================================== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--border) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-line { height: var(--space-md); margin-bottom: var(--space-sm); }
.skeleton-card { height: 80px; margin-bottom: var(--space-md); }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ===========================================
   Toggle / Checkbox
   =========================================== */
.toggle {
  position: relative;
  display: inline-block;
  width: var(--space-3xl);
  height: 18px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 9px;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background: var(--text);
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }

.toggle input:checked + .toggle-slider::before {
  transform: translateX(14px);
  background: var(--accent-on);
}


/* ===========================================
   Activity Timeline
   =========================================== */
.activity-feed {
  padding: var(--space-lg);
  font-family: var(--mono);
  font-size: var(--text-base);
}

.activity-line { line-height: 1.8; }

.activity-time         { color: var(--text-muted); }
.activity-type-scan    { color: var(--accent); }
.activity-type-alert   { color: var(--sunshine); }
.activity-type-tool    { color: var(--azure); }
.activity-type-error   { color: var(--sriracha); }
.activity-type-memory  { color: var(--text-muted); }
.activity-type-chat    { color: var(--text); }
.activity-detail       { color: var(--text-muted); }

.activity-line.old { opacity: 0.5; }


/* ===========================================
   Skill Cards
   =========================================== */
.skill-list {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.skill-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-md);
  align-items: start;
}

.skill-card.disabled { opacity: 0.5; }

.skill-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
}

.skill-name {
  font-size: var(--text-lg);
  font-weight: 700;
}

.skill-version {
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px var(--space-sm);
  border-radius: 2px;
}

.skill-desc {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.skill-stats {
  display: flex;
  gap: var(--space-lg);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.skill-stats strong { color: var(--text); }

/* Success rate highlight — use class instead of inline style */
.skill-stats .stat-success { color: var(--accent); }

.skill-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-sm);
}


/* ===========================================
   Settings-specific
   =========================================== */
.settings-textarea {
  width: 100%;
  min-height: 200px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--text-xs);
  padding: var(--space-md);
  resize: vertical;
  outline: none;
}

.settings-textarea:focus { border-color: var(--accent); }

/* Rules description text */
.rules-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* Utility: margin-top spacer */
.mt-md { margin-top: var(--space-md); }

/* Form fields */
.form-group { margin-bottom: var(--space-lg); }

.form-label {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  outline: none;
}

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

/* Padded content wrapper (replaces inline padding divs) */
.padded { padding: var(--space-xl); }

/* Section label (replaces inline font-size/color divs) */
.section-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-md);
}


/* ===========================================
   Roadmap Items
   =========================================== */
.roadmap-section { margin-bottom: var(--space-2xl); }

.roadmap-section-title {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.roadmap-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-size: var(--text-md);
}


/* ===========================================
   Changelog Entries
   =========================================== */
.changelog-entry { margin-bottom: var(--space-xl); }

.changelog-version {
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.changelog-date {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.changelog-list {
  list-style: none;
  padding: 0;
}

.changelog-list li {
  font-size: var(--text-base);
  color: var(--text-muted);
  padding: 2px 0;
}

.changelog-list li::before {
  content: '+ ';
  color: var(--accent);
  font-weight: 700;
}


/* ===========================================
   Wishlist Cards
   =========================================== */
.wishlist-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.wishlist-title {
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.wishlist-desc {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.wishlist-actions {
  display: flex;
  gap: var(--space-sm);
}


/* ===========================================
   Checkbox with label
   =========================================== */
.check-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.check-label input[type="checkbox"] {
  width: var(--space-md);
  height: var(--space-md);
  accent-color: var(--accent);
}

/* Larger checkbox variant (skill toggles) */
.check-label--lg input[type="checkbox"] {
  width: var(--space-lg);
  height: var(--space-lg);
}


/* ===========================================
   Global Hover States (#26)
   =========================================== */

/* Sidebar agent items */
.agent-item:hover {
  background: var(--accent-dim);
  cursor: pointer;
}

/* Sidebar category tabs */
.sidebar-cat:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Stat cards */
.stat-card:hover {
  cursor: default;
}

/* Buttons (all) */
.btn:hover,
.btn-new-agent:hover,
.btn-run:hover {
  cursor: pointer;
}

/* Skill cards */
.skill-card:hover {
  border-color: var(--accent);
  transition: border-color var(--transition-fast);
}

/* Memory cards */
.memory-card:hover {
  border-color: var(--accent);
  transition: border-color var(--transition-fast);
}


/* ===========================================
   Focus Indicators (#27)
   =========================================== */
.tab:focus-visible,
.sidebar-cat:focus-visible,
.agent-item:focus-visible,
.btn:focus-visible,
.btn-new-agent:focus-visible,
.btn-run:focus-visible,
.cli-btn:focus-visible,
.chat-input input:focus-visible,
.cli-input:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.settings-textarea:focus-visible,
.toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ===========================================
   Smooth Transitions (#28)
   =========================================== */
.agent-item,
.sidebar-cat,
.stat-card,
.tab,
.btn,
.btn-new-agent,
.btn-run,
.skill-card,
.memory-card,
.badge,
.header-controls button {
  transition: all var(--transition-fast);
}


/* ===========================================
   Light Mode Overrides (#20-23)
   =========================================== */

/* New Agent button — Forest bg with white text in light mode (#22) */
[data-theme="light"] .btn-new-agent {
  background: var(--forest);
  color: var(--beige);
}

/* Stat card shadows in light mode (#23) */
[data-theme="light"] .stat-card {
  box-shadow: var(--shadow-sm);
}

/* ===========================================
   Disabled / Coming Soon States
   =========================================== */
.btn-disabled,
button:disabled,
button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.coming-soon {
  opacity: 0.5;
  position: relative;
}


/* Welcome message in chat */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-2xl);
}

.chat-welcome-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.chat-welcome-desc {
  font-size: var(--text-base);
  max-width: 360px;
  line-height: 1.5;
}
