/* Arab Templates — Welcome Color-Mood Concierge
   Glass backdrop, four studied palettes, custom accent/background picker.
   Every palette sets text + surface colours together so contrast is kept. */

.atpm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 9, 18, .55);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  opacity: 0;
  transition: opacity .32s ease;
}
.atpm-backdrop.on { opacity: 1; }
html[data-at-theme="light"] .atpm-backdrop,
html[data-theme="light"] .atpm-backdrop { background: rgba(20, 28, 44, .38); }

.atpm-panel {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 20px;
  border: 1px solid rgba(197, 160, 89, .35);
  background: linear-gradient(165deg, #121C2F, #0A1220 72%);
  color: #EAF1FB;
  box-shadow: 0 40px 110px rgba(0, 0, 0, .55);
  font: 500 13px/1.7 system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}
html[data-at-theme="light"] .atpm-panel,
html[data-theme="light"] .atpm-panel {
  background: #FFFDF8;
  color: #1B2436;
  border-color: rgba(120, 92, 40, .3);
  box-shadow: 0 30px 80px rgba(15, 23, 42, .22);
}
.atpm-head { display: flex; align-items: flex-start; gap: 10px; padding: 18px 20px 0; }
.atpm-kicker { display: inline-flex; align-items: center; gap: 7px; font-size: 9px; font-weight: 900; letter-spacing: .14em; color: #C5A059; text-transform: uppercase; }
.atpm-head h2 { margin: 5px 0 3px; font-size: clamp(17px, 2.4vw, 23px); line-height: 1.3; letter-spacing: -.02em; }
.atpm-head p { margin: 0; color: #93A4BC; font-size: 11px; line-height: 1.8; }
html[data-at-theme="light"] .atpm-head p { color: #5C677E; }
.atpm-x { margin-inline-start: auto; border: 1px solid rgba(255, 255, 255, .14); background: transparent; color: inherit; width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 15px; }
.atpm-x:hover { border-color: #C5A059; color: #C5A059; }

.atpm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 15px 20px 0; }
.atpm-swatch {
  position: relative;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 13px;
  padding: 11px;
  cursor: pointer;
  background: rgba(255, 255, 255, .03);
  text-align: start;
  color: inherit;
  font: inherit;
  transition: border-color .16s, transform .16s;
}
html[data-at-theme="light"] .atpm-swatch { background: #fff; border-color: rgba(15, 23, 42, .12); }
.atpm-swatch:hover { transform: translateY(-1px); border-color: rgba(197, 160, 89, .6); }
.atpm-swatch.on { border-color: #C5A059; box-shadow: 0 0 0 3px rgba(197, 160, 89, .18); }
.atpm-preview { display: flex; height: 46px; border-radius: 9px; overflow: hidden; border: 1px solid rgba(148, 163, 184, .2); }
.atpm-preview i { flex: 1; }
.atpm-meta b { display: block; font-size: 11px; line-height: 1.4; }
.atpm-meta small { display: block; color: #8FA1BC; font-size: 9px; line-height: 1.6; }
html[data-at-theme="light"] .atpm-meta small { color: #5C677E; }
.atpm-check { position: absolute; inset-inline-end: 9px; top: 9px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #C5A059; color: #0F172A; font-size: 10px; font-weight: 900; opacity: 0; }
.atpm-swatch.on .atpm-check { opacity: 1; }

.atpm-custom { margin: 13px 20px 0; border: 1px dashed rgba(197, 160, 89, .35); border-radius: 13px; padding: 12px; }
.atpm-custom-head { display: flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 900; }
.atpm-custom-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.atpm-custom label { display: grid; gap: 4px; font-size: 9px; font-weight: 800; color: #93A4BC; }
html[data-at-theme="light"] .atpm-custom label { color: #5C677E; }
.atpm-custom input[type="color"] { width: 46px; height: 30px; padding: 2px; border-radius: 7px; border: 1px solid rgba(148, 163, 184, .3); background: transparent; cursor: pointer; }
.atpm-contrast { margin-inline-start: auto; font-size: 9px; font-weight: 900; border-radius: 99px; padding: 2px 8px; border: 1px solid rgba(52, 211, 153, .4); color: #6EE7B7; }
.atpm-contrast.bad { border-color: rgba(239, 68, 68, .45); color: #FCA5A5; }

.atpm-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 15px 20px 18px; }
.atpm-note { color: #8296AF; font-size: 9px; line-height: 1.7; flex: 1; min-width: 180px; }
html[data-at-theme="light"] .atpm-note { color: #67718A; }
.atpm-btn { border: 1px solid #C5A059; background: #C5A059; color: #0F172A; border-radius: 9px; padding: 9px 15px; font: 900 10.5px/1.4 inherit; cursor: pointer; }
.atpm-btn.ghost { background: transparent; color: #C5A059; }
.atpm-btn:hover { filter: brightness(1.06); }

/* floating palette button */
.atpm-fab {
  position: fixed;
  inset-inline-end: 16px;
  bottom: 110px;
  z-index: 9440;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(197, 160, 89, .45);
  background: rgba(15, 23, 42, .94);
  color: #F2D99B;
  border-radius: 99px;
  padding: 8px 11px;
  font: 900 9.5px/1.4 system-ui, Tahoma, sans-serif;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .3);
}
.atpm-fab:hover { background: #16243A; }

/* palette surfaces — driven by the CSS variables the concierge writes */
html[data-at-palette] body { background: var(--at-bg) !important; color: var(--at-text) !important; }
html[data-at-palette] .top,
html[data-at-palette] .topbar,
html[data-at-palette] header.top { background: color-mix(in srgb, var(--at-bg) 90%, transparent) !important; border-color: var(--at-line) !important; }
html[data-at-palette] .card,
html[data-at-palette] .panel,
html[data-at-palette] .command,
html[data-at-palette] .atx-card,
html[data-at-palette] .atx-tile,
html[data-at-palette] .bundle-card,
html[data-at-palette] .plan,
html[data-at-palette] .fact {
  background: var(--at-panel) !important;
  color: var(--at-text) !important;
  border-color: var(--at-line) !important;
}
html[data-at-palette] .atx-head p,
html[data-at-palette] .hero-sub-text,
html[data-at-palette] .fact span { color: var(--at-muted) !important; }
html[data-at-palette] .btn.gold,
html[data-at-palette] .atx-btn,
html[data-at-palette] .atpm-btn { background: var(--at-gold) !important; border-color: var(--at-gold) !important; color: var(--at-on-accent) !important; }
html[data-at-palette] .atx-kicker,
html[data-at-palette] .atx-tile-k,
html[data-at-palette] .atx-tile-cta,
html[data-at-palette] a { color: var(--at-gold-2) !important; }
html[data-at-palette] .atx-prompt-in { background: var(--at-panel) !important; }

/* light palettes must out-rank the shared light-mode bridge (same specificity, later file) */
html[data-at-palette][data-at-theme="light"] body,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) {
  background: var(--at-bg) !important;
  color: var(--at-text) !important;
}
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .top,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .topbar,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) header {
  background: color-mix(in srgb, var(--at-panel) 92%, transparent) !important;
  border-color: var(--at-line) !important;
}
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .panel,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .card,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .kpi,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .fact,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .mini>div,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .list li,
html[data-at-palette][data-at-theme="light"] body:not(.atp-page) .wa {
  background: var(--at-panel) !important;
  color: var(--at-text) !important;
  border-color: var(--at-line) !important;
}
html[data-at-palette] .card *,
html[data-at-palette] .atx-card *,
html[data-at-palette] .bundle-card * { border-color: var(--at-line); }

@media (max-width: 560px) {
  .atpm-grid { grid-template-columns: 1fr; }
  .atpm-panel { max-height: 94vh; }
  .atpm-fab { bottom: 118px; font-size: 9px; padding: 7px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .atpm-backdrop, .atpm-swatch { transition: none; }
}
