/* EBMotivator Dashboard Styles */

:root {
  --primary: #5865F2;
  --danger: #ED4245;
  --success: #57F287;
  --warning: #FEE75C;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #2c2f33;
  --text-muted: #72767d;
  --border: #e3e5e8;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Navigation */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: #2c2f33;
  color: white;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: white;
}

.nav-logo {
  height: 32px;
  width: auto;
}

.nav-title {
  font-weight: bold;
  font-size: 1.25rem;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.nav-link {
  color: white;
  text-decoration: none;
  opacity: 0.8;
  font-size: 0.875rem;
}

.nav-link:hover {
  opacity: 1;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Metrics bar */
.metrics-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.metrics-group {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.metric {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.metric-value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary);
}

.metric-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.inline-form {
  display: inline;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.tab {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--card-bg);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.search-box {
  margin-left: auto;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
  min-width: 200px;
}

.search-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

/* Table wrapper */
.table-wrapper {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Member table */
.member-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
}

.member-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.member-table th a {
  text-decoration: none;
  color: inherit;
}

.member-table th a:hover {
  color: var(--text);
}

.member-row {
  cursor: pointer;
  transition: background 0.15s;
}

.member-row:hover {
  background: #f8f9fb;
}

.member-row td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.member-row.expanded {
  background: #f0f1f4;
}

.detail-row td {
  padding: 1.25rem;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
}

.badge-hot {
  background: #57F287;
  color: #1a1a1a;
}

.badge-warm {
  background: #FEE75C;
  color: #1a1a1a;
}

.badge-cold {
  background: #5865F2;
  color: white;
}

.badge-dormant {
  background: #ED4245;
  color: white;
}

.badge-active {
  background: #dcfce7;
  color: #166534;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef9c3;
  color: #854d0e;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-whatsapp {
  background: #dcfde7;
  color: #25d366;
  font-weight: 600;
}

.badge-muted {
  background: #e3e5e8;
  color: #72767d;
}

.badge-danger {
  background: #fecaca;
  color: #991b1b;
}

.badge-dry-run {
  background: #e0e7ff;
  color: #3730a3;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--primary);
  color: white;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.9;
}

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

.btn-warning {
  background: var(--warning);
  color: #1a1a1a;
}

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

.btn-secondary {
  background: #6b7280;
  color: white;
}

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

/* Detail panel */
.detail-panel {
  max-width: 100%;
}

.detail-title {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.detail-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .detail-sections {
    grid-template-columns: 1fr;
  }
}

.detail-section h4 {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.detail-table th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.detail-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.message-preview {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.detail-phone {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 0.5rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* Dry-run banner */
.dry-run-banner {
  background: #e0e7ff;
  color: #3730a3;
  text-align: center;
  padding: 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.page-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Nudge-log message cell */
.message-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

/* Login page */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.login-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.login-title {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-label {
  font-size: 0.875rem;
  font-weight: 500;
}

.login-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 1rem;
  outline: none;
}

.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

.login-button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.625rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.25rem;
}

.login-button:hover {
  opacity: 0.9;
}

/* Phone linking */
.phone-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.phone-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.phone-display {
  font-weight: 600;
  font-size: 0.9rem;
}

.phone-change {
  margin-top: 0.5rem;
}

.phone-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.phone-input {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  width: 260px;
}

.phone-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

/* Nudge message preview */
.nudge-preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nudge-preview-card {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
}

.nudge-preview-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.nudge-stage-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.nudge-preview-text {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.4;
}

/* Alert messages */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Nudge template editor */
.templates-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.template-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.template-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.template-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.template-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.template-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.template-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

.template-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  gap: 0.5rem;
}

.template-preview {
  flex: 1;
  min-width: 0;
}

.preview-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.preview-text {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: #f8f9fb;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.template-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
