/* ===========================================================
   Taxina Notify — Clean Light Theme
   =========================================================== */

:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-soft: #f3f4f6;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-soft: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code {
  background: var(--border-soft);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: #4b5563;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

.sidebar {
  width: 248px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 32px;
  padding: 0 8px;
}

.sidebar .brand .logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--accent);
}

.sidebar nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  transition: background .12s, color .12s;
}

.sidebar nav a:hover { background: var(--border-soft); color: var(--text); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-user {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0 4px;
}

.content {
  margin-left: 248px;
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
}

.content-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px;
}

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 36px 0 16px;
}

.muted { color: var(--text-secondary); font-size: 14px; }
.lead { color: var(--text-secondary); font-size: 15px; margin-top: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h1 { font-size: 18px; margin: 0 0 12px; }
.card p { margin: 0 0 12px; }
.card ul { margin: 0; padding-left: 20px; color: var(--text-secondary); }
.card ul li { margin-bottom: 6px; }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card .value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  margin-top: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.btn:hover { background: var(--accent-hover); }

.btn.secondary { background: var(--border-soft); color: #374151; }
.btn.secondary:hover { background: var(--border); }

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

.btn.small { padding: 7px 12px; font-size: 13px; }

/* ---------- Forms ---------- */
label {
  font-size: 13px;
  color: #374151;
  font-weight: 500;
  display: block;
  margin: 18px 0 6px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

textarea { resize: vertical; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

/* ---------- Channel options ---------- */
.channel-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.channel-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  cursor: pointer;
}

.channel-option input[type="checkbox"],
.channel-option input[type="radio"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}

.table th {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
  color: #374151;
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fcfcfd; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.sent { background: #dcfce7; color: #166534; }
.badge.failed { background: var(--danger-soft); color: #991b1b; }
.badge.skipped { background: #fef3c7; color: #92400e; }
.badge.pending { background: var(--border-soft); color: #374151; }

/* ---------- Toolbar & filters ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters select, .filters input { width: auto; min-width: 170px; }

/* ---------- Condition rows ---------- */
.condition-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.condition-row select,
.condition-row input { flex: 1; }

.remove-btn {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.remove-btn:hover { background: var(--danger-hover); }

/* ---------- Dashboard: stat grid (5-up) ---------- */
.stat-grid {
  grid-template-columns: repeat(5, 1fr);
}

/* ---------- Dashboard: channel health chips ---------- */
.channel-health {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.ch-channel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  flex: 1 1 220px;
  min-width: 220px;
}
.ch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.ch-dot.ch-ok { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }
.ch-dot.ch-bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }
.ch-dot.ch-unknown { background: #d1d5db; }
.ch-name { font-weight: 600; font-size: 14px; color: var(--text); }
.ch-meta { font-size: 12px; color: var(--text-secondary); }

/* ---------- Dashboard: attention split ---------- */
.attention-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.attention-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 10px;
}
.attention-list { font-size: 13px; }

/* ---------- Channel pills (in tables) ---------- */
.ch-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.ch-pill-fcm { background: #e0e7ff; color: #3730a3; }
.ch-pill-whatsapp { background: #dcfce7; color: #166534; }
.ch-pill-sms { background: #fef3c7; color: #92400e; }

/* ---------- Table compact variant ---------- */
.table.compact th,
.table.compact td {
  padding: 8px 10px;
  font-size: 13px;
}

/* ---------- Message preview cell ---------- */
.msg-preview {
  color: var(--text-secondary);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Time-range pills ---------- */
.time-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s, color .12s, border-color .12s;
}
.pill:hover { background: var(--border-soft); color: var(--text); }
.pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color .12s, border-color .12s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- Collapsible provider_response ---------- */
.resp-details {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
}
.resp-details summary {
  padding: 2px 0;
  outline: none;
}
.resp-details summary:hover { color: var(--text); }
.resp-pre {
  background: var(--border-soft);
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  max-width: 600px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 0;
}

/* ---------- Drawer (right-side panel) ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  z-index: 50;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 560px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(17, 24, 39, 0.08);
  z-index: 51;
  display: flex;
  flex-direction: column;
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 16px; margin: 0; }
.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.drawer-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 18px;
}
.drawer-h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  margin: 18px 0 6px;
}

/* ---------- Form with live preview (right column) ---------- */
.form-with-preview {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}
.form-main { min-width: 0; }
.form-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: sticky;
  top: 24px;
}
.preview-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  margin: 0 0 4px;
}
.preview-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.5;
  min-height: 80px;
}
.preview-title-rendered {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.preview-body { color: var(--text); white-space: pre-wrap; }
.missing-var {
  background: #fee2e2;
  color: #991b1b;
  padding: 1px 4px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* ---------- Required field indicator ---------- */
.required-star { color: var(--danger); margin-left: 2px; }

/* ---------- Modal backdrop ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(16, 24, 40, 0.12);
}
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.modal .form-actions { margin-top: 20px; }

/* ---------- Inline switch (active toggle) ---------- */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #d1d5db;
  border-radius: 999px;
  transition: background .15s;
}
.slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  top: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform .15s;
}
.switch input:checked + .slider { background-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 16px;
}
.empty-state p {
  margin: 0 0 16px;
  font-size: 14px;
}

/* ---------- Body preview (template list) ---------- */
.body-preview {
  max-width: 360px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.5em;
  overflow: hidden;
}

/* ---------- Usage pill (template "Used by") ---------- */
.usage-pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
  cursor: default;
}
.usage-pill.usage-inactive {
  background: var(--border-soft);
  color: var(--text-secondary);
  text-decoration: line-through;
}

/* ---------- Toast notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.15);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-success { background: #16a34a; }
.toast.toast-error { background: var(--danger); }

/* ---------- Live indicator (sidebar) ---------- */
.live-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
  transition: background .15s, box-shadow .15s;
}
.live-dot.off {
  background: #d1d5db;
  box-shadow: none;
}
.live-label { font-weight: 500; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .content { margin-left: 0; }
  .content-inner { padding: 20px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .attention-split { grid-template-columns: 1fr; }
  .form-with-preview { grid-template-columns: 1fr; }
  .form-preview { position: static; }
}