/* AI Ops Assistant v2.0 - Components */

/* ── Buttons ───────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-primary-hover);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-color-strong);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg-tertiary);
}

.btn-success {
  background: var(--brand-success);
  color: white;
}

.btn-danger {
  background: var(--brand-danger);
  color: white;
}

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

.btn-icon { width: 14px; height: 14px; }

/* ── Cards ─────────────────────────────── */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
}

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

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

/* ── Grid ──────────────────────────────── */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Table ─────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-tertiary);
}

.table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: var(--bg-tertiary);
}

.table-empty {
  padding: var(--space-3xl);
  text-align: center;
  color: var(--text-tertiary);
}

/* ── Badge ─────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
}

.badge-primary { background: var(--brand-primary-light); color: var(--brand-primary); }
.badge-success { background: #d1fae5; color: var(--brand-success); }
.badge-warning { background: #fef3c7; color: var(--brand-warning); }
.badge-danger { background: #fee2e2; color: var(--brand-danger); }
.badge-info { background: #e0f2fe; color: var(--brand-info); }
.badge-neutral { background: var(--neutral-200); color: var(--text-secondary); }

/* ── Filter Row ────────────────────────── */
.filter-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.filter-row .form-select { width: auto; min-width: 120px; }

/* ── Modal ─────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

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

.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform var(--transition-fast);
}

.modal-overlay.active .modal { transform: scale(1); }

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

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xs);
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.modal-body {
  padding: var(--space-xl);
  overflow-y: auto;
  flex: 1;
}

/* ── Toast ─────────────────────────────── */
.toast {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  color: white;
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  transform: translateX(120%);
  transition: transform var(--transition-normal);
  box-shadow: var(--shadow-lg);
}

.toast.show { transform: translateX(0); }
.toast-success { background: var(--brand-success); }
.toast-error { background: var(--brand-danger); }
.toast-info { background: var(--brand-primary); }

/* ── Stat Card ─────────────────────────── */
.stat-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.stat-label { font-size: 12px; color: var(--text-tertiary); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.stat-change { font-size: 12px; font-weight: 500; }
.stat-change.up { color: var(--brand-success); }
.stat-change.down { color: var(--brand-danger); }

/* ── Section ───────────────────────────── */
.section-gap { margin-top: var(--space-xl); }

.desc-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.subsection-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

/* ── Empty State ───────────────────────── */
.empty-state {
  padding: var(--space-3xl);
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-lg);
  color: var(--neutral-300);
}

.empty-state p {
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
}

/* ── Tabs (for sub-flow within a page) ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: var(--space-lg);
}

.tab-btn {
  padding: var(--space-sm) var(--space-lg);
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* ── Timeline (publication workflow) ───── */
.timeline {
  position: relative;
  padding-left: var(--space-xl);
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-lg);
}

.timeline-dot {
  position: absolute;
  left: -13px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--neutral-300);
  border: 2px solid var(--bg-primary);
}

.timeline-dot.success { background: var(--brand-success); }
.timeline-dot.error { background: var(--brand-danger); }
.timeline-dot.active { background: var(--brand-primary); box-shadow: 0 0 0 3px var(--brand-primary-light); }

.timeline-content {
  padding-left: var(--space-sm);
}

.timeline-title { font-weight: 500; font-size: 13px; }
.timeline-time { font-size: 11px; color: var(--text-tertiary); }

/* ── Alert Banner ──────────────────────── */
.alert-banner {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 13px;
  margin-bottom: var(--space-lg);
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

/* ── Loading Spinner ───────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--neutral-200);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Status Dot ────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--space-xs);
}

.status-dot.online { background: var(--brand-success); }
.status-dot.offline { background: var(--neutral-300); }
.status-dot.error { background: var(--brand-danger); }

/* ── File Upload ───────────────────────── */
.upload-area {
  border: 2px dashed var(--border-color-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-area:hover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}

.upload-area input[type="file"] { display: none; }

/* ── Code Block ────────────────────────── */
.code-block {
  background: var(--neutral-900);
  color: var(--neutral-100);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Toggle Switch ─────────────────────── */
.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--neutral-300);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: none;
  transition: background var(--transition-fast);
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle.active {
  background: var(--brand-primary);
}

.toggle.active::after {
  transform: translateX(16px);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
}

/* ── Row ───────────────────────────────── */
.row { display: flex; gap: var(--space-sm); align-items: center; }
.row-end { display: flex; gap: var(--space-sm); align-items: center; justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
