/* Abide Within — Portal Styles */
/* Design tokens from landing page: sage #7A8B6F, cream #F5F0E8, earth #5C4A3A, gold #C4A265 */

:root {
  --sage: #7A8B6F;
  --sage-light: #A3B495;
  --sage-bg: #f4f7f2;
  --cream: #F5F0E8;
  --warm-white: #FDFBF7;
  --earth: #5C4A3A;
  --earth-light: #8B7355;
  --gold: #C4A265;
  --deep-green: #3D4F35;
  --mist: #E8E2D6;
  --border: #ddd4c5;
  --shadow: rgba(92, 74, 58, 0.1);
  --radius: 8px;
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--earth);
  background: var(--cream);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== PORTAL LAYOUT ===== */
.portal-header {
  background: var(--warm-white);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.portal-logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--deep-green);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-logo span { color: var(--sage); }

.portal-nav {
  display: flex;
  gap: 0.25rem;
}

.portal-nav a {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  color: var(--earth-light);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.portal-nav a:hover, .portal-nav a.active {
  background: var(--sage-bg);
  color: var(--deep-green);
}

.portal-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--deep-green);
}

.page-header p {
  color: var(--earth-light);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--sage);
  color: #fff;
}

.btn-secondary {
  background: var(--warm-white);
  color: var(--earth);
  border: 1px solid var(--border);
}

.btn-danger {
  background: #e25c4a;
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.search-bar input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--warm-white);
  color: var(--earth);
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: var(--sage);
}

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

.client-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.client-card:hover {
  box-shadow: 0 4px 16px var(--shadow);
  transform: translateY(-1px);
}

.client-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.client-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--deep-green);
}

.client-badge {
  font-size: 0.72rem;
  background: var(--sage-bg);
  color: var(--sage);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 500;
}

.client-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--earth-light);
}

.client-meta strong { color: var(--earth); }

.client-goals {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--mist);
  font-size: 0.85rem;
  color: var(--earth-light);
  line-height: 1.5;
}

/* ===== TABLES ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--warm-white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table th {
  background: var(--mist);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--earth-light);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--mist);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--sage-bg); }

.type-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: capitalize;
}

.type-nutrition { background: #e8f4e8; color: #3a7a3a; }
.type-sound_therapy { background: #f3e8f5; color: #7a3a7a; }

.session-notes {
  max-width: 300px;
  font-size: 0.85rem;
  color: var(--earth-light);
}

/* ===== FORMS ===== */
.form-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 640px;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--earth);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--earth);
  background: var(--warm-white);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--sage);
}

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

.form-hint {
  font-size: 0.78rem;
  color: var(--earth-light);
  margin-top: 0.3rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--mist);
}

/* ===== CLIENT DETAIL ===== */
.client-detail-header {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.client-detail-header h1 { font-size: 1.5rem; font-weight: 600; color: var(--deep-green); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.detail-field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--earth-light);
  font-weight: 600;
}

.detail-field p {
  font-size: 0.9rem;
  color: var(--earth);
  margin-top: 0.2rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--deep-green);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--earth-light);
}

.empty-state svg { margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; color: var(--earth); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; }

/* ===== TOAST / ALERTS ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  z-index: 1000;
  animation: slideIn 0.3s ease;
}

.toast-success { background: var(--sage); }
.toast-error { background: #e25c4a; }

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

/* ===== UTILITIES ===== */
.text-muted { color: var(--earth-light); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.actions { display: flex; gap: 0.5rem; align-items: center; }

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

.filter-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.88rem;
  background: var(--warm-white);
  color: var(--earth);
  outline: none;
}

.filter-bar input[type="text"]:focus { border-color: var(--sage); }
.filter-bar input[type="date"] { padding: 0.55rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius); font-family: inherit; font-size: 0.88rem; background: var(--warm-white); color: var(--earth); outline: none; min-width: 140px; }
.filter-bar select { padding: 0.55rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius); font-family: inherit; font-size: 0.88rem; background: var(--warm-white); color: var(--earth); outline: none; cursor: pointer; }

/* ===== LEADS TABLE ===== */
.leads-table-wrap { overflow-x: auto; }

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: capitalize;
}

.status-new { background: #e8f4f8; color: #2a6a8a; }
.status-contacted { background: #fff3cd; color: #8a6a2a; }
.status-qualified { background: #e8f4e8; color: #3a7a3a; }
.status-converted { background: var(--sage-bg); color: var(--sage); }
.status-lost { background: #fde8e8; color: #8a2a2a; }

.type-badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.78rem; font-weight: 500; }
.source-discovery_session { background: #e8f4f8; color: #2a6a8a; }
.source-referral { background: #f3e8f5; color: #7a3a7a; }
.source-lead_magnet { background: #f3f5e8; color: #6a7a2a; }

.lead-meta-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; flex-wrap: wrap; }
.lead-actions { display: flex; gap: 0.5rem; align-items: center; }
.converted-label { font-size: 0.88rem; color: var(--sage); font-weight: 500; }

.back-link { font-size: 0.85rem; color: var(--earth-light); text-decoration: none; display: block; margin-bottom: 0.5rem; }
.back-link:hover { color: var(--earth); }

.lead-detail-section { background: var(--warm-white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; max-width: 680px; }

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

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal {
  background: var(--warm-white);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal h2 { font-size: 1.2rem; font-weight: 600; color: var(--deep-green); margin-bottom: 0.75rem; }
.modal p { font-size: 0.9rem; color: var(--earth-light); margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }