/* ===== APP SHELL ===== */
.app-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-nav {
  height: 56px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
  z-index: 10;
}

.app-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.app-nav-right {
  margin-left: auto;
}

.nav-badge {
  font-size: 0.8rem;
  color: var(--fg-dim);
  font-family: var(--font-display);
}

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

/* ===== SIDEBAR ===== */
.app-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  text-transform: uppercase;
}

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(108,92,231,0.15);
  border: 1px solid rgba(108,92,231,0.3);
  color: var(--accent);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-icon:hover { background: rgba(108,92,231,0.25); }

.icp-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.icp-item {
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.icp-item:hover { background: rgba(255,255,255,0.04); }
.icp-item.active { background: rgba(108,92,231,0.15); border: 1px solid rgba(108,92,231,0.25); }

.icp-item-name {
  font-weight: 500;
  font-size: 0.9rem;
  font-family: var(--font-display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icp-item-meta {
  font-size: 0.75rem;
  color: var(--fg-dim);
  margin-top: 2px;
}

/* ===== MAIN ===== */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: 1rem;
}

.empty-icon { font-size: 3rem; }
.empty-state h2 { font-family: var(--font-display); font-size: 1.5rem; }
.empty-state p { color: var(--fg-dim); max-width: 360px; }

.empty-hint {
  color: var(--fg-dim);
  font-size: 0.85rem;
  padding: 1rem 0;
}

/* ===== ICP VIEW ===== */
.icp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.icp-name {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.icp-meta {
  font-size: 0.85rem;
  color: var(--fg-dim);
}

.icp-actions { display: flex; gap: 0.5rem; }

/* ===== TABS ===== */
.app-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.6rem 1.25rem;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-dim);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

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

.tab-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin-left: auto;
}

.select-all-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--fg-dim);
  cursor: pointer;
}

/* ===== PROSPECT CARDS ===== */
.prospects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.prospect-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
}

.prospect-card:hover { border-color: rgba(108,92,231,0.3); transform: translateY(-1px); }
.prospect-card.selected { border-color: var(--accent); background: rgba(108,92,231,0.08); }
.prospect-card.has-email { border-color: rgba(0,210,160,0.3); }

.prospect-check {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.prospect-company {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.15rem;
  padding-right: 1.5rem;
}

.prospect-domain {
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.prospect-contact {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin-bottom: 0.5rem;
}

.prospect-contact strong { color: var(--fg); }

.prospect-desc {
  font-size: 0.8rem;
  color: var(--fg-dim);
  line-height: 1.5;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prospect-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 100px;
  background: rgba(108,92,231,0.12);
  color: var(--accent);
  border: 1px solid rgba(108,92,231,0.2);
}

.tag.success { background: rgba(0,210,160,0.1); color: var(--success); border-color: rgba(0,210,160,0.2); }

.prospect-footer {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prospect-gen-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  background: rgba(108,92,231,0.15);
  border: 1px solid rgba(108,92,231,0.25);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s;
}

.prospect-gen-btn:hover { background: rgba(108,92,231,0.25); }

.view-email-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  background: rgba(0,210,160,0.1);
  border: 1px solid rgba(0,210,160,0.2);
  color: var(--success);
  cursor: pointer;
  transition: background 0.15s;
}

.view-email-btn:hover { background: rgba(0,210,160,0.2); }

/* ===== EMAIL LIST ===== */
.emails-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.email-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.email-card:hover { border-color: rgba(108,92,231,0.3); }
.email-card.sent { border-color: rgba(0,210,160,0.25); opacity: 0.75; }

.email-card-left { flex: 1; min-width: 0; }

.email-card-company {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.email-card-contact {
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin-bottom: 0.4rem;
}

.email-card-subject {
  font-size: 0.85rem;
  color: var(--fg);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-card-preview {
  font-size: 0.8rem;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.draft { background: rgba(255,255,255,0.06); color: var(--fg-dim); }
.status-badge.sent { background: rgba(0,210,160,0.1); color: var(--success); }

/* ===== BUTTONS ===== */
.btn-primary {
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.btn-danger {
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  background: rgba(255,71,87,0.1);
  border: 1px solid rgba(255,71,87,0.2);
  color: var(--red);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover { background: rgba(255,71,87,0.2); }

.btn-icon-left { font-size: 0.9rem; }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 540px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.modal-lg { width: 680px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin-top: 2px;
}

.modal-close {
  font-size: 1.3rem;
  background: none;
  border: none;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.modal-close:hover { color: var(--fg); }

.modal-body { padding: 1.5rem; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.email-modal-left { margin-right: auto; }
.email-modal-right { display: flex; gap: 0.5rem; }

/* ===== FORM FIELDS ===== */
.field { margin-bottom: 1.25rem; }

.field label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-dim);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.req { color: var(--red); }

.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(108,92,231,0.5);
}

.field select option { background: var(--bg-card); }

.field-hint {
  font-size: 0.75rem;
  color: var(--fg-dim);
  margin-top: 0.3rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.email-subject-input { font-weight: 600; }

.email-body-input {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  resize: vertical;
}

/* ===== EMAIL TABS (inside modal) ===== */
.email-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.email-tab {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-family: var(--font-display);
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-dim);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

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

.email-status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  text-transform: uppercase;
}

/* ===== LOADING STATES ===== */
.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.4rem;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.05) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  color: var(--fg);
  z-index: 200;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: 320px;
}

.toast.visible { opacity: 1; transform: translateY(0); }
.toast.success { border-color: rgba(0,210,160,0.4); color: var(--success); }
.toast.error { border-color: rgba(255,71,87,0.4); color: var(--red); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-sidebar { width: 200px; min-width: 200px; }
  .app-main { padding: 1rem; }
  .field-row { grid-template-columns: 1fr; }
  .prospects-grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .app-layout { flex-direction: column; }
  .app-sidebar { width: 100%; min-width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .icp-list { max-height: 150px; }
}
