/* Rainmaker — App Styles */
/* Imports design tokens from the landing page: dark bg, gold accent, Space Grotesk */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500&display=swap');

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1a1a1a;
  --border: #222;
  --border-light: #2a2a2a;
  --gold: #c8a234;
  --gold-light: #e8c854;
  --gold-dim: rgba(200, 162, 52, 0.12);
  --gold-glow: rgba(200, 162, 52, 0.08);
  --text: #e8e8e8;
  --text-muted: #888;
  --text-dim: #555;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --radius: 6px;
  --radius-lg: 10px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Top Bar ─────────────────────────────────────────────────────────────── */

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 10;
}

.topbar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.5px;
  text-decoration: none;
}

.topbar-logo span {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 8px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  grid-row: 2;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
  background: var(--bg);
}

.sidebar-section {
  padding: 4px 12px 12px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--gold-dim); color: var(--gold); }
.nav-item .icon { font-size: 15px; width: 18px; text-align: center; }

/* ── Main Content ─────────────────────────────────────────────────────────── */

.main {
  grid-row: 2;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Views ─────────────────────────────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }

/* ── Page Header ─────────────────────────────────────────────────────────── */

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

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Stats Strip ─────────────────────────────────────────────────────────── */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color 0.15s;
}

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

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
}

.stat-value.gold { color: var(--gold); }
.stat-value.green { color: var(--green); }

/* ── Pipeline Kanban ─────────────────────────────────────────────────────── */

.pipeline-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  min-height: 500px;
}

.pipeline-board::-webkit-scrollbar { height: 4px; }
.pipeline-board::-webkit-scrollbar-track { background: transparent; }
.pipeline-board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.pipeline-col {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top: 2px solid currentColor;
}

.stage-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.stage-count {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 1px 7px;
  border-radius: 20px;
}

.pipeline-col-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* ── Deal Card ─────────────────────────────────────────────────────────────── */

.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.deal-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.deal-card-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.deal-card-company {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.deal-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.deal-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
}

.deal-prob {
  font-size: 11px;
  color: var(--text-dim);
}

.deal-close-date {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ── Deals Table ─────────────────────────────────────────────────────────── */

.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.data-table tbody tr:hover { background: var(--surface2); }

/* ── Stage Badge ─────────────────────────────────────────────────────────── */

.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(200, 162, 52, 0.1);
}

.stage-badge::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

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

.empty-state h3 {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.empty-state p { font-size: 13px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gold);
  color: #0a0a0a;
}

.btn-primary:hover {
  background: var(--gold-light);
  box-shadow: 0 0 12px rgba(200, 162, 52, 0.3);
}

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

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

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

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.15s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-lg { max-width: 720px; }

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: color 0.15s;
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close:hover { color: var(--text); background: var(--surface2); }

.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 8px; justify-content: flex-end; }

/* ── Form ────────────────────────────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .form-group.full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.form-input, .form-select, .form-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  padding: 8px 12px;
  transition: border-color 0.15s;
  width: 100%;
}

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

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-dim); }
.form-select { cursor: pointer; }
.form-select option { background: var(--surface2); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── AI Panel ────────────────────────────────────────────────────────────── */

.ai-panel {
  background: linear-gradient(135deg, var(--surface2) 0%, rgba(20, 14, 3, 0.8) 100%);
  border: 1px solid rgba(200, 162, 52, 0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
}

.ai-spark { font-size: 16px; }

.ai-action-tabs {
  display: flex;
  gap: 6px;
}

.ai-tab {
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s;
}

.ai-tab.active {
  background: var(--gold-dim);
  border-color: rgba(200, 162, 52, 0.3);
  color: var(--gold);
}

.ai-tab:hover:not(.active) { border-color: var(--border-light); color: var(--text); }

.ai-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 120px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  font-family: 'Inter', sans-serif;
}

.ai-output.loading {
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-subject {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 12px;
}

.ai-subject-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.ai-subject-value {
  color: var(--text);
  font-weight: 600;
}

/* ── Spinning loader ─────────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-light);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ── Deal Detail ─────────────────────────────────────────────────────────── */

.deal-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.deal-detail-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.deal-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.meta-chip.gold { border-color: rgba(200,162,52,0.3); color: var(--gold); background: var(--gold-dim); }
.meta-chip.green { border-color: rgba(34,197,94,0.2); color: var(--green); background: rgba(34,197,94,0.08); }

.deal-detail-section {
  margin-bottom: 20px;
}

.deal-detail-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Event Timeline ─────────────────────────────────────────────────────── */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  position: relative;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  flex-shrink: 0;
  margin-top: 5px;
}

.timeline-dot.gold { background: var(--gold); }

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

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

.timeline-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

/* ── Contacts Table ─────────────────────────────────────────────────────── */

.contact-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  font-family: 'Space Grotesk', sans-serif;
  flex-shrink: 0;
}

.contact-info { display: flex; align-items: center; gap: 10px; }
.contact-name { font-weight: 600; font-size: 13.5px; }
.contact-company { font-size: 12px; color: var(--text-muted); }

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  animation: toastIn 0.2s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-width: 300px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
  }
  .sidebar { display: none; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
}
