/* ===== RECALLA APP STYLES ===== */
/* Matches landing page design system */

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

:root {
  --warm: #F97316;
  --warm-light: #FFF7ED;
  --warm-dark: #C2410C;
  --warm-bg: rgba(249, 115, 22, 0.08);
  --dark: #0C0A09;
  --gray-900: #1C1917;
  --gray-800: #292524;
  --gray-700: #44403C;
  --gray-500: #78716C;
  --gray-400: #A8A29E;
  --gray-300: #D6D3D1;
  --gray-200: #E7E5E4;
  --gray-100: #F5F5F4;
  --white: #FAFAF9;
  --green: #22C55E;
  --green-bg: rgba(34, 197, 94, 0.1);
  --red: #EF4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --yellow: #EAB308;
  --yellow-bg: rgba(234, 179, 8, 0.1);
  --blue: #3B82F6;
  --blue-bg: rgba(59, 130, 246, 0.1);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px;
  background: var(--dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--warm);
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--gray-500);
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.9rem;
  color: var(--gray-400);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}

.nav-item.active {
  background: rgba(249, 115, 22, 0.12);
  color: var(--warm);
}

.nav-item .icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 100px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer a {
  font-size: 0.8rem;
  color: var(--gray-500);
  text-decoration: none;
}

.sidebar-footer a:hover {
  color: var(--warm);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: white;
  border-radius: 14px;
  padding: 20px 24px;
  border: 1px solid var(--gray-200);
}

.stat-card .stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.stat-card .stat-value.orange { color: var(--warm); }
.stat-card .stat-value.green { color: var(--green); }
.stat-card .stat-value.red { color: var(--red); }
.stat-card .stat-value.blue { color: var(--blue); }

.stat-card .stat-sub {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ===== CARD CONTAINER ===== */
.card {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}

.card-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
}

.card-body {
  padding: 20px 24px;
}

/* ===== TABLES ===== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tbody tr:hover {
  background: var(--gray-100);
}

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

/* ===== BADGES ===== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active {
  background: var(--green-bg);
  color: var(--green);
}

.badge-at-risk {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.badge-lost {
  background: var(--red-bg);
  color: var(--red);
}

.badge-sent {
  background: var(--green-bg);
  color: var(--green);
}

.badge-pending {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.badge-failed {
  background: var(--red-bg);
  color: var(--red);
}

/* ===== RETENTION SCORE BAR ===== */
.score-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-bar .bar {
  flex: 1;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  max-width: 80px;
  overflow: hidden;
}

.score-bar .bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.score-bar .score-num {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  min-width: 28px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--warm);
  color: white;
}

.btn-primary:hover {
  background: var(--warm-dark);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red);
  color: white;
}

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

.btn-group {
  display: flex;
  gap: 8px;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--gray-900);
  background: white;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--warm);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

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

/* ===== FILE UPLOAD ===== */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: 14px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--gray-100);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--warm);
  background: var(--warm-light);
}

.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.upload-zone h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-900);
}

.upload-zone p {
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.88rem;
  max-width: 400px;
  margin: 0 auto 16px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--gray-200);
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: white;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
  max-width: 380px;
}

.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--blue); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== EMAIL PREVIEW ===== */
.email-preview {
  background: var(--gray-100);
  border-radius: 10px;
  padding: 20px;
  border: 1px solid var(--gray-200);
}

.email-preview .ep-field {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.email-preview .ep-label {
  font-weight: 600;
  color: var(--gray-500);
  min-width: 60px;
}

.email-preview .ep-value {
  color: var(--gray-900);
}

.email-preview .ep-body {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-300);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--gray-700);
  white-space: pre-wrap;
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--warm);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===== AT-RISK LIST ===== */
.risk-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  gap: 16px;
}

.risk-card:last-child {
  border-bottom: none;
}

.risk-info {
  flex: 1;
  min-width: 0;
}

.risk-info .name {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.92rem;
}

.risk-info .meta {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.risk-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2378716C' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") 12px center no-repeat;
}

.filter-bar .search-input:focus {
  outline: none;
  border-color: var(--warm);
}

.filter-chips {
  display: flex;
  gap: 6px;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--gray-300);
  background: white;
  color: var(--gray-700);
  transition: all 0.15s ease;
}

.filter-chip:hover {
  border-color: var(--warm);
  color: var(--warm);
}

.filter-chip.active {
  background: var(--warm);
  color: white;
  border-color: var(--warm);
}

/* ===== MOBILE ===== */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  background: var(--dark);
  color: var(--warm);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1.2rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  .mobile-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
    padding-top: 56px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .search-input {
    min-width: 0;
  }
}

/* ===== PROGRESS ===== */
.progress-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.progress-ring .ring-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
}

.progress-ring .ring-label {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* ===== SAMPLE DATA BANNER ===== */
.sample-banner {
  background: linear-gradient(135deg, var(--warm-light) 0%, #FED7AA 100%);
  border: 1px solid #FDBA74;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sample-banner .sb-text {
  font-size: 0.88rem;
  color: var(--gray-900);
}

.sample-banner .sb-text strong {
  font-weight: 600;
}

/* ===== SETTINGS FORM ===== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}
