/* app.css — ApexPipeline app shell styles */
/* Inherits design tokens from theme.css: --bg, --accent, --fg, etc. */

/* === APP SHELL === */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* === SIDEBAR === */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo a {
  text-decoration: none;
  color: inherit;
}

.logo-mark {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--fg-dim);
  font-family: var(--font-body);
  font-weight: 400;
  margin-top: 0.15rem;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  padding: 0.75rem 0.75rem 0.3rem;
  margin-top: 0.5rem;
}

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

.nav-link:hover {
  background: var(--bg-card);
  color: var(--fg);
}

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.nav-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 100px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-tagline {
  font-size: 0.7rem;
  color: var(--fg-dim);
  line-height: 1.5;
}

/* === MAIN CONTENT === */
.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === TOP BAR === */
.topbar {
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
}

.topbar-subtitle {
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin-top: 0.1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  font-family: var(--font-body);
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0f;
}

.btn-primary:hover {
  background: #5ff095;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.35);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--fg-dim);
  background: var(--bg-elevated);
}

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

.btn-ghost:hover {
  color: var(--fg);
  border-color: var(--border);
}

.btn-danger {
  background: rgba(255, 100, 100, 0.1);
  color: #ff6464;
  border: 1px solid rgba(255, 100, 100, 0.2);
}

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

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
}

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

/* === VIEWS === */
.view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

.view.active {
  display: flex;
}

.view-body {
  padding: 2rem;
  flex: 1;
}

/* === STAT CARDS === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.stat-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  margin-bottom: 0.5rem;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-card-value.accent { color: var(--accent); }
.stat-card-value.cyan { color: var(--accent-secondary); }
.stat-card-value.gold { color: #fbbf24; }
.stat-card-value.blue { color: #818cf8; }

.stat-card-sub {
  font-size: 0.75rem;
  color: var(--fg-dim);
}

/* === DATA TABLE === */
.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.table-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.table-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
}

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

th {
  padding: 0.75rem 1.5rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

td {
  padding: 0.9rem 1.5rem;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(42, 42, 58, 0.5);
  vertical-align: middle;
}

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

tr:hover td {
  background: rgba(255,255,255,0.015);
}

.td-company {
  font-weight: 600;
  color: var(--fg);
}

.td-sub {
  font-size: 0.75rem;
  color: var(--fg-dim);
  margin-top: 0.1rem;
}

/* === STATUS BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-new { background: rgba(99, 102, 241, 0.12); color: #818cf8; border: 1px solid rgba(99,102,241,0.25); }
.badge-contacted { background: rgba(34,211,238,0.1); color: var(--accent-secondary); border: 1px solid rgba(34,211,238,0.25); }
.badge-responded { background: rgba(251,191,36,0.1); color: #fbbf24; border: 1px solid rgba(251,191,36,0.25); }
.badge-booked { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(74,222,128,0.3); }
.badge-draft { background: rgba(100,100,120,0.1); color: var(--fg-muted); border: 1px solid var(--border); }
.badge-sent { background: rgba(34,211,238,0.1); color: var(--accent-secondary); border: 1px solid rgba(34,211,238,0.25); }
.badge-opened { background: rgba(251,191,36,0.1); color: #fbbf24; border: 1px solid rgba(251,191,36,0.25); }
.badge-replied { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(74,222,128,0.3); }
.badge-scheduled { background: rgba(34,211,238,0.1); color: var(--accent-secondary); border: 1px solid rgba(34,211,238,0.25); }
.badge-completed { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(74,222,128,0.3); }
.badge-cancelled { background: rgba(255,100,100,0.1); color: #ff6464; border: 1px solid rgba(255,100,100,0.25); }

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-input, .filter-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
}

.filter-input:focus, .filter-select:focus {
  border-color: var(--accent);
}

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

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

/* === FORMS & MODALS === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-wide { max-width: 740px; }

.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--fg-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: color 0.15s;
}

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

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

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="datetime-local"],
input[type="number"],
select,
textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
}

input::placeholder, textarea::placeholder { color: var(--fg-dim); }

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* === EMAIL COMPOSER === */
.composer {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  align-items: flex-start;
}

.composer-sidebar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: sticky;
  top: 1rem;
}

.composer-sidebar h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.lead-picker {
  width: 100%;
  margin-bottom: 1rem;
}

.tone-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tone-chip {
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--fg-muted);
  transition: all 0.15s;
}

.tone-chip.active, .tone-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.composer-main {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.composer-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.email-subject-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-body);
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}

.email-subject-input:focus { border-color: var(--accent); }

.email-body-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  line-height: 1.7;
  outline: none;
  width: 100%;
  min-height: 280px;
  resize: vertical;
  transition: border-color 0.15s;
}

.email-body-input:focus { border-color: var(--accent); }

.ai-generating {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--accent-glow);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--accent);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(74,222,128,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* === OUTREACH LIST === */
.email-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.email-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.email-card:hover { border-color: var(--fg-dim); }

.email-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.email-card-to {
  font-weight: 600;
  font-size: 0.9rem;
}

.email-card-subject {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.email-card-preview {
  font-size: 0.8rem;
  color: var(--fg-dim);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* === CALENDAR === */
.calendar-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.calendar-month-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-dow {
  padding: 0.6rem;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
}

.calendar-day {
  min-height: 90px;
  padding: 0.5rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.calendar-day:nth-child(7n) { border-right: none; }

.calendar-day:hover { background: var(--bg-card); }

.calendar-day.today {
  background: rgba(74, 222, 128, 0.04);
}

.calendar-day.other-month { opacity: 0.35; }

.day-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 0.3rem;
}

.calendar-day.today .day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: #0a0a0f;
  border-radius: 50%;
  font-size: 0.72rem;
}

.cal-event {
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(74,222,128,0.2);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* === PIPELINE / KANBAN === */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  align-items: flex-start;
}

.pipeline-col {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.pipeline-col-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pipeline-col-count {
  font-size: 0.75rem;
  color: var(--fg-dim);
  background: var(--bg-card);
  padding: 0.1rem 0.5rem;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.pipeline-cards {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 120px;
}

.pipeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}

.pipeline-card:hover {
  border-color: var(--fg-dim);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.pipeline-card-name {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.pipeline-card-meta {
  font-size: 0.75rem;
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pipeline-card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

/* === EMPTY STATES === */
.empty-state {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--fg-dim);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 0.4rem;
}

.empty-sub {
  font-size: 0.85rem;
  max-width: 300px;
  margin: 0 auto;
  line-height: 1.6;
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  color: var(--fg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: slideUp 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  pointer-events: auto;
}

.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid #ff6464; }
.toast.info { border-left: 3px solid var(--accent-secondary); }

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

/* === LOADING === */
.loading-row td {
  padding: 2rem;
  text-align: center;
  color: var(--fg-dim);
}

/* === RESPONSIVE === */
@media (max-width: 1100px) {
  .pipeline-board { grid-template-columns: repeat(2, 1fr); }
  .composer { grid-template-columns: 1fr; }
  .composer-sidebar { position: static; }
}

@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .pipeline-board { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .view-body { padding: 1rem; }
}
