/* ---- App layout ---- */
.app-body {
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Nav ---- */
.app-nav {
  height: 56px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-surface);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none !important;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 4px 12px;
  border-radius: 99px;
  letter-spacing: 0.04em;
}

/* ---- App layout ---- */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 56px);
}

/* ---- Panels ---- */
.panel {
  overflow-y: auto;
  padding: 28px 24px;
}

.panel-left {
  width: 360px;
  min-width: 300px;
  border-right: 1px solid rgba(255,255,255,0.06);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex-shrink: 0;
}

.panel-right {
  flex: 1;
  background: var(--bg);
}

.panel-header h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.panel-sub {
  font-size: 14px;
  color: var(--fg-muted);
  line-height: 1.5;
}

/* ---- Form ---- */
.research-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-group input {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 14px;
  transition: border-color 0.15s;
  outline: none;
  width: 100%;
}

.form-group input::placeholder {
  color: var(--fg-dim);
}

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

/* ---- Buttons ---- */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  padding: 11px 20px;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: var(--fg-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  padding: 5px 12px;
  transition: background 0.15s, color 0.15s;
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--fg);
}

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

/* ---- Spinner ---- */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

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

/* ---- History ---- */
.history-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-header h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s;
}

.history-item:hover {
  border-color: rgba(79, 125, 249, 0.4);
  background: #1a1a22;
}

.history-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-company {
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-date {
  font-size: 11px;
  color: var(--fg-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.empty-state {
  font-size: 13px;
  color: var(--fg-dim);
  text-align: center;
  padding: 24px 0;
  line-height: 1.6;
}

/* ---- Results: Empty state ---- */
.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--fg-muted);
  gap: 12px;
}

.results-empty .empty-icon {
  font-size: 48px;
  opacity: 0.4;
}

.results-empty h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg-muted);
}

.results-empty p {
  font-size: 14px;
  color: var(--fg-dim);
  max-width: 300px;
  line-height: 1.6;
}

/* ---- Results: Loading state ---- */
.results-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 28px;
  text-align: center;
}

.loading-animation {
  position: relative;
  width: 64px;
  height: 64px;
}

.loading-orb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79,125,249,0.5) 0%, transparent 70%);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

.results-loading h3 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--fg-muted);
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--fg-dim);
  transition: color 0.3s;
}

.loading-step.active { color: var(--fg); }
.loading-step.done { color: var(--green); }

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  transition: background 0.3s;
}

.loading-step.active .step-dot {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: dot-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes dot-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.5); }
}

/* ---- Results: Content ---- */
.results-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

.results-header {
  padding: 24px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.prospect-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prospect-meta h2 {
  font-size: 1.4rem;
}

.prospect-company {
  font-size: 14px;
  color: var(--fg-muted);
}

.badge-complete {
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
  padding: 4px 12px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  padding: 20px 28px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px 10px;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

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

/* ---- Tab panels ---- */
.tab-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 20px 28px;
  gap: 12px;
}

/* ---- Email editor ---- */
.email-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.email-label {
  font-size: 12px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.email-actions {
  display: flex;
  gap: 8px;
}

.email-editor {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  min-height: 280px;
  padding: 16px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.email-editor:focus {
  border-color: rgba(79, 125, 249, 0.4);
}

.save-confirmation {
  font-size: 13px;
  color: var(--green);
  text-align: right;
  padding-top: 4px;
}

/* ---- Research summary ---- */
.research-summary {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 1.7;
  overflow-y: auto;
  padding: 20px;
  white-space: pre-wrap;
  flex: 1;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .panel-left {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }

  .panel-right {
    min-height: 600px;
  }
}
