/* ============================================================
   NativPost Email Marketing Tool — styles.css
   Design matches NativPost SEO tool (same dark sidebar, NativPost green accents)
   ============================================================ */

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

:root {
  --green: #16A34A;
  --green-dark: #15803d;
  --green-light: #f0fdf4;
  --sidebar-bg: #111827;
  --sidebar-text: #9ca3af;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #1f2937;
  --sidebar-section: #6b7280;
  --body-bg: #f4f5f8;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-sm: 13px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --danger: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
}

html, body { height: 100%; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--body-bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ── Layout ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 220px;
  background: var(--sidebar-bg); display: flex; flex-direction: column;
  overflow-y: auto; z-index: 100;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 20px 20px 16px; border-bottom: 1px solid #1f2937;
}
.brand-dot { width: 10px; height: 10px; background: var(--green); border-radius: 50%; flex-shrink: 0; }
.brand-name { color: #fff; font-weight: 700; font-size: 16px; }
.brand-tag { background: #16A34A22; color: var(--green); font-size: 10px; font-weight: 600;
             padding: 2px 6px; border-radius: 9999px; text-transform: uppercase; letter-spacing: 0.5px; }

.nav-list { list-style: none; padding: 12px 0; flex: 1; }
.nav-section { padding: 12px 20px 4px; font-size: 10px; font-weight: 600; text-transform: uppercase;
               letter-spacing: 1px; color: var(--sidebar-section); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; color: var(--sidebar-text); text-decoration: none;
  font-size: 13.5px; font-weight: 500; border-radius: 0; transition: all 0.15s;
}
.nav-item:hover { color: var(--sidebar-active); background: var(--sidebar-active-bg); }
.nav-item.active { color: var(--sidebar-active); background: var(--sidebar-active-bg);
                   border-left: 2px solid var(--green); }
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }
.nav-logout { margin-top: auto; color: #6b7280; }
.nav-logout:hover { color: var(--danger); }

.main { margin-left: 220px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 0 32px; height: 56px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-user { font-size: 13px; color: var(--text-muted); }
.content { padding: 24px 32px; flex: 1; max-width: 1400px; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert { padding: 10px 32px; font-size: 13px; font-weight: 500; }
.alert-success { background: #f0fdf4; color: #166534; border-bottom: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border-bottom: 1px solid #fecaca; }

/* ── Panels ─────────────────────────────────────────────── */
.panel {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 20px; box-shadow: var(--shadow);
}
.panel-narrow { max-width: 640px; }
.panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-header h2 { font-size: 14px; font-weight: 600; }
.panel-body { padding: 20px; }
.panel-body.p0 { padding: 0; }
.panel-link { font-size: 13px; color: var(--green); text-decoration: none; font-weight: 500; }
.panel-link:hover { text-decoration: underline; }
.panel-row { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.panel-lg, .panel-sm { margin-bottom: 0; }
.panel-footer-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 0 0; }
.panel-code .code-editor { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px;
  border: none; outline: none; width: 100%; min-height: 400px; resize: vertical;
  padding: 16px; background: #1e1e2e; color: #cdd6f4; border-radius: 0 0 var(--radius) var(--radius); }
.panel-preview {}
.preview-container { overflow: hidden; border-radius: 0 0 var(--radius) var(--radius); }

/* ── Stats ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
             padding: 20px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 28px; font-weight: 700; margin: 6px 0 2px; }
.stat-value-danger { color: var(--danger); }
.stat-sub { font-size: 12px; color: var(--text-muted); }
.stat-row { display: flex; justify-content: space-between; align-items: center;
            padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--text-muted); }

/* ── Tables ─────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600;
                 color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
                 border-bottom: 1px solid var(--border); background: #fafafa; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; font-size: 13px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.empty-row { text-align: center; color: var(--text-muted); padding: 40px !important; }
.text-sm { font-size: 12px; }
.muted { color: var(--text-muted); }
.truncate { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 9999px;
         font-size: 11px; font-weight: 600; text-transform: capitalize; }
.badge-draft { background: #f3f4f6; color: #374151; }
.badge-sending, .badge-active { background: #dbeafe; color: #1d4ed8; }
.badge-sent, .badge-completed, .badge-subscribed { background: #dcfce7; color: #166534; }
.badge-scheduled { background: #fef9c3; color: #854d0e; }
.badge-paused { background: #fef3c7; color: #92400e; }
.badge-cancelled, .badge-failed, .badge-bounced, .badge-complained { background: #fee2e2; color: #991b1b; }
.badge-unsubscribed { background: #f3f4f6; color: #6b7280; }

.badge-plan { border-radius: 4px; }
.badge-plan-trial { background: #ede9fe; color: #5b21b6; }
.badge-plan-starter { background: #e0f2fe; color: #0369a1; }
.badge-plan-growth { background: #dcfce7; color: #166534; }
.badge-plan-pro { background: #fef9c3; color: #854d0e; }
.badge-plan-agency { background: #fce7f3; color: #9d174d; }
.badge-plan-cancelled { background: #f3f4f6; color: #6b7280; }

.badge-plan-inactive { background: #f3f4f6; color: #6b7280; }
.badge-plan-past_due { background: #fef2f2; color: #991b1b; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
       border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--card-bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 6px; align-items: center; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 4px;
            font-size: 16px; font-weight: 700; }
.btn-danger-icon { color: var(--danger); }
.btn-danger-icon:hover { background: #fee2e2; }

/* ── Forms ─────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
         font-size: 13px; font-family: inherit; background: var(--card-bg); color: var(--text);
         transition: border-color 0.15s; outline: none; }
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,0.1); }
.input-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.field-hint { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.checkbox-label { display: flex; align-items: flex-start; gap: 8px; font-size: 13px;
                  cursor: pointer; padding: 4px 0; }
.checkbox-label input { margin-top: 2px; flex-shrink: 0; accent-color: var(--green); }
.form-two-col { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.form-main {  }
.form-sidebar { position: sticky; top: 76px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 16px; }
.code-block { background: #1e1e2e; color: #cdd6f4; padding: 16px; border-radius: var(--radius-sm);
              font-family: monospace; font-size: 12px; overflow-x: auto; white-space: pre; }
.code-editor { font-family: 'JetBrains Mono', monospace; font-size: 12px; width: 100%; resize: vertical;
               border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px;
               outline: none; background: #1e1e2e; color: #cdd6f4; min-height: 200px; }

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toolbar-desc { font-size: 13px; color: var(--text-muted); }
.stats-inline { display: flex; gap: 8px; }
.stat-pill { padding: 3px 10px; border-radius: 9999px; font-size: 12px; font-weight: 500;
             background: #f3f4f6; color: var(--text-muted); }
.stat-pill-green { background: var(--green-light); color: var(--green); }
.stat-pill-red { background: #fee2e2; color: var(--danger); }
.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-input { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
                font-size: 13px; min-width: 200px; outline: none; }
.filter-input:focus { border-color: var(--green); }
.filter-select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }

/* ── Action buttons list ─────────────────────────────────── */
.action-btn { display: block; padding: 10px 14px; background: #f9fafb; border: 1px solid var(--border);
              border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; text-decoration: none;
              color: var(--text); margin-bottom: 8px; transition: all 0.15s; }
.action-btn:hover { background: var(--green-light); border-color: var(--green); color: var(--green); }
.action-btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.action-btn-primary:hover { background: var(--green-dark); color: #fff; }

/* ── Pagination ─────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; margin-top: 16px; justify-content: center; }
.pagination-info { font-size: 12px; color: var(--text-muted); }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px; text-decoration: none;
            font-size: 12px; color: var(--text); }
.page-btn.active { background: var(--green); color: #fff; border-color: var(--green); }
.page-btn:hover:not(.active) { background: #f3f4f6; }

/* ── Modal ─────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex;
         align-items: center; justify-content: center; z-index: 1000; }
.modal.hidden { display: none; }
.modal-box { background: var(--card-bg); border-radius: var(--radius); width: 480px; max-width: 95vw;
             box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center;
                padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px;
               color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; background: #f9fafb;
              padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.modal-hint code { background: #e5e7eb; padding: 0 4px; border-radius: 3px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Page header ─────────────────────────────────────────── */
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-header h1 { font-size: 20px; font-weight: 700; }
.back-link { color: var(--text-muted); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--text); }

/* ── Template grid ─────────────────────────────────────── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 20px; }
.template-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
                 overflow: hidden; box-shadow: var(--shadow); }
.template-card-thumb { height: 120px; background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
                       display: flex; align-items: center; justify-content: center; }
.template-category { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
                     color: var(--green); background: #fff; padding: 4px 10px; border-radius: 9999px; }
.template-card-body { padding: 12px 16px; }
.template-card-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.template-card-subject { }
.template-card-actions { padding: 10px 16px; border-top: 1px solid var(--border); display: flex;
                          align-items: center; gap: 8px; justify-content: flex-end; }
.template-editor-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.template-editor-left, .template-editor-right { }
.preview-toggle { display: flex; gap: 6px; }

/* ── Lifecycle cards ─────────────────────────────────────── */
.lifecycle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.lifecycle-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
                  padding: 16px 12px; text-align: center; }
.lifecycle-icon { font-size: 24px; margin-bottom: 6px; }
.lifecycle-label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.lifecycle-trigger { font-size: 11px; color: var(--text-muted); }
.lifecycle-trigger code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; }
.lifecycle-card-purple { border-color: #ede9fe; }
.lifecycle-card-amber { border-color: #fef3c7; }
.lifecycle-card-red { border-color: #fee2e2; }
.lifecycle-card-green { border-color: #dcfce7; }
.lifecycle-card-blue { border-color: #dbeafe; }
.lifecycle-card-teal { border-color: #ccfbf1; }

/* ── Sequence steps ─────────────────────────────────────── */
.sequence-step { display: flex; gap: 16px; padding: 14px 20px; border-bottom: 1px solid #f3f4f6; }
.sequence-step:last-child { border-bottom: none; }
.step-connector { width: 20px; display: flex; flex-direction: column; align-items: center; }
.step-line { width: 2px; height: 100%; background: var(--border); margin: 0 auto; }
.step-content { flex: 1; }
.step-header { display: flex; align-items: center; gap: 10px; }
.step-badge { padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.step-badge-email { background: #dbeafe; color: #1d4ed8; }
.step-badge-wait { background: #fef9c3; color: #854d0e; }
.step-badge-condition { background: #ede9fe; color: #5b21b6; }
.step-label { font-size: 13px; flex: 1; }
.step-delay { font-size: 12px; color: var(--text-muted); background: #f3f4f6; padding: 2px 8px; border-radius: 4px; }
.empty-steps { padding: 32px; text-align: center; color: var(--text-muted); }
.delay-row { display: flex; gap: 6px; }
.delay-input { width: 80px; }
.delay-unit { flex: 1; }

/* ── Analytics ─────────────────────────────────────────── */
.bar-cell { display: flex; align-items: center; gap: 8px; }
.mini-bar { height: 8px; background: var(--green); border-radius: 4px; min-width: 2px; max-width: 100px; }

/* ── Copy field ─────────────────────────────────────────── */
.copy-field { display: flex; align-items: flex-start; gap: 8px; background: #f9fafb;
              border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px;
              font-size: 13px; }
.copy-field button { flex-shrink: 0; background: var(--card-bg); border: 1px solid var(--border);
                     padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.code-tag { background: #f3f4f6; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-family: monospace; }

/* ── Login ─────────────────────────────────────────────── */
.login-body { background: var(--body-bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
              padding: 40px; width: 420px; max-width: 95vw; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.login-logo { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn-primary { margin-top: 8px; }

/* ── Links ─────────────────────────────────────────────── */
.link-primary { color: var(--green); text-decoration: none; font-weight: 500; }
.link-primary:hover { text-decoration: underline; }
.hidden { display: none !important; }
.text-center { text-align: center; }
