/* ==========================================================================
   LUMI Interactive Studio — Live Customizer + CRM + Dashboard + Mini-Site
   Isolated containment prevents internal mutations from reflowing the page.
   ========================================================================== */

.studio-shell {
  --studio-accent: #6d4aff;
  --studio-accent-2: #ec2f96;
  --studio-accent-3: #0b99e6;
  --studio-accent-soft: rgba(109, 74, 255, 0.1);
  --studio-bg: #ffffff;
  --studio-sidebar: #f7f9fd;
  --studio-card: #ffffff;
  --studio-surface: #f4f7fc;
  --studio-ink: #0b1222;
  --studio-ink-muted: #516078;
  --studio-border: #e2e8f3;

  container: studio / inline-size;
  contain: layout style paint;
  border-radius: var(--radius-xl);
  background: var(--studio-bg);
  border: 1px solid var(--studio-border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition:
    background-color var(--dur-base) ease,
    border-color var(--dur-base) ease;
}

/* Customizer Color Palettes */
.studio-shell[data-palette="lumi"] {
  --studio-accent: #6d4aff;
  --studio-accent-2: #ec2f96;
  --studio-accent-3: #0b99e6;
  --studio-accent-soft: rgba(109, 74, 255, 0.11);
}

.studio-shell[data-palette="rose"] {
  --studio-accent: #8f3a5c;
  --studio-accent-2: #e11d74;
  --studio-accent-3: #c08497;
  --studio-accent-soft: rgba(143, 58, 92, 0.11);
}

.studio-shell[data-palette="cobalt"] {
  --studio-accent: #1d4ed8;
  --studio-accent-2: #0284c7;
  --studio-accent-3: #38bdf8;
  --studio-accent-soft: rgba(29, 78, 216, 0.11);
}

.studio-shell[data-palette="emerald"] {
  --studio-accent: #0f766e;
  --studio-accent-2: #10b981;
  --studio-accent-3: #14b8a6;
  --studio-accent-soft: rgba(15, 118, 110, 0.12);
}

.studio-shell[data-palette="obsidian"] {
  --studio-accent: #1e293b;
  --studio-accent-2: #475569;
  --studio-accent-3: #0ea5e9;
  --studio-accent-soft: rgba(30, 41, 59, 0.1);
}

/* Simulated Dark Theme Inside Studio Preview */
.studio-shell[data-theme="dark"] {
  --studio-bg: #0f1626;
  --studio-sidebar: #131c31;
  --studio-card: #182239;
  --studio-surface: #1d2944;
  --studio-ink: #f1f5f9;
  --studio-ink-muted: #9eb0cd;
  --studio-border: #273554;
}

.studio-shell[data-theme="dark"][data-palette="obsidian"] {
  --studio-accent: #38bdf8;
  --studio-accent-soft: rgba(56, 189, 248, 0.16);
}

/* Customizer Control Deck (Always light & crisp above the live app frame) */
.customizer-deck {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  padding: 1.15rem 1.2rem;
  background: var(--surface-pearl);
  border-bottom: 1px solid var(--border-hairline);
}

.customizer-deck > * {
  min-width: 0;
}

@media (min-width: 1024px) {
  .customizer-deck {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) auto;
    align-items: end;
    padding: 1.25rem 1.4rem;
  }
}

.customizer-group {
  display: grid;
  gap: 0.45rem;
}

.customizer-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.niche-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.niche-pill {
  padding: 0.46rem 0.88rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur-fast) ease;
}

.niche-pill:hover {
  border-color: var(--lumi-violet);
  color: var(--ink-primary);
}

.niche-pill[aria-pressed="true"] {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: #ffffff;
}

.customizer-input {
  font: inherit;
  font-size: max(1rem, 0.94rem);
  min-height: 42px;
  padding: 0.48rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-subtle);
  background: #ffffff;
  color: var(--ink-primary);
  width: 100%;
}

.customizer-input:focus {
  outline: none;
  border-color: var(--lumi-violet);
  box-shadow: 0 0 0 3px rgba(109, 74, 255, 0.14);
}

.customizer-swatches-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.swatch-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 1.5px var(--border-subtle);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out-expo), box-shadow var(--dur-fast) ease;
}

/* Touch Target Accessibility (WCAG 2.5.5: >= 44x44px on coarse pointers) */
@media (pointer: coarse) {
  .customizer-swatches-row {
    gap: 0.9rem;
  }

  .swatch-btn::after {
    content: "";
    position: absolute;
    inset: -7px;
  }

  .niche-pill,
  .theme-toggle-btn,
  .studio-tab,
  .stage-btn,
  .period-btn,
  .studio-btn {
    min-block-size: 44px;
    display: inline-flex;
    align-items: center;
  }
}

.swatch-btn:hover {
  transform: scale(1.12);
}

.swatch-btn[aria-pressed="true"] {
  box-shadow: 0 0 0 2.5px var(--ink-primary);
  transform: scale(1.08);
}

.swatch-lumi { background: linear-gradient(135deg, #ec2f96, #6d4aff, #0b99e6); }
.swatch-rose { background: linear-gradient(135deg, #8f3a5c, #e11d74); }
.swatch-cobalt { background: linear-gradient(135deg, #1d4ed8, #0ea5e9); }
.swatch-emerald { background: linear-gradient(135deg, #0f766e, #10b981); }
.swatch-obsidian { background: linear-gradient(135deg, #0f172a, #475569); }

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  color: var(--ink-primary);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
}

/* Studio Application Workspace */
.studio-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 590px;
  background: var(--studio-bg);
  color: var(--studio-ink);
}

.studio-app > * {
  min-width: 0;
}

@media (min-width: 920px) {
  .studio-app {
    grid-template-columns: 228px minmax(0, 1fr);
  }
}

.studio-sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.35rem 1rem;
  background: var(--studio-sidebar);
  border-bottom: 1px solid var(--studio-border);
}

@media (min-width: 920px) {
  .studio-sidebar {
    border-bottom: 0;
    border-right: 1px solid var(--studio-border);
  }
}

.studio-brand-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem;
}

.studio-brand-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
  background: linear-gradient(135deg, var(--studio-accent), var(--studio-accent-2));
  flex-shrink: 0;
}

.studio-brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--studio-ink);
  line-height: 1.2;
}

.studio-brand-niche {
  font-size: 0.76rem;
  color: var(--studio-ink-muted);
}

.studio-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

@media (min-width: 920px) {
  .studio-nav {
    flex-direction: column;
    flex-wrap: nowrap;
  }
}

.studio-tab {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.72rem 0.9rem;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--studio-ink-muted);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition:
    background-color var(--dur-fast) ease,
    color var(--dur-fast) ease;
}

.studio-tab:hover {
  background: var(--studio-surface);
  color: var(--studio-ink);
}

.studio-tab[aria-selected="true"] {
  background: var(--studio-accent-soft);
  color: var(--studio-accent);
}

.studio-tab-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--studio-surface);
  color: var(--studio-ink);
}

.studio-user-pill {
  display: none;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.75rem;
  border-radius: 14px;
  background: var(--studio-card);
  border: 1px solid var(--studio-border);
}

@media (min-width: 920px) {
  .studio-user-pill {
    display: flex;
  }
}

.studio-user-initials {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--studio-accent-soft);
  color: var(--studio-accent);
}

.studio-user-meta strong {
  display: block;
  font-size: 0.84rem;
  color: var(--studio-ink);
}

.studio-user-meta span {
  font-size: 0.74rem;
  color: var(--studio-ink-muted);
}

/* Studio Main Panels */
.studio-main {
  padding: clamp(1.1rem, 2.5vw, 1.75rem);
  display: grid;
  align-content: start;
  gap: 1.25rem;
  min-width: 0;
}

.studio-panel {
  min-width: 0;
  max-width: 100%;
}

.studio-panel[hidden] {
  display: none;
}

.kpi-box,
.chart-card,
.minisite-frame,
.minisite-body > *,
.crm-contact-card {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .crm-reply-form {
    flex-wrap: wrap;
  }
  .crm-reply-form .studio-btn {
    width: 100%;
    justify-content: center;
  }
}

.studio-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.studio-topbar h3 {
  font-size: 1.3rem;
  color: var(--studio-ink);
}

.studio-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.studio-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--studio-border);
  background: var(--studio-card);
  color: var(--studio-ink);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform var(--dur-fast) ease,
    background-color var(--dur-fast) ease,
    border-color var(--dur-fast) ease;
}

.studio-btn:hover {
  border-color: var(--studio-accent);
}

.studio-btn-accent {
  background: var(--studio-accent);
  border-color: var(--studio-accent);
  color: #ffffff;
}

.studio-btn-accent:hover {
  filter: brightness(1.08);
  color: #ffffff;
}

/* CRM Split Layout (Inspired by Pelle Nobre reference) */
.crm-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
}

.crm-split > * {
  min-width: 0;
}

@media (min-width: 780px) {
  .crm-split {
    grid-template-columns: minmax(250px, 0.92fr) minmax(0, 1.08fr);
  }
}

.crm-list {
  display: grid;
  gap: 0.65rem;
  align-content: start;
  max-height: 455px;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.crm-contact-card {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 0.55rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1.5px solid var(--studio-border);
  background: var(--studio-card);
  color: var(--studio-ink);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) ease,
    background-color var(--dur-fast) ease,
    transform var(--dur-fast) ease;
}

.crm-contact-card:hover {
  border-color: var(--studio-accent);
}

.crm-contact-card[aria-current="true"] {
  border-color: var(--studio-accent);
  background: var(--studio-accent-soft);
}

.crm-contact-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.crm-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, var(--studio-accent), var(--studio-accent-2));
  flex-shrink: 0;
}

.crm-contact-name {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--studio-ink);
}

.crm-contact-time {
  margin-left: auto;
  font-size: 0.74rem;
  color: var(--studio-ink-muted);
}

.crm-contact-snippet {
  font-size: 0.84rem;
  color: var(--studio-ink-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.crm-contact-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.crm-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--studio-ink);
}

/* Conversation Detail Pane */
.crm-thread-pane {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem;
  border-radius: 18px;
  background: var(--studio-surface);
  border: 1px solid var(--studio-border);
  min-height: 440px;
}

.crm-thread-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--studio-border);
}

.crm-stage-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.stage-btn {
  padding: 0.34rem 0.7rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--studio-border);
  background: var(--studio-card);
  color: var(--studio-ink-muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.stage-btn[aria-pressed="true"] {
  background: var(--studio-accent);
  border-color: var(--studio-accent);
  color: #ffffff;
}

.crm-messages {
  display: grid;
  gap: 0.7rem;
  align-content: start;
  flex: 1;
  max-height: 310px;
  overflow-y: auto;
  padding-block: 0.25rem;
}

.chat-bubble {
  max-width: 86%;
  padding: 0.72rem 0.95rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.chat-bubble.incoming {
  justify-self: start;
  background: var(--studio-card);
  color: var(--studio-ink);
  border: 1px solid var(--studio-border);
  border-bottom-left-radius: 4px;
}

.chat-bubble.outgoing {
  justify-self: end;
  background: var(--studio-accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.intent-underline {
  text-decoration: underline;
  text-decoration-color: var(--status-hot-solid);
  text-decoration-thickness: 2.5px;
  text-underline-offset: 3px;
  font-weight: 600;
}

.crm-reply-form {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--studio-border);
  min-width: 0;
}

.crm-reply-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--studio-border);
  background: var(--studio-card);
  color: var(--studio-ink);
  font: inherit;
  font-size: max(1rem, 0.9rem);
}

/* Dashboard KPIs & Pure SVG Chart */
.period-switcher {
  display: inline-flex;
  padding: 0.25rem;
  border-radius: var(--radius-pill);
  background: var(--studio-surface);
  border: 1px solid var(--studio-border);
}

.period-btn {
  padding: 0.36rem 0.8rem;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  color: var(--studio-ink-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.period-btn[aria-pressed="true"] {
  background: var(--studio-card);
  color: var(--studio-ink);
  box-shadow: var(--shadow-xs);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

@media (min-width: 720px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-box {
  padding: 1rem 1.1rem;
  border-radius: 16px;
  background: var(--studio-card);
  border: 1px solid var(--studio-border);
  display: grid;
  gap: 0.35rem;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--studio-ink-muted);
  font-weight: 500;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: clamp(1.15rem, 1rem + 0.8vw, 1.55rem);
  font-weight: 700;
  color: var(--studio-ink);
}

.kpi-delta {
  font-size: 0.78rem;
  font-weight: 600;
  color: #15803d;
}

.studio-shell[data-theme="dark"] .kpi-delta {
  color: #4ade80;
}

.chart-card {
  position: relative;
  padding: 1.25rem;
  border-radius: 18px;
  background: var(--studio-card);
  border: 1px solid var(--studio-border);
  display: grid;
  gap: 1rem;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--studio-ink-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 12px;
  height: 4px;
  border-radius: 99px;
}

.legend-swatch.dashed {
  background: repeating-linear-gradient(90deg, var(--studio-accent-3) 0 4px, transparent 4px 7px);
}

.chart-svg-wrap {
  position: relative;
  width: 100%;
  display: grid;
  gap: 0.75rem;
}

.chart-svg {
  width: 100%;
  height: auto;
  aspect-ratio: 680 / 230;
  max-height: 240px;
  overflow: visible;
}

.chart-tooltip {
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  background: var(--studio-surface);
  border: 1px solid var(--studio-border);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--studio-ink);
}

/* Mini-Site Live Preview Tab */
.minisite-frame {
  border-radius: 18px;
  border: 1px solid var(--studio-border);
  overflow: hidden;
  background: var(--studio-card);
}

.minisite-browser-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  background: var(--studio-surface);
  border-bottom: 1px solid var(--studio-border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--studio-ink-muted);
}

.browser-dots {
  display: flex;
  gap: 0.35rem;
}

.browser-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--studio-border);
}

.minisite-body {
  padding: clamp(1.35rem, 3vw, 2.25rem);
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 760px) {
  .minisite-body {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: center;
  }
}

.minisite-headline {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 1.1rem + 1.1vw, 2rem);
  font-weight: 700;
  color: var(--studio-ink);
  line-height: 1.18;
  margin-bottom: 0.75rem;
}

.minisite-sub {
  font-size: 0.94rem;
  color: var(--studio-ink-muted);
  margin-bottom: 1.15rem;
}

.minisite-form-box {
  padding: 1.15rem;
  border-radius: 16px;
  background: var(--studio-surface);
  border: 1px solid var(--studio-border);
  display: grid;
  gap: 0.75rem;
}

.minisite-form-box input {
  min-height: 40px;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--studio-border);
  background: var(--studio-card);
  color: var(--studio-ink);
  font: inherit;
  font-size: max(1rem, 0.9rem);
}
