/* 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; }
/* The tabs switch views with the "hidden" class. The grid rule above would otherwise win over it,
   leaving the template list on screen with the Media Library pushed below it. */
.wa-tpl-root .hidden { display: none !important; }
@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; }

/* Filters above the list in the Templates and Archived tabs */
.wa-tpl-list-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px 10px; border-bottom: 1px solid #e2e8f0; }
.wa-tpl-list-filters input[type="search"] { grid-column: 1 / -1; }
.wa-tpl-list-filters input, .wa-tpl-list-filters select {
  width: 100%; min-width: 0; box-sizing: border-box; padding: 6px 8px; font-size: 12.5px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: #0f172a; color-scheme: light;
}
.wa-tpl-list-filters select option { background: #fff; color: #0f172a; }
.wa-tpl-list-filters .wa-tpl-btn { justify-content: center; padding: 5px 8px; font-size: 12px; }
.wa-tpl-list-filters .wa-tpl-btn[disabled] { opacity: .45; cursor: not-allowed; }
.wa-tpl-row .wa-lib-card-groups { margin-top: 4px; }
body.dark .wa-tpl-list-filters { border-color: rgba(255,255,255,0.10); }
body.dark .wa-tpl-list-filters input, body.dark .wa-tpl-list-filters select { background: #0b1220; color: #f8fafc; border-color: #334155; color-scheme: dark; }
body.dark .wa-tpl-list-filters select option { background: #0f172a; color: #f8fafc; }

/* Template library tab (templates-library.js): cards in a grid, preview on the right */
.wa-lib { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .wa-lib { grid-template-columns: minmax(0, 1fr); } }
.wa-lib-main, .wa-lib-side { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; }
.wa-lib-side { padding: 14px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
@media (max-width: 1100px) { .wa-lib-side { position: static; max-height: none; } }
.wa-lib-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #e2e8f0; }
.wa-lib-filter { display: flex; flex-direction: column; gap: 3px; min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.wa-lib-filter.wa-lib-search { flex: 2 1 220px; max-width: 320px; }
.wa-lib-filter > span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; }
.wa-lib-filter input, .wa-lib-filter select, .wa-lib-group-form input {
  width: 100%; box-sizing: border-box; padding: 7px 9px; font-size: 13px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: #0f172a; color-scheme: light;
}
.wa-lib-filter select option { background: #fff; color: #0f172a; }
.wa-lib-clear[disabled] { opacity: .45; cursor: not-allowed; }
.wa-lib-count { margin-left: auto; font-size: 12px; color: #64748b; padding-bottom: 8px; white-space: nowrap; }
.wa-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; padding: 14px; }
.wa-lib-card {
  display: flex; flex-direction: column; gap: 8px; text-align: left; padding: 12px; min-height: 150px; cursor: pointer;
  background: #fff; color: #0f172a; border: 1px solid #e2e8f0; border-radius: 10px; font: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.wa-lib-card:hover { border-color: #93c5fd; box-shadow: 0 2px 8px rgba(37,99,235,.10); }
.wa-lib-card:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.wa-lib-card.is-selected { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.18); }
.wa-lib-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.wa-lib-card-name { font-size: 13.5px; font-weight: 700; overflow-wrap: anywhere; }
.wa-lib-card-body {
  flex: 1; font-size: 12.5px; line-height: 1.45; color: #475569; white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.wa-lib-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; color: #64748b; }
.wa-lib-card-groups, .wa-lib-group-list { display: flex; flex-wrap: wrap; gap: 4px; }
.wa-lib-group { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; font-size: 11px; font-weight: 600; border-radius: 999px; background: #ede9fe; color: #5b21b6; }
.wa-lib-group button { border: 0; background: transparent; color: inherit; font-size: 14px; line-height: 1; cursor: pointer; padding: 0; }
.wa-lib-group button[disabled] { opacity: .4; cursor: default; }
.wa-lib-badge { display: inline-block; flex-shrink: 0; padding: 1px 8px; font-size: 11px; font-weight: 600; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.wa-lib-badge.is-green { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.wa-lib-badge.is-blue { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.wa-lib-badge.is-red { background: #ffe4e6; color: #9f1239; border-color: #fecdd3; }
.wa-lib-badge.is-amber { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.wa-lib-badge.is-grey, .wa-lib-badge.is-plain { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.wa-lib-empty { grid-column: 1 / -1; padding: 28px 14px; text-align: center; font-size: 13px; color: #64748b; }
.wa-lib-empty.is-error { color: #b91c1c; }
.wa-lib-side-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: #0f172a; overflow-wrap: anywhere; }
.wa-lib-side-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 12px; }
.wa-lib-side-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; margin-bottom: 6px; }
.wa-lib-muted { font-size: 11.5px; color: #64748b; }
.wa-lib-reason { margin-bottom: 10px; padding: 8px 10px; font-size: 12px; border-radius: 8px; border: 1px solid #fecdd3; background: #fff1f2; color: #9f1239; }
.wa-lib-locales { margin-bottom: 8px; }
.wa-lib-groups { margin-top: 14px; padding-top: 12px; border-top: 1px solid #e2e8f0; }
.wa-lib-groups p { margin: 8px 0 0; }
.wa-lib-group-form { display: flex; gap: 6px; margin-top: 8px; }
.wa-lib-group-form input { flex: 1; min-width: 0; }
.wa-lib-side-actions { margin-top: 14px; display: flex; justify-content: flex-end; }
body.dark .wa-lib-main, body.dark .wa-lib-side { background: #0f172a; border-color: rgba(255,255,255,0.12); }
body.dark .wa-lib-toolbar, body.dark .wa-lib-groups { border-color: rgba(255,255,255,0.10); }
body.dark .wa-lib-filter > span, body.dark .wa-lib-count, body.dark .wa-lib-card-meta,
body.dark .wa-lib-side-label, body.dark .wa-lib-muted, body.dark .wa-lib-empty { color: #94a3b8; }
body.dark .wa-lib-filter input, body.dark .wa-lib-filter select, body.dark .wa-lib-group-form input {
  background: #0b1220; color: #f8fafc; border-color: #334155; color-scheme: dark;
}
body.dark .wa-lib-filter select option { background: #0f172a; color: #f8fafc; }
body.dark .wa-lib-card { background: rgba(255,255,255,0.03); color: #f8fafc; border-color: rgba(255,255,255,0.12); }
body.dark .wa-lib-card:hover { border-color: #60a5fa; box-shadow: none; }
body.dark .wa-lib-card.is-selected { border-color: #60a5fa; box-shadow: 0 0 0 2px rgba(96,165,250,.25); }
body.dark .wa-lib-card-body { color: #cbd5e1; }
body.dark .wa-lib-side-head h2 { color: #f8fafc; }
body.dark .wa-lib-group { background: rgba(139,92,246,.25); color: #ddd6fe; }
body.dark .wa-lib-badge.is-green { background: rgba(16,185,129,.2); color: #6ee7b7; border-color: rgba(16,185,129,.35); }
body.dark .wa-lib-badge.is-blue { background: rgba(14,165,233,.2); color: #7dd3fc; border-color: rgba(14,165,233,.35); }
body.dark .wa-lib-badge.is-red { background: rgba(244,63,94,.2); color: #fda4af; border-color: rgba(244,63,94,.35); }
body.dark .wa-lib-badge.is-amber { background: rgba(245,158,11,.2); color: #fcd34d; border-color: rgba(245,158,11,.35); }
body.dark .wa-lib-badge.is-grey, body.dark .wa-lib-badge.is-plain { background: rgba(255,255,255,.08); color: #cbd5e1; border-color: rgba(255,255,255,.12); }
body.dark .wa-lib-reason { background: rgba(244,63,94,.12); border-color: rgba(244,63,94,.35); color: #fda4af; }
body.dark .wa-lib-empty.is-error { color: #fca5a5; }

/* Message preview in the template detail: the template as WhatsApp will show it */
.wa-tpl-preview { white-space: normal; }
.wa-tpl-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.wa-tpl-preview-head .wa-tpl-preview-label { margin-bottom: 0; }
.wa-tpl-preview-locales { display: flex; flex-wrap: wrap; gap: 4px; }
.wa-tpl-preview-locales button { padding: 2px 8px; font-size: 11px; font-weight: 600; border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; color: #475569; cursor: pointer; }
.wa-tpl-preview-locales button.is-active { background: #2563eb; border-color: #2563eb; color: #fff; }
.wa-tpl-preview-note { margin: 8px 0 0; font-size: 11px; color: #64748b; }
.wa-tpl-chat { background: #e7ddd3; border-radius: 10px; padding: 14px 12px; display: flex; justify-content: flex-start; }
.wa-tpl-msg { width: 100%; max-width: 340px; background: #fff; color: #111b21; border-radius: 0 10px 10px 10px; box-shadow: 0 1px 1px rgba(11,20,26,.18); overflow: hidden; font-size: 14px; line-height: 1.45; }
.wa-tpl-msg-header { padding: 8px 10px 0; font-weight: 700; color: #111b21; overflow-wrap: anywhere; }
.wa-tpl-msg-media { background: #d1d7db; display: flex; align-items: center; justify-content: center; }
.wa-tpl-msg-media img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.wa-tpl-msg-media.is-placeholder { min-height: 96px; padding: 12px; color: #54656f; font-size: 13px; font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.wa-tpl-msg-body { padding: 8px 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-tpl-msg-footer { padding: 6px 10px 0; font-size: 12px; color: #667781; overflow-wrap: anywhere; }
.wa-tpl-msg-time { padding: 2px 10px 6px; font-size: 11px; color: #667781; text-align: right; }
.wa-tpl-msg-buttons { border-top: 1px solid #e9edef; }
.wa-tpl-msg-button { padding: 9px 10px; text-align: center; font-size: 13.5px; font-weight: 600; color: #027eb5; border-bottom: 1px solid #e9edef; overflow-wrap: anywhere; }
.wa-tpl-msg-button:last-child { border-bottom: 0; }
.wa-tpl-msg-empty { padding: 18px 12px; text-align: center; font-size: 13px; color: #64748b; }
.wa-tpl-var { background: #dcfce7; color: #166534; border-radius: 4px; padding: 0 3px; }
.wa-tpl-var.is-empty { background: #fef3c7; color: #92400e; }
body.dark .wa-tpl-preview-locales button { background: transparent; border-color: #475569; color: #cbd5e1; }
body.dark .wa-tpl-preview-locales button.is-active { background: #2563eb; border-color: #2563eb; color: #fff; }
body.dark .wa-tpl-preview-note,
body.dark .wa-tpl-msg-empty { color: #94a3b8; }
body.dark .wa-tpl-chat { background: #0b141a; }
body.dark .wa-tpl-msg { background: #202c33; color: #e9edef; box-shadow: none; }
body.dark .wa-tpl-msg-header { color: #e9edef; }
body.dark .wa-tpl-msg-media { background: #111b21; }
body.dark .wa-tpl-msg-media.is-placeholder,
body.dark .wa-tpl-msg-footer,
body.dark .wa-tpl-msg-time { color: #8696a0; }
body.dark .wa-tpl-msg-buttons,
body.dark .wa-tpl-msg-button { border-color: rgba(134,150,160,.2); }
body.dark .wa-tpl-msg-button { color: #53bdeb; }
body.dark .wa-tpl-var { background: rgba(34,197,94,.22); color: #86efac; }
body.dark .wa-tpl-var.is-empty { background: rgba(245,158,11,.22); color: #fcd34d; }

.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; }
