/* WhatsApp Template Manager – compact layout (Tailwind 2 safe) */
.wa-tpl-shell { max-width: 1600px; margin: 0 auto; padding: 0 16px; }
.wa-tpl-header { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.wa-tpl-header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.wa-tpl-kicker { margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #2563eb; font-weight: 700; }
.wa-tpl-title { margin: 2px 0 0; font-size: 20px; font-weight: 800; color: #0f172a; }
.wa-tpl-sub { margin: 4px 0 0; font-size: 13px; color: #475569; }
.wa-tpl-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wa-tpl-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px; border: 0;
  background: #2563eb; color: #fff !important; font-size: 13px; font-weight: 700;
  cursor: pointer; box-shadow: 0 1px 2px rgba(37,99,235,.35);
}
.wa-tpl-btn:hover { background: #1d4ed8; }
.wa-tpl-btn svg { width: 16px; height: 16px; }
.wa-tpl-tabs { display: flex; gap: 4px; padding: 0 16px; border-top: 1px solid #e2e8f0; }
.wa-tpl-tab { padding: 10px 14px; font-size: 13px; font-weight: 600; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #64748b; cursor: pointer; }
.wa-tpl-tab.is-active { color: #2563eb; border-bottom-color: #2563eb; }

.wa-tpl-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; }
@media (max-width: 1100px) { .wa-tpl-layout { grid-template-columns: 1fr; } }
.wa-tpl-panel { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.wa-tpl-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; }
.wa-tpl-panel-head h2 { margin: 0; font-size: 13px; font-weight: 700; color: #0f172a; }
.wa-tpl-count { font-size: 12px; color: #64748b; }

.wa-tpl-row {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border: 0; border-bottom: 1px solid #f1f5f9;
  background: #fff; cursor: pointer;
}
.wa-tpl-row:hover { background: #f8fafc; }
.wa-tpl-row.is-selected { background: #eff6ff; border-left: 4px solid #2563eb; padding-left: 8px; }
.wa-tpl-row-inner { display: block; min-width: 0; }
.wa-tpl-row-body { min-width: 0; }
.wa-tpl-row-name {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: #0f172a;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}
.wa-tpl-row-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.wa-tpl-row-meta { margin: 3px 0 0; font-size: 11px; color: #64748b; white-space: normal; word-break: break-word; }
.wa-tpl-status,
.wa-tpl-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  font-size: 9px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 0.01em;
  text-transform: capitalize;
  color: #64748b;
  background: #f8fafc;
}
.wa-tpl-status.is-active,
.wa-tpl-status.is-approved,
.wa-tpl-chip.is-ok { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.wa-tpl-status.is-ready { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.wa-tpl-status.is-submitted,
.wa-tpl-status.is-pending,
.wa-tpl-chip.is-wait { color: #0369a1; background: #f0f9ff; border-color: #bae6fd; }
.wa-tpl-status.is-rejected,
.wa-tpl-status.is-failed,
.wa-tpl-chip.is-bad { color: #be123c; background: #fff1f2; border-color: #fecdd3; }

.wa-tpl-sticky {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 0; margin-bottom: 8px;
  background: #fff; border-bottom: 1px solid #f1f5f9;
}
.wa-tpl-sticky h1 { margin: 0; font-size: 18px; font-weight: 800; color: #0f172a; }
.wa-tpl-sticky-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wa-tpl-btn-green { background: #059669; }
.wa-tpl-btn-green:hover { background: #047857; }
.wa-tpl-btn-red { background: #dc2626; }
.wa-tpl-btn-red:hover { background: #b91c1c; }
.wa-tpl-btn-outline { background: #fff; color: #334155 !important; border: 1px solid #cbd5e1; box-shadow: none; }
.wa-tpl-btn-outline:hover { border-color: #2563eb; color: #1d4ed8 !important; background: #eff6ff; }

.wa-tpl-card { border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; background: #fff; }
.wa-tpl-card-nav { display: flex; gap: 2px; padding: 0 8px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.wa-tpl-card-nav button { padding: 10px 12px; font-size: 13px; font-weight: 600; border: 0; background: transparent; color: #64748b; border-bottom: 2px solid transparent; cursor: pointer; }
.wa-tpl-card-nav button.is-active { color: #1d4ed8; border-bottom-color: #2563eb; }
.wa-tpl-card-body { padding: 14px; }
.wa-tpl-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .wa-tpl-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wa-tpl-stat { background: #f8fafc; border: 1px solid #f1f5f9; border-radius: 8px; padding: 8px 10px; }
.wa-tpl-stat span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; }
.wa-tpl-stat strong { display: block; margin-top: 2px; font-size: 13px; color: #1e293b; }
.wa-tpl-preview { margin-top: 12px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px 12px; font-size: 13px; color: #0f172a; background: #f8fafc; white-space: pre-wrap; line-height: 1.45; }
.wa-tpl-preview-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; margin-bottom: 6px; }
.wa-tpl-preview-text { color: inherit; font-size: 13px; line-height: 1.5; }

.wa-designer-modal { position: fixed; inset: 0; z-index: 80; background: rgba(15,23,42,.65); display: flex; }
.wa-designer-shell { display: flex; flex-direction: column; width: 100%; height: 100%; background: #fff; }
.wa-designer-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; background: linear-gradient(90deg, #2563eb, #4338ca); color: #fff; }
.wa-designer-topbar h2 { margin: 0; font-size: 15px; font-weight: 700; }
.wa-designer-topbar p { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #dbeafe; }
.wa-designer-close { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 6px; padding: 6px 12px; font-weight: 600; cursor: pointer; }
.wa-designer-body { flex: 1; min-height: 0; overflow: hidden; }

#whatsapp-template-designer.wa-designer-compact,
#meta-template-designer-container.wa-designer-compact {
  display: flex !important; height: 100% !important; min-height: 0 !important; background: #f8fafc !important;
}
.wa-designer-compact #template-list > div,
.wa-designer-compact #template-list .wa-designer-card {
  padding: 8px 10px !important; margin-bottom: 6px !important;
}
.wa-designer-compact #template-editor { min-width: 0; }
.wa-designer-compact .wa-designer-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
dialog.wa-app-dialog { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 16px; border: none; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: 2147483647; }
dialog.wa-app-dialog::backdrop { background: rgba(15,23,42,.55); }
.wa-app-dialog-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 20px 50px rgba(15,23,42,.25); overflow: hidden; }
.wa-app-dialog-card h3 { margin: 0; padding: 16px 20px; font-size: 16px; font-weight: 700; color: #0f172a; border-bottom: 1px solid #e2e8f0; }
.wa-app-dialog-body { padding: 16px 20px; }
.wa-app-dialog-body p { margin: 0 0 10px; font-size: 13px; color: #475569; }
.wa-app-dialog-body input { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; color: #0f172a; background: #fff; }
.wa-app-dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; background: #f8fafc; border-top: 1px solid #e2e8f0; }

body.dark .wa-tpl-header,
body.dark .wa-tpl-panel,
body.dark .wa-tpl-row,
body.dark .wa-tpl-card,
body.dark .wa-tpl-sticky,
body.dark .wa-designer-shell,
body.dark .wa-app-dialog-card {
  background: #0f172a;
  border-color: rgba(255,255,255,0.12);
  color: #e5e7eb;
}
body.dark .wa-tpl-title,
body.dark .wa-tpl-panel-head h2,
body.dark .wa-tpl-row-name,
body.dark .wa-tpl-sticky h1,
body.dark .wa-tpl-stat strong,
body.dark .wa-app-dialog-card h3 { color: #f8fafc; }
body.dark .wa-tpl-sub,
body.dark .wa-tpl-count,
body.dark .wa-tpl-row-meta,
body.dark .wa-tpl-tab,
body.dark .wa-tpl-card-nav button,
body.dark .wa-app-dialog-body p { color: #94a3b8; }
body.dark .wa-tpl-tabs,
body.dark .wa-tpl-panel-head,
body.dark .wa-tpl-row,
body.dark .wa-tpl-sticky,
body.dark .wa-tpl-card-nav,
body.dark .wa-app-dialog-card h3,
body.dark .wa-app-dialog-footer { border-color: rgba(255,255,255,0.10); }
body.dark .wa-tpl-row { background: transparent; }
body.dark .wa-tpl-row:hover { background: rgba(255,255,255,0.04); }
body.dark .wa-tpl-row.is-selected { background: rgba(37,99,235,0.18); }
body.dark .wa-tpl-preview {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: #64748b !important;
}
body.dark .wa-tpl-preview-label { color: #cbd5e1 !important; }
body.dark .wa-tpl-tabs,
body.dark .wa-tpl-card-nav,
body.dark .wa-tpl-stat,
body.dark .wa-app-dialog-footer { background: rgba(255,255,255,0.04); }
body.dark .wa-tpl-tab.is-active,
body.dark .wa-tpl-card-nav button.is-active { color: #93c5fd; border-bottom-color: #60a5fa; }
body.dark .wa-tpl-chip { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); color: #cbd5e1; }
body.dark .wa-tpl-btn-outline { background: transparent; color: #e5e7eb !important; border-color: rgba(255,255,255,0.18); }
body.dark .wa-tpl-btn-outline:hover { background: rgba(59,130,246,0.16); color: #93c5fd !important; }
body.dark .wa-designer-modal { background: rgba(2,6,23,.72); }
body.dark .wa-designer-body,
body.dark #whatsapp-template-designer.wa-designer-compact,
body.dark #meta-template-designer-container.wa-designer-compact,
body.dark #whatsapp-template-designer,
body.dark #template-editor {
  background: #0b1220 !important;
}
body.dark #template-editor .bg-white,
body.dark #whatsapp-template-designer .bg-white,
body.dark #meta-template-designer-container .bg-white {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.12) !important;
}
body.dark #template-editor .bg-gray-50,
body.dark #whatsapp-template-designer .bg-gray-50,
body.dark #whatsapp-template-designer .bg-slate-50 {
  background: #0b1220 !important;
}
body.dark #template-editor .text-gray-900,
body.dark #template-editor .text-slate-900,
body.dark #whatsapp-template-designer .text-gray-900,
body.dark #whatsapp-template-designer .text-slate-900 { color: #f8fafc !important; }
body.dark #template-editor .text-gray-700,
body.dark #template-editor .text-slate-700,
body.dark #whatsapp-template-designer .text-gray-500,
body.dark #whatsapp-template-designer .text-slate-500 { color: #94a3b8 !important; }
body.dark #template-editor input,
body.dark #template-editor textarea,
body.dark .wa-app-dialog-body input,
body.dark #whatsapp-template-designer input,
body.dark #whatsapp-template-designer textarea {
  background: #0a0f1e !important;
  color: #e5e7eb !important;
  border-color: #334155 !important;
}
#template-editor select,
#whatsapp-template-designer select,
#meta-template-designer-container select,
.wa-themed-select {
  color-scheme: light;
  background: #ffffff;
  color: #0f172a;
}
#template-editor select option,
#whatsapp-template-designer select option,
#meta-template-designer-container select option,
.wa-themed-select option {
  background-color: #ffffff;
  color: #0f172a;
}
body.dark #template-editor select,
body.dark #whatsapp-template-designer select,
body.dark #meta-template-designer-container select,
body.dark .wa-themed-select {
  background: #0f172a !important;
  color: #f8fafc !important;
  border-color: #334155 !important;
  color-scheme: dark;
}
body.dark #template-editor select option,
body.dark #whatsapp-template-designer select option,
body.dark #meta-template-designer-container select option,
body.dark .wa-themed-select option,
body.dark .wa-app-dialog select option {
  background-color: #0f172a !important;
  color: #f8fafc !important;
}
body.dark .wa-app-dialog-card { background: #0f172a; }
body.dark #template-editor .border-gray-200,
body.dark #template-editor .border-slate-200,
body.dark #whatsapp-template-designer .border-gray-200,
body.dark #whatsapp-template-designer .border-slate-200,
body.dark #meta-template-designer-container .border-slate-200 {
  border-color: rgba(255,255,255,0.12) !important;
}

.wa-media-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.wa-media-thumb img,
.wa-media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.wa-media-thumb-fallback,
.wa-media-thumb-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  color: #64748b;
  padding: 12px;
  text-align: center;
}
.wa-media-thumb svg {
  width: 40px;
  height: 40px;
}
.wa-media-thumb-file p {
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-media-play {
  position: absolute;
  inset: auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.wa-media-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  background: rgba(15, 23, 42, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.wa-media-preview-card {
  width: min(920px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}
.wa-media-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 18px;
  border-bottom: 1px solid #e2e8f0;
}
.wa-media-preview-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}
.wa-media-preview-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: #64748b;
}
.wa-media-preview-close {
  border: 0;
  background: #f1f5f9;
  color: #0f172a;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
.wa-media-preview-body {
  padding: 16px 18px 20px;
  display: flex;
  justify-content: center;
  background: #0f172a;
}
.wa-media-preview-body img,
.wa-media-preview-body video {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}
.wa-media-preview-body iframe {
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: #fff;
}
.wa-media-preview-body audio {
  width: 100%;
}
.wa-media-preview-empty {
  color: #e2e8f0;
  padding: 24px;
}
body.dark .wa-media-preview-card { background: #0f172a; }
body.dark .wa-media-preview-head { border-bottom-color: rgba(255,255,255,0.1); }
body.dark .wa-media-preview-head h3 { color: #f8fafc; }
