/* ============================================================
   Kappino — Marketing Management UI
   Scoped styles for the Marketing workspace. Everything is
   prefixed `.mk-` (or nested under .view[data-view="marketing"])
   so it cannot collide with the rest of the app's styles.css.
   ============================================================ */

.view[data-view="marketing"] {
  --mk-accent: #10b981;
  --mk-accent-dark: #059669;
  --mk-accent-soft: #ecfdf5;
  --mk-violet: #7c3aed;
  --mk-violet-soft: #f5f3ff;
  --mk-ink: #0f172a;
  --mk-muted: #64748b;
  --mk-line: #e6e9ee;
  --mk-bg: #f7f8fa;
  --mk-card: #ffffff;
  --mk-radius: 14px;
  --mk-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
}

/* ---------- Tab bar ---------- */
.mk-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 5px;
  margin: 4px 0 20px;
  background: #eef1f4;
  border-radius: 12px;
}
.mk-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--mk-muted);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.mk-tab:hover { color: var(--mk-ink); }
.mk-tab.active {
  background: var(--mk-card);
  color: var(--mk-ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

/* ---------- Panel + layout ---------- */
.mk-panel { min-height: 320px; }
.mk-loading, .mk-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 64px 24px; color: var(--mk-muted); text-align: center;
}
.mk-empty-ico {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--mk-accent-soft); color: var(--mk-accent-dark); font-size: 22px;
}
.mk-empty-title { font-weight: 700; color: var(--mk-ink); font-size: 15px; }
.mk-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--mk-line); border-top-color: var(--mk-accent);
  animation: mk-spin .7s linear infinite;
}
@keyframes mk-spin { to { transform: rotate(360deg); } }

.mk-section { margin-bottom: 22px; }
.mk-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 2px 12px;
}
.mk-section-title { font-weight: 700; font-size: 15.5px; color: var(--mk-ink); }
.mk-section-sub { font-size: 12.5px; color: var(--mk-muted); margin-top: 1px; }

.mk-grid { display: grid; gap: 16px; }
.mk-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.mk-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.mk-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .mk-grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .mk-grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px)  { .mk-grid.cols-2, .mk-grid.cols-3, .mk-grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.mk-stat {
  background: var(--mk-card);
  border: 1px solid var(--mk-line);
  border-radius: var(--mk-radius);
  padding: 16px 18px;
}
.mk-stat-label { font-size: 12px; font-weight: 600; color: var(--mk-muted); letter-spacing: .01em; }
.mk-stat-value { font-size: 26px; font-weight: 800; color: var(--mk-ink); margin-top: 6px; line-height: 1.1; }
.mk-stat-foot { font-size: 12px; color: var(--mk-muted); margin-top: 4px; }
.mk-stat-foot.up { color: var(--mk-accent-dark); }
.mk-stat-foot.down { color: #dc2626; }

/* ---------- Cards ---------- */
.mk-card {
  background: var(--mk-card);
  border: 1px solid var(--mk-line);
  border-radius: var(--mk-radius);
  box-shadow: var(--mk-shadow);
  overflow: hidden;
}
.mk-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--mk-line);
}
.mk-card-title { font-weight: 700; font-size: 14.5px; color: var(--mk-ink); }
.mk-card-sub { font-size: 12px; color: var(--mk-muted); margin-top: 1px; }
.mk-card-body { padding: 16px 18px; }
.mk-card-body.flush { padding: 0; }

/* ---------- Buttons ---------- */
.mk-btn {
  appearance: none; font: inherit; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--mk-line); background: var(--mk-card); color: var(--mk-ink);
  transition: background .14s, border-color .14s, opacity .14s;
}
.mk-btn:hover { background: #f4f6f8; }
.mk-btn.primary { background: var(--mk-accent); border-color: var(--mk-accent); color: #fff; }
.mk-btn.primary:hover { background: var(--mk-accent-dark); }
.mk-btn.violet { background: var(--mk-violet); border-color: var(--mk-violet); color: #fff; }
.mk-btn.violet:hover { filter: brightness(.94); }
.mk-btn.danger { color: #dc2626; border-color: #f3c6c6; }
.mk-btn.danger:hover { background: #fef2f2; }
.mk-btn.sm { padding: 5px 10px; font-size: 12px; }
.mk-btn:disabled { opacity: .5; cursor: not-allowed; }
.mk-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Badges / pills ---------- */
.mk-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: #eef1f4; color: var(--mk-muted); white-space: nowrap;
}
.mk-badge.green  { background: #ecfdf5; color: #047857; }
.mk-badge.red    { background: #fef2f2; color: #b91c1c; }
.mk-badge.amber  { background: #fffbeb; color: #b45309; }
.mk-badge.blue   { background: #eff6ff; color: #1d4ed8; }
.mk-badge.violet { background: #f5f3ff; color: #6d28d9; }
.mk-badge.slate  { background: #f1f5f9; color: #475569; }
.mk-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Data table ---------- */
.mk-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mk-table th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--mk-muted);
  padding: 10px 14px; border-bottom: 1px solid var(--mk-line); background: #fafbfc;
}
.mk-table td { padding: 11px 14px; border-bottom: 1px solid #f1f3f5; color: var(--mk-ink); vertical-align: middle; }
.mk-table tr:last-child td { border-bottom: 0; }
.mk-table tr.clickable { cursor: pointer; }
.mk-table tr.clickable:hover td { background: #f7faf9; }
.mk-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.mk-table-empty { padding: 38px 14px; text-align: center; color: var(--mk-muted); }

/* ---------- List rows ---------- */
.mk-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid #f1f3f5;
}
.mk-row:last-child { border-bottom: 0; }
.mk-row-main { flex: 1; min-width: 0; }
.mk-row-title { font-weight: 600; font-size: 13.5px; color: var(--mk-ink); }
.mk-row-sub { font-size: 12px; color: var(--mk-muted); margin-top: 2px; }
.mk-row-sub.clamp, .mk-row-title.clamp {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.mk-avatar {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff; background: var(--mk-accent);
}
.mk-avatar.fb { background: #1877f2; }
.mk-avatar.ig { background: linear-gradient(45deg, #f09433, #dc2743, #bc1888); }
.mk-avatar.tt { background: #010101; }
.mk-avatar.gb { background: #4285f4; }

/* ---------- Forms ---------- */
.mk-field { margin-bottom: 14px; }
.mk-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--mk-ink); margin-bottom: 5px; }
.mk-hint { font-size: 11.5px; color: var(--mk-muted); margin-top: 4px; }
.mk-input, .mk-select, .mk-textarea {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--mk-ink);
  padding: 9px 11px; border: 1px solid var(--mk-line); border-radius: 9px;
  background: #fff; box-sizing: border-box;
}
.mk-input:focus, .mk-select:focus, .mk-textarea:focus {
  outline: none; border-color: var(--mk-accent); box-shadow: 0 0 0 3px var(--mk-accent-soft);
}
.mk-textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.mk-field-row { display: flex; gap: 12px; }
.mk-field-row > * { flex: 1; }

/* ---------- Toggle switch ---------- */
.mk-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.mk-switch input { opacity: 0; width: 0; height: 0; }
.mk-switch span {
  position: absolute; inset: 0; cursor: pointer; background: #cbd5e1;
  border-radius: 999px; transition: background .16s;
}
.mk-switch span::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .16s;
}
.mk-switch input:checked + span { background: var(--mk-accent); }
.mk-switch input:checked + span::before { transform: translateX(18px); }

/* ---------- Modal ---------- */
.mk-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  z-index: 1200; opacity: 0; transition: opacity .16s;
}
.mk-modal-backdrop.open { opacity: 1; }
.mk-modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 540px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
  transform: translateY(8px); transition: transform .16s;
}
.mk-modal.wide { max-width: 720px; }
.mk-modal-backdrop.open .mk-modal { transform: translateY(0); }
.mk-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--mk-line);
}
.mk-modal-title { font-weight: 700; font-size: 16px; color: var(--mk-ink); }
.mk-modal-sub { font-size: 12.5px; color: var(--mk-muted); margin-top: 2px; }
.mk-modal-x {
  appearance: none; border: 0; background: #f1f3f5; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; font-size: 17px; color: var(--mk-muted);
  flex-shrink: 0; line-height: 1;
}
.mk-modal-x:hover { background: #e6e9ee; color: var(--mk-ink); }
.mk-modal-body { padding: 18px 20px; overflow-y: auto; }
.mk-modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 20px; border-top: 1px solid var(--mk-line);
}

/* ---------- Toast ---------- */
.mk-toast-wrap {
  position: fixed; bottom: 22px; right: 22px; z-index: 1300;
  display: flex; flex-direction: column; gap: 9px;
}
.mk-toast {
  background: var(--mk-ink); color: #fff; font-size: 13px; font-weight: 500;
  padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 23, 42, .35);
  display: flex; align-items: center; gap: 9px; max-width: 360px;
  animation: mk-toast-in .2s ease;
}
@keyframes mk-toast-in { from { opacity: 0; transform: translateY(10px); } }
.mk-toast.success { background: #065f46; }
.mk-toast.error   { background: #991b1b; }
.mk-toast-ico { font-size: 15px; }

/* ---------- Misc ---------- */
.mk-meter { height: 7px; border-radius: 999px; background: #eef1f4; overflow: hidden; }
.mk-meter-fill { height: 100%; border-radius: 999px; background: var(--mk-accent); }
.mk-meter-fill.amber { background: #f59e0b; }
.mk-meter-fill.red { background: #ef4444; }
.mk-kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13px; }
.mk-kv + .mk-kv { border-top: 1px solid #f1f3f5; }
.mk-kv-k { color: var(--mk-muted); }
.mk-kv-v { font-weight: 600; color: var(--mk-ink); }
.mk-tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-inline-note {
  background: var(--mk-accent-soft); border: 1px solid #c7ebd9; color: #065f46;
  border-radius: 10px; padding: 10px 13px; font-size: 12.5px;
}
.mk-banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 10px; padding: 11px 14px; font-size: 12.5px; margin-bottom: 16px;
}
.mk-pre-wrap { white-space: pre-wrap; word-break: break-word; }
.mk-muted { color: var(--mk-muted); }
.mk-soon {
  text-align: center; padding: 56px 24px; color: var(--mk-muted);
}
.mk-soon-badge {
  display: inline-block; background: var(--mk-violet-soft); color: var(--mk-violet);
  font-weight: 700; font-size: 12px; padding: 4px 12px; border-radius: 999px; margin-bottom: 12px;
}
