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

:root {
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --sidebar-active: #0f3460;
  --accent: #e94560;
  --accent-hover: #c73652;
  --text-primary: #1a1a2e;
  --text-muted: #6b7280;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── Sidebar ── */
#sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}

#sidebar .logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.logo-img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  margin-bottom: 4px;
  object-fit: contain;
}

#sidebar .logo h1 {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

#sidebar .logo p {
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  margin: 0;
}

#user-info {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

.logout-btn {
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.6);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 2px;
}
.logout-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

#sidebar nav {
  padding: 12px 0;
  flex: 1;
}

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

#sidebar nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

#sidebar nav a.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: var(--accent);
}

#sidebar nav a .icon { font-size: 16px; width: 20px; text-align: center; }

/* ── Main content ── */
#main {
  margin-left: 220px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#page-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#page-header h2 { font-size: 20px; font-weight: 600; }

#content-area {
  padding: 28px;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px;
  text-align: center;
}

.stat-card .stat-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-text     { background: #e0f2fe; color: #0369a1; }
.badge-image    { background: #fce7f3; color: #be185d; }
.badge-video    { background: #f3e8ff; color: #7e22ce; }
.badge-link     { background: #dbeafe; color: #1d4ed8; }
.badge-deeplink { background: #ede9fe; color: #5b21b6; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-sent     { background: #d1fae5; color: #065f46; }
.badge-failed   { background: #fee2e2; color: #991b1b; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}

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

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

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

.btn-secondary:hover { background: #e9eaf0; }

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

.btn-danger:hover { background: #dc2626; }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

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

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"], input[type="email"], input[type="date"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

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

/* ── Misc ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar h3 { font-size: 15px; font-weight: 600; }

.step-list { list-style: none; }

.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  background: #fff;
}

.step-item .step-day {
  background: var(--sidebar-bg);
  color: #fff;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.step-item .step-title { flex: 1; font-size: 13.5px; }

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #dbeafe; color: #1e40af; }

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a2e;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: none;
  z-index: 9999;
  max-width: 320px;
}

#toast.show { display: block; animation: slideIn 0.2s ease; }

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

.loading { color: var(--text-muted); font-style: italic; padding: 20px 0; }

@media (max-width: 640px) {
  #sidebar { width: 100%; min-height: auto; position: relative; }
  #main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Simulate Layout ── */
.simulate-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

.simulate-form { position: sticky; top: 20px; }

.simulate-preview {
  display: flex;
  justify-content: center;
}

/* ── Phone Frame ── */
.phone-frame {
  width: 100%;
  max-width: 360px;
  border-radius: 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 0 0 6px #1a1a2e;
  overflow: hidden;
  background: #f1f3f4;
  display: flex;
  flex-direction: column;
  min-height: 500px;
}

.phone-header {
  background: #1a73e8;
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
}

.phone-lock { font-size: 13px; opacity: 0.8; }

.phone-messages {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #e5e5ea;
}

/* ── Chat bubbles ── */
.sim-day-label {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #666;
  background: rgba(255,255,255,0.6);
  border-radius: 10px;
  padding: 2px 10px;
  margin: 8px auto 4px;
  width: fit-content;
}

.sim-bubble {
  background: #1a73e8;
  color: #fff;
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  max-width: 88%;
  align-self: flex-start;
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: 4px;
}

.sim-bubble-future {
  background: #b0bec5;
  color: #455a64;
  opacity: 0.75;
}

.sim-bubble-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  opacity: 0.9;
}

.sim-bubble-body { word-break: break-word; }

.sim-bubble-img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 4px;
  display: block;
}

.sim-bubble-video {
  max-width: 100%;
  width: 100%;
  border-radius: 8px;
  margin-top: 6px;
  display: block;
  background: #000;
  max-height: 260px;
}

/* ── Status badges ── */
.sim-status {
  font-size: 11px;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sim-status-delivered { color: #a5f3c0; }
.sim-bubble-future .sim-status-future { color: #607d8b; }
.sim-status-scheduled { color: #ffe082; }
.sim-bubble-future .sim-status-future { color: #607d8b; }

.sim-dot-orange {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fb923c;
  display: inline-block;
  flex-shrink: 0;
}

.sim-empty, .sim-error {
  text-align: center;
  color: #999;
  font-size: 13px;
  padding: 20px;
}

.sim-error { color: #c0392b; }

input[type="range"] {
  padding: 0;
  height: 6px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ── Content type selector tabs ── */
.type-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.type-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.type-tab:hover { border-color: var(--accent); color: var(--accent); }
.type-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Upload form helpers ── */
.radio-group {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  align-items: center;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  color: var(--text-primary);
}

.upload-status-text  { color: var(--text-muted); font-style: italic; font-size: 12px; }
.upload-status-success { color: var(--success); font-size: 12px; }
.upload-status-error   { color: var(--danger); font-size: 12px; }

.upload-preview-area { margin-top: 8px; }

.upload-preview-img {
  max-height: 120px;
  max-width: 100%;
  border-radius: 6px;
  display: block;
}

.upload-preview-video {
  max-height: 180px;
  max-width: 100%;
  border-radius: 6px;
  display: block;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ── Link / Deeplink bubbles in simulate view ── */
.sim-link-bubble {
  margin-top: 4px;
}

.sim-link-bubble a {
  color: rgba(255,255,255,0.9);
  text-decoration: underline;
  word-break: break-all;
}

.sim-bubble-future .sim-link-bubble a { color: #546e7a; }

.sim-deeplink-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 7px 16px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.sim-bubble-future .sim-deeplink-bubble {
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.15);
  color: #455a64;
}

@media (max-width: 900px) {
  .simulate-layout { grid-template-columns: 1fr; }
  .simulate-form { position: static; }
}

/* Journey Timeline */
.timeline-outer { overflow-x: auto; padding-bottom: 16px; }
.timeline { display: flex; gap: 16px; align-items: flex-start; min-height: 200px; padding: 8px 0; }
.timeline-col { flex-shrink: 0; width: 200px; background: #f8fafc; border-radius: 12px; padding: 10px; border: 2px dashed #e2e8f0; min-height: 120px; }
.timeline-col-header { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #64748b; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid #e2e8f0; letter-spacing: 0.05em; }
.timeline-card { background: white; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); cursor: grab; border-left: 3px solid #6366f1; transition: box-shadow 0.15s; user-select: none; }
.timeline-card:active { cursor: grabbing; }
.timeline-card.sortable-ghost { opacity: 0.4; }
.timeline-card.sortable-chosen { box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.timeline-card-icon { font-size: 16px; margin-right: 4px; }
.timeline-card-title { font-weight: 600; font-size: 13px; color: #1e293b; }
.timeline-card-meta { margin-top: 4px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.timeline-card-actions { margin-top: 8px; display: flex; gap: 6px; }
.timeline-card-edit-form { margin-top: 8px; padding-top: 8px; border-top: 1px solid #e2e8f0; }
.timeline-card-edit-form label { font-size: 11px; color: #64748b; display: block; margin-bottom: 2px; }
.timeline-card-edit-form input { width: 100%; padding: 4px 6px; font-size: 13px; border: 1px solid #cbd5e1; border-radius: 4px; margin-bottom: 6px; box-sizing: border-box; }
.timeline-col.sortable-over { border-color: #6366f1; background: #eef2ff; }
.timeline-card[data-type="text"]     { border-left-color: #6366f1; }
.timeline-card[data-type="image"]    { border-left-color: #10b981; }
.timeline-card[data-type="video"]    { border-left-color: #f59e0b; }
.timeline-card[data-type="link"]     { border-left-color: #3b82f6; }
.timeline-card[data-type="deeplink"] { border-left-color: #8b5cf6; }

/* User Inbox */
.inbox-thread { max-width: 420px; margin: 0 auto; padding: 16px 0; }
.inbox-divider { text-align: center; font-size: 11px; color: #94a3b8; margin: 16px 0 8px; position: relative; }
.inbox-divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: #e2e8f0; z-index: 0; }
.inbox-divider span { background: #f8fafc; padding: 0 8px; position: relative; z-index: 1; }

/* ── Timeline gap columns ── */
.timeline-col-gap {
  flex-shrink: 0;
  width: 140px;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 10px;
  border: 2px dashed #cbd5e1;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 11px;
  text-align: center;
  gap: 4px;
}
.timeline-col-gap .gap-icon { font-size: 18px; opacity: 0.5; }
.timeline-col-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  color: #cbd5e1;
  font-size: 11px;
}

/* ── Dashboard grid ── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }
.user-list-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.user-list-item:last-child { border-bottom: none; }
.user-list-name { font-weight: 600; color: #1e293b; }
.user-list-meta { font-size: 11px; color: #94a3b8; }
.journey-list-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.journey-list-item:last-child { border-bottom: none; }
.journey-list-name { font-weight: 600; flex: 1; }
.journey-list-meta { font-size: 11px; color: #94a3b8; }

/* ── Journey status badges ── */
.badge-active { background: #d1fae5; color: #065f46; }
.badge-paused { background: #e2e8f0; color: #475569; }

/* Multi-user checklist */
.user-checklist { max-height: 240px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 8px; padding: 4px; }
.user-checklist-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.user-checklist-item:hover { background: #f1f5f9; }
.user-checklist-item input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.user-checklist-item label { cursor: pointer; flex: 1; font-size: 13px; }
.user-checklist-item .user-email { font-size: 11px; color: #94a3b8; }
.checklist-controls { display: flex; gap: 12px; margin-bottom: 6px; font-size: 12px; }
.checklist-controls a { color: #6366f1; cursor: pointer; text-decoration: underline; }
.selected-count { font-size: 12px; color: #6366f1; font-weight: 600; margin-top: 4px; }

.nav-separator {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 12px;
}

/* ── Login page ── */
body.login-page {
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; color: #1a1a2e; margin: 0 0 4px; }
.login-logo p { color: #94a3b8; font-size: 13px; margin: 0; }

/* ── Journey accordion ── */
.journey-accordion-row td { padding: 0 !important; }
.journey-accordion-panel {
  padding: 12px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}
.journey-accordion-section { margin-bottom: 10px; }
.journey-accordion-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.enrolled-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}
.enrolled-user-row:last-child { border-bottom: none; }
.accordion-step-row {
  font-size: 12px;
  color: #475569;
  padding: 2px 0;
}
.accordion-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #64748b;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}
.accordion-toggle-btn:hover { background: #e2e8f0; }

/* Journey Accordion */
.journey-accordion {
  border-bottom: 1px solid var(--border);
}
.journey-accordion:last-child { border-bottom: none; }

.journey-accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
}
.journey-accordion-header:hover { background: #f8fafc; border-radius: 8px; }

.journey-chevron { font-size: 11px; color: #94a3b8; width: 14px; flex-shrink: 0; }
.journey-accordion-name { font-weight: 600; font-size: 14px; color: #1e293b; }
.journey-accordion-meta { font-size: 12px; color: #94a3b8; flex: 1; }
.journey-accordion-actions { display: flex; gap: 6px; margin-left: auto; }

.journey-accordion-body {
  padding: 4px 24px 16px;
  background: #f8fafc;
  border-radius: 0 0 8px 8px;
}

.accordion-section { margin-bottom: 12px; }
.accordion-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #64748b; letter-spacing: 0.05em; margin-bottom: 6px; }

.accordion-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.accordion-step { background: white; border: 1px solid #e2e8f0; border-radius: 6px; padding: 4px 10px; font-size: 12px; color: #475569; }

.accordion-user-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #e2e8f0; font-size: 13px; }
.accordion-user-row:last-child { border-bottom: none; }
