/* ============================================================
   SoloDeck App Styles — extends theme.css tokens
   ============================================================ */

/* ── App Shell ────────────────────────────────────────────── */
.app-main {
  position: relative;
  z-index: 1;
  padding: 48px 0;
  min-height: calc(100vh - 64px);
}

.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 48px;
}

.app-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 48px;
  gap: 24px;
}

.app-page-title {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.app-page-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Auth ───────────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 48px 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
}

.auth-title {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 32px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #000;
}
.btn-primary:hover { background: var(--green-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

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

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

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-danger { background: #ff4444; color: #fff; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.required { color: var(--green); }
.label-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-left: 8px;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  transition: border-color 0.15s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-bg);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-dim); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Stats Cards ────────────────────────────────────────────── */
.campaign-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.stat-value {
  font-family: var(--display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Campaign Grid ─────────────────────────────────────────── */
.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.campaign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.campaign-card:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

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

.campaign-name {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.campaign-status {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-draft { background: var(--surface-2); color: var(--text-muted); }
.status-active { background: var(--green-bg); color: var(--green); }
.status-paused { background: rgba(255, 200, 0, 0.1); color: #ffc800; }
.status-completed { background: var(--surface-2); color: var(--text-dim); }

.campaign-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  text-align: center;
}

.metric-value {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.metric-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.campaign-sent-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 16px;
}

.sent-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.campaign-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.tab-btn {
  padding: 10px 20px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

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

.tab-content { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.tab-toolbar h3 {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-toolbar-right { display: flex; gap: 8px; }

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--surface-2);
  border-radius: 11px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Leads List ─────────────────────────────────────────────── */
.leads-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lead-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
}

.lead-row:hover { border-color: var(--text-muted); }

.lead-email { color: var(--text); font-weight: 500; }
.lead-name { color: var(--text-muted); }
.lead-company { color: var(--text-dim); }
.lead-status {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lead-status-sent { background: var(--green-bg); color: var(--green); }
.lead-status-pending { background: rgba(255,200,0,0.1); color: #ffc800; }
.lead-status-failed { background: rgba(255,68,68,0.1); color: #ff4444; }
.lead-status-replied { background: rgba(0,200,255,0.1); color: #00c8ff; }

/* ── Email Log ──────────────────────────────────────────────── */
.emails-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 16px;
  align-items: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
}

.email-to { color: var(--text); font-weight: 500; }
.email-subject { color: var(--text-muted); }
.email-status {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Settings ──────────────────────────────────────────────── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 24px;
}

.settings-section h3 {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

.settings-status { color: var(--text-muted); margin-bottom: 16px; }
.status-actions { display: flex; gap: 12px; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

.modal-content-sm { max-width: 480px; }

@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-header h2 {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }

/* ── Import UI ──────────────────────────────────────────────── */
.import-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}

.import-drop-zone:hover, .import-drop-zone.drag-over {
  border-color: var(--green);
  background: var(--green-bg);
}

.drop-icon {
  font-size: 2rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.drop-title {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.drop-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.import-format-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.import-preview {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  max-height: 200px;
  overflow-y: auto;
}

.import-preview table { width: 100%; border-collapse: collapse; }
.import-preview td { padding: 4px 8px; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ── Preview UI ─────────────────────────────────────────────── */
.preview-select-lead { margin-bottom: 20px; }
.preview-select-lead label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.preview-select-lead select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.preview-email {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.preview-field {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.preview-body {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ── Misc ──────────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  margin-bottom: 32px;
  margin-top: 16px;
}
.back-link:hover { color: var(--text); }

.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--text-muted);
}

.empty-hint { font-size: 0.8rem; color: var(--text-dim); margin-top: 8px; }

.campaigns-loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 48px;
  justify-content: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

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

.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 0.85rem;
  z-index: 300;
  animation: toastIn 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

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

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

/* ── Error states ─────────────────────────────────────────── */
.form-error {
  background: rgba(255, 68, 68, 0.1);
  border: 1px solid rgba(255, 68, 68, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.8rem;
  color: #ff4444;
  margin-bottom: 20px;
}

/* ── Auth forms ─────────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  text-align: center;
}

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

.auth-divider {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin: 16px 0;
}

/* ── Demo notice ─────────────────────────────────────────────── */
.demo-notice {
  background: rgba(255, 200, 0, 0.08);
  border: 1px solid rgba(255, 200, 0, 0.25);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.8rem;
  color: #ffc800;
  margin-bottom: 24px;
}

/* ── Loading states ─────────────────────────────────────────── */
button.loading {
  position: relative;
  color: transparent !important;
}
button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ── Upgrade Banner ─────────────────────────────────────────── */
.upgrade-banner {
  background: linear-gradient(135deg, rgba(59,130,246,0.12) 0%, rgba(59,130,246,0.05) 100%);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.upgrade-banner strong { color: var(--text); }

.upgrade-banner-link {
  color: #3b82f6;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.upgrade-banner-link:hover { text-decoration: underline; }