/* ═══════════════════════════════════════════════════════
   Tristar Ops — Design System
   ═══════════════════════════════════════════════════════ */

:root {
  --bg: #0a0e17;
  --surface: #111827;
  --surface-2: #1a2332;
  --surface-3: #1e293b;
  --border: #1e293b;
  --border-light: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --accent: #06b6d4;
  --accent-hover: #22d3ee;
  --accent-dim: rgba(6, 182, 212, 0.12);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --orange: #f97316;
  --orange-dim: rgba(249, 115, 22, 0.12);
  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.12);
  --mono: 'JetBrains Mono', monospace;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── NAV ── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-top {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 32px;
}

.nav-brand {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 2px;
}

.nav-link {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-dim);
  transition: all 0.15s;
  cursor: pointer;
  text-decoration: none;
}

.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── WORKSPACE NAV (second tier) ── */
.nav-workspace {
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.nav-back {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-back:hover { color: var(--accent); }

.nav-client-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  padding-right: 16px;
  border-right: 1px solid var(--border);
}

.nav-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── LAYOUT ── */
.page {
  padding-top: 48px;
  min-height: 100vh;
}

.has-workspace .page {
  padding-top: 92px;
}

.page-header {
  padding: 32px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 4px;
}

.page-body {
  padding: 24px 32px 48px;
}

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-body { padding: 20px; }

/* ── STAT CARDS (metric boxes) ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── SCORE BADGE ── */
.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 600;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
}

.score-sm { font-size: 12px; padding: 2px 8px; }
.score-lg { font-size: 20px; padding: 8px 16px; }

.score-green { color: var(--green); background: var(--green-dim); }
.score-yellow { color: var(--yellow); background: var(--yellow-dim); }
.score-red { color: var(--red); background: var(--red-dim); }
.score-blue { color: var(--blue); background: var(--blue-dim); }

/* ── TABLE ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--surface-2); }

tr.clickable { cursor: pointer; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface);
  color: var(--text-dim);
}

.btn:hover {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--surface-2);
}

.btn-primary {
  background: var(--accent);
  color: #0a0e17;
  border-color: var(--accent);
  font-weight: 600;
}

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

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-dim); }

.btn-success { color: var(--green); border-color: var(--green); }
.btn-success:hover { background: var(--green-dim); }

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── TAGS / BADGES ── */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tag-green { color: var(--green); background: var(--green-dim); }
.tag-yellow { color: var(--yellow); background: var(--yellow-dim); }
.tag-red { color: var(--red); background: var(--red-dim); }
.tag-blue { color: var(--accent); background: var(--accent-dim); }
.tag-purple { color: var(--purple); background: var(--purple-dim); }
.tag-orange { color: var(--orange); background: var(--orange-dim); }

/* ── FORMS ── */
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--sans);
  width: 100%;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 6px;
}

/* ── PROGRESS BAR ── */
.progress-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}

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

/* ── TOAST / ALERTS ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: slideUp 0.2s ease-out;
}

.toast-success { border-color: var(--green); color: var(--green); }
.toast-error { border-color: var(--red); color: var(--red); }

@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── LOADING ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  gap: 12px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text-dim); }

/* ── GRID UTILS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.text-mono { font-family: var(--mono); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── CLIENT LIST (home page) ── */
.client-row {
  display: grid;
  grid-template-columns: 2fr repeat(5, 1fr) 80px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.client-row:hover { background: var(--surface-2); }
.client-row:last-child { border-bottom: none; }

.client-name {
  font-weight: 600;
  color: var(--text);
}

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

/* ── ISSUE LIST ── */
.issue-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.issue-severity {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.issue-severity.critical { background: var(--red); }
.issue-severity.warning { background: var(--yellow); }
.issue-severity.info { background: var(--blue); }

.issue-text { flex: 1; }
.issue-title { font-size: 14px; color: var(--text); }
.issue-detail { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── SECTION DIVIDER ── */
.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* ── RESPONSIVE ── */
/* ── Content images — never stretch ── */
.content-preview img, .page-content img, .preview-frame img, .editor-area img {
  max-width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  border-radius: 6px;
  margin: 12px 0;
}

@media (max-width: 768px) {
  .nav-top { padding: 0 12px; gap: 12px; }
  .nav-workspace { padding: 0 12px; gap: 12px; }
  .nav-client-name { display: none; }
  .page-header, .page-body { padding-left: 16px; padding-right: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .client-row { grid-template-columns: 1fr 1fr; }
}
