/* ============================================================
   SALONIQA — Client Retention Engine Styles
   ============================================================ */

/* ── Layout ──────────────────────────────── */
.retention-body {
  background: var(--bg-soft);
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  cursor: auto;                 /* override style.css `body{cursor:none}` — the custom cursor is landing-only */
  min-height: 100vh;
}
/* style.css ships a JS custom cursor + scroll-reveal (opacity:0) for the landing.
   This admin page has neither script, so neutralise them to avoid an invisible
   cursor / faded-and-unclickable content. */
.retention-body .custom-cursor { display: none !important; }
.retention-body .reveal,
.retention-body .reveal-left,
.retention-body .reveal-right { opacity: 1 !important; transform: none !important; }

.retention-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 64px;      /* extra bottom spacing so the last card clears the viewport */
}

/* ── Feedback ────────────────────────────── */
.ret-feedback {
  display: none;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}
.ret-feedback.show { display: block; }
.ret-feedback.success { background: #d4edda; color: var(--emerald-mid); border: 1px solid #c3e6cb; }
.ret-feedback.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.ret-feedback.info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Header ──────────────────────────────── */
.ret-header { margin-bottom: 24px; }
.ret-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px;
}
.ret-header p { color: #777; font-size: 14px; margin: 0; }

/* ── Metrics Grid ────────────────────────── */
.ret-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.ret-metric-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border-left: 3px solid #ddd;
}

.ret-metric-icon {
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

.metric-active .ret-metric-icon { background: #d4edda; color: var(--emerald-mid); }
.metric-active { border-left-color: var(--emerald-mid); }
.metric-atrisk .ret-metric-icon { background: #fff3cd; color: #856404; }
.metric-atrisk { border-left-color: #ffc107; }
.metric-lost .ret-metric-icon { background: #f8d7da; color: var(--danger); }
.metric-lost { border-left-color: var(--danger); }
.metric-recovered .ret-metric-icon { background: #d1ecf1; color: #0c5460; }
.metric-recovered { border-left-color: #17a2b8; }
.metric-retention .ret-metric-icon { background: #e8d5b7; color: var(--gold); }
.metric-retention { border-left-color: var(--gold); }
.metric-points .ret-metric-icon { background: #cce5ff; color: #004085; }
.metric-points { border-left-color: #007bff; }

.ret-metric-body { min-width: 0; }
.ret-metric-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}
.ret-metric-label {
  display: block;
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* ── Tabs ────────────────────────────────── */
.ret-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  overflow-x: auto;
}
.ret-tab {
  padding: 12px 20px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}
.ret-tab:hover { color: #555; }
.ret-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.ret-tab-content { display: none; }
.ret-tab-content.active { display: block; }

/* ── Cards ───────────────────────────────── */
.ret-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  margin-bottom: 16px;
  overflow: hidden;
}

.ret-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
  gap: 8px;
}

.ret-card-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.ret-card-body {
  padding: 16px 20px;
}

.ret-empty-small {
  text-align: center;
  padding: 32px 16px;
  color: #999;
  font-size: 14px;
}

/* ── Birthday rows ───────────────────────── */
.ret-birthday-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}
.ret-birthday-row:last-child { border-bottom: none; }
.ret-birthday-icon { font-size: 20px; }
.ret-meta { font-size: 12px; color: #999; }

/* ── Winback rows ────────────────────────── */
.ret-winback-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
  gap: 8px;
}
.ret-winback-row:last-child { border-bottom: none; }

/* ── Activity list ───────────────────────── */
.ret-activity-list { }
.ret-activity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
  gap: 8px;
}
.ret-activity-row:last-child { border-bottom: none; }

.pts-positive { color: var(--emerald-mid); font-weight: 600; }
.pts-negative { color: var(--danger); font-weight: 600; }

.ret-status-sent { color: var(--emerald-mid); }
.ret-status-failed { color: var(--danger); }
.ret-status-opened { color: #007bff; }
.ret-status-converted { color: var(--gold); }

/* ── Overview grid ───────────────────────── */
.ret-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 16px;
}
@media (max-width: 900px) {
  .ret-overview-grid { grid-template-columns: 1fr; }
}

/* ── Customer filters ────────────────────── */
.ret-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ret-filters .filter-group { flex: 1; min-width: 180px; }
.ret-filters .filter-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.ret-filters .filter-group input,
.ret-filters .filter-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  box-sizing: border-box;
}

/* ── Customer table ──────────────────────── */
.ret-table-wrapper { overflow-x: auto; }
.ret-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ret-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-soft);
  color: #555;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.ret-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.ret-table tr:hover td { background: #fdfcf9; }

.ret-cust-link {
  color: var(--gold);
  text-decoration: none;
  cursor: pointer;
}
.ret-cust-link:hover { text-decoration: underline; }

.ret-points-cell {
  font-weight: 600;
  color: var(--emerald-mid);
}

/* ── Customer cards (mobile) ─────────────── */
.ret-cust-cards { display: none; }
@media (max-width: 768px) {
  .ret-table-wrapper { display: none; }
  .ret-cust-cards { display: flex; flex-direction: column; gap: 12px; }
}
.ret-cust-card {
  background: #fff;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.ret-cust-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.ret-cust-card-body {
  font-size: 13px;
  color: #555;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.ret-cust-card-actions {
  display: flex;
  gap: 8px;
}

/* ── Loading ─────────────────────────────── */
.ret-loading {
  display: flex;
  justify-content: center;
  padding: 40px;
  gap: 6px;
}
.ret-loading span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  animation: retBounce 1.4s ease-in-out infinite both;
}
.ret-loading span:nth-child(1) { animation-delay: -0.32s; }
.ret-loading span:nth-child(2) { animation-delay: -0.16s; }
@keyframes retBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.ret-empty {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}
.ret-empty .icon { font-size: 48px; margin-bottom: 12px; }
.ret-empty h3 { font-family: 'Playfair Display', serif; color: #555; margin: 0 0 8px; }
.ret-empty p { font-size: 14px; margin: 0; }

/* ── Loyalty grid ────────────────────────── */
.ret-loyalty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 16px;
}
@media (max-width: 900px) {
  .ret-loyalty-grid { grid-template-columns: 1fr; }
}

.ret-loyalty-settings .form-group { margin-bottom: 12px; }
.ret-loyalty-settings label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.ret-loyalty-settings input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  box-sizing: border-box;
}
.ret-hint {
  display: block;
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

/* ── Leaderboard ─────────────────────────── */
.ret-leaderboard { }
.ret-leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
}
.ret-leaderboard-row:last-child { border-bottom: none; }
.ret-leaderboard-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  flex-shrink: 0;
}
.ret-leaderboard-row:first-child .ret-leaderboard-rank { background: var(--gold); color: #fff; }
.ret-leaderboard-row:nth-child(2) .ret-leaderboard-rank { background: #e8d5b7; color: #8b7a4e; }
.ret-leaderboard-row:nth-child(3) .ret-leaderboard-rank { background: #f0e6d3; color: #a0916a; }

/* ── Campaigns grid ──────────────────────── */
.ret-campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 16px;
}
@media (max-width: 900px) {
  .ret-campaigns-grid { grid-template-columns: 1fr; }
}

.ret-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}
.ret-toggle input { opacity: 0; width: 0; height: 0; }
.ret-toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}
.ret-toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  bottom: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.ret-toggle input:checked + .ret-toggle-slider { background: var(--emerald-mid); }
.ret-toggle input:checked + .ret-toggle-slider::before { transform: translateX(20px); }

.ret-template-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
}
.ret-template-input:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 2px rgba(201,169,110,0.15);
}

.ret-campaign-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 8px;
}
.ret-last-run {
  font-size: 12px;
  color: #5f6368;   /* darker for readable pending/status text */
  font-weight: 500;
}

/* ── Redeem preview ──────────────────────── */
.ret-redeem-preview {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 13px;
  color: #555;
  display: none;
}

/* ── Modal ───────────────────────────────── */
.ret-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.ret-modal-overlay.show { display: flex; }

.ret-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.ret-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f0f0f0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.ret-modal-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.ret-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #888;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.ret-modal-close:hover { color: #333; }

.ret-modal-body { padding: 20px 24px 24px; }

/* ── Profile modal ───────────────────────── */
.ret-profile-grid { }
.ret-profile-section {
  margin-bottom: 20px;
}
.ret-profile-section h4 {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f0f0f0;
}
.ret-profile-info {
  font-size: 14px;
  line-height: 1.8;
  color: #333;
}

.ret-profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.ret-profile-stat {
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}
.ret-ps-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}
.ret-ps-label {
  display: block;
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  margin-top: 2px;
}

.ret-profile-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ret-profile-table th {
  text-align: left;
  padding: 6px 8px;
  font-weight: 600;
  color: #555;
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.ret-profile-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f0f0f0;
}

.ret-profile-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ── Risk badge reuse ────────────────────── */
.risk-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.risk-badge.lost { background: #f8d7da; color: var(--danger); }
.risk-badge.high { background: #fff3cd; color: #856404; }
.risk-badge.warm { background: #e8d5b7; color: #8b7a4e; }
.risk-badge.recovered { background: #d1ecf1; color: #0c5460; }

/* ── Action buttons reuse ────────────────── */
.actions-cell { display: flex; gap: 4px; }
.btn-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}
.btn-icon-sm:hover { border-color: var(--gold); color: var(--gold); }
.btn-icon-sm.wa:hover { border-color: var(--wa); color: var(--wa); }

/* ── Form reuse ──────────────────────────── */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  box-sizing: border-box;
}
.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group { flex: 1; }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  font-family: 'Inter', sans-serif;
  line-height: 1.4;
  border: none;
}
.btn-primary {
  background: var(--gold);
  color: #fff;
}
.btn-primary:hover { background: var(--gold-dark); }
.btn-outline-dark {
  background: transparent;
  color: #555;
  border: 1px solid #ddd;
}
.btn-outline-dark:hover { border-color: var(--gold); color: var(--gold); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Loading dots ────────────────────────── */
.loading-dots {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 20px;
}
.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: retBounce 1.4s ease-in-out infinite both;
}
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

/* ── Responsive tweaks ───────────────────── */
@media (max-width: 768px) {
  .retention-container { padding: 16px; }
  .ret-header h1 { font-size: 22px; }
  .ret-metrics { grid-template-columns: repeat(2, 1fr); }
  .ret-tab { padding: 10px 14px; font-size: 13px; }
  .ret-card-header { flex-direction: column; align-items: flex-start; }
  .ret-card-body { padding: 12px 14px; }
  .form-row { flex-direction: column; gap: 0; }
  .ret-profile-stats { grid-template-columns: repeat(2, 1fr); }
  .ret-modal { max-width: 100%; margin: 10px; border-radius: 8px; }
}