/* ============================================================
   BREWY — Premium Build Session UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@400;500;600;700&family=Playfair+Display:wght@700&display=swap');

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  /* Premium Dark Shell */
  --shell-bg:       #08080a;
  --shell-surface:  rgba(17, 17, 20, 0.6);
  --shell-border:   rgba(255, 255, 255, 0.07);
  --shell-text:     #e2e2e6;
  --shell-muted:    #8f8f9d;
  --shell-accent:   #7c3aed;    /* electric violet */
  --shell-accent-light: #a78bfa;

  /* Status colours */
  --ok:      #10b981; /* emerald */
  --warn:    #f59e0b; /* amber */
  --err:     #ef4444; /* red */

  --nova-volume: 0; /* Updated via JS for orb animation */

  font-family: 'Outfit', 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  font-weight: 400;
  color-scheme: dark;
  color: var(--shell-text);
  background-color: var(--shell-bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App Background Gradient Mesh ──────────────────────────── */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    radial-gradient(circle at 15% 50%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(34, 211, 238, 0.05) 0%, transparent 50%);
  z-index: -1;
  pointer-events: none;
}

/* ── Dynamic Storefront Theme Tokens ───────────────────────── */
#storefront-preview {
  /* These will be overridden dynamically by inline styles via JS */
  --preview-bg:         #ffffff;
  --preview-surface:    #f8f8f8;
  --preview-border:     #e8e8e8;
  --preview-text:       #1a1a1a;
  --preview-muted:      #6b7280;
  --preview-accent:     #4f46e5; /* Primary Color */
  --preview-cta-bg:     var(--preview-accent);
  --preview-cta-text:   #ffffff;
  --preview-headline-font: 'Inter', sans-serif;
  --preview-card-bg:    #ffffff;
  --preview-card-border: #e8e8e8;
  --preview-card-shadow: 0 1px 4px rgba(0,0,0,0.08);
  --preview-badge-bg:   #ede9fe;
  --preview-badge-text: var(--preview-accent);
  --preview-price-color: var(--preview-accent);
  --preview-gradient-a: #c7d2fe;
  --preview-gradient-b: #ddd6fe;

  /* Additional dynamics */
  --preview-animation: none;
  --preview-pattern: none;
}

/* Generative Backgrounds */
#storefront-preview.bg-solid {
  background: var(--preview-bg);
}

#storefront-preview.bg-mesh-gradient {
  background: 
    radial-gradient(at 0% 0%, var(--preview-gradient-a) 0px, transparent 50%),
    radial-gradient(at 100% 100%, var(--preview-gradient-b) 0px, transparent 50%),
    var(--preview-bg);
}

#storefront-preview.bg-dot-pattern {
  background-color: var(--preview-bg);
  background-image: radial-gradient(var(--preview-border) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Interactive Elements for Real-Time CSS */
.interactive-element {
  position: relative;
  transition: all 0.2s ease;
  cursor: pointer;
}

.interactive-element:hover::after {
  content: '';
  position: absolute;
  top: -4px; left: -4px; right: -4px; bottom: -4px;
  border: 1px dashed var(--shell-accent);
  border-radius: inherit;
  pointer-events: none;
  z-index: 10;
}

.interactive-element.selected {
  outline: 2px solid var(--shell-accent);
  outline-offset: 4px;
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.3);
}

/* Dynamic Animation Styles */
#storefront-preview.anim-smooth-fade .interactive-element {
  animation: fadeSlideIn 0.5s ease-out both;
}
#storefront-preview.anim-spring .interactive-element {
  animation: springIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
#storefront-preview.anim-bouncy .interactive-element {
  animation: bouncyIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
}

@keyframes springIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes bouncyIn {
  0%   { opacity: 0; transform: scale(0.5); }
  60%  { opacity: 1; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  height: 100vh;
  overflow: hidden;
}

h1, h2, h3 { margin: 0; font-family: 'Outfit', sans-serif; }

/* ── App shell ─────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 1rem 1.5rem;
  gap: 1rem;
}

/* ── Top Nav (Header) ──────────────────────────────────────── */
#top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem;
  flex-shrink: 0;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  background: linear-gradient(to right, #fff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.step-pills {
  display: flex;
  gap: 0.75rem;
}

.step-pill {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--shell-border);
  background: var(--shell-surface);
  color: var(--shell-muted);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  font-size: 0.65rem;
  font-weight: 700;
}

.step-pill[data-status="active"] {
  border-color: var(--shell-accent);
  background: rgba(124, 58, 237, 0.15);
  color: #fff;
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.2);
}
.step-pill[data-status="active"] .step-num {
  background: var(--shell-accent);
  color: #fff;
}

.step-pill[data-status="done"] {
  border-color: var(--ok);
  color: var(--ok);
}
.step-pill[data-status="done"] .step-num {
  background: var(--ok);
  color: #000;
}

/* Status indicator */
#status {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--shell-border);
}

.disconnected { background: rgba(255,255,255,0.03); color: var(--shell-muted); }
.connecting   { background: rgba(245, 158, 11, 0.1); border-color: rgba(245,158,11,0.2); color: var(--warn); }
.connected    { background: rgba(16, 185, 129, 0.1); border-color: rgba(16,185,129,0.2); color: var(--ok); }
.ready        { background: rgba(16, 185, 129, 0.1); border-color: rgba(16,185,129,0.2); color: var(--ok); }
.recording    { background: rgba(124, 58, 237, 0.15); border-color: var(--shell-accent); color: #fff; box-shadow: 0 0 10px rgba(124,58,237,0.3); }
.processing   { background: rgba(245, 158, 11, 0.1); color: var(--warn); }
.error        { background: rgba(239, 68, 68, 0.1); border-color: rgba(239,68,68,0.3); color: var(--err); }

/* ── Main Layout ───────────────────────────────────────────── */
#main-layout {
  display: flex;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
}

/* ── Sidebars (Left & Right) ─────────────────────────────── */
#sidebar-left, #sidebar-right {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  /* Hide scrollbar for clean look */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#sidebar-left::-webkit-scrollbar, #sidebar-right::-webkit-scrollbar { display: none; }

/* Nova Orb Visualizer */
#nova-visualizer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 140px;
  position: relative;
  border: 1px solid var(--shell-border);
  border-radius: 16px;
  background: var(--shell-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.orb-container {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #a78bfa, #7c3aed);
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
  /* The scale is driven dynamically by --nova-volume */
  transform: scale(calc(1 + var(--nova-volume) * 2));
  transition: transform 0.05s linear, box-shadow 0.05s linear;
}

/* Optional organic breathing when idle */
.ready #nova-visualizer .orb {
  animation: orb-breathe 4s infinite ease-in-out;
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 15px rgba(124, 58, 237, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 25px rgba(124, 58, 237, 0.6); }
}

#barge-in-pill {
  position: absolute;
  bottom: 10px;
  background: rgba(245, 158, 11, 0.2);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.2s, transform 0.2s;
}

#barge-in-pill.show {
  opacity: 1;
  transform: translateY(0);
}

/* Checklist / Progress Panel */
#progress-panel, #conversation-panel {
  border: 1px solid var(--shell-border);
  border-radius: 16px;
  padding: 1.25rem;
  background: var(--shell-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
}

#progress-panel h3, #conversation-panel h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--shell-muted);
  font-weight: 600;
  margin-bottom: 1rem;
}

.category-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.category-row:last-child { border-bottom: none; }

.category-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1.5px solid var(--shell-border);
  transition: all 0.3s;
}

.category-icon.done        { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 8px rgba(16,185,129,0.4); }
.category-icon.in_progress { background: var(--shell-accent); border-color: var(--shell-accent); box-shadow: 0 0 8px rgba(124,58,237,0.4); }
.category-icon.todo        { background: transparent; }

.category-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--shell-text);
  line-height: 1.3;
}
.category-label.todo { color: var(--shell-muted); }

.category-tasks {
  font-size: 0.75rem;
  color: var(--shell-muted);
  margin-top: 4px;
  line-height: 1.6;
}

/* Controls inside sidebar */
#controls {
  display: flex;
  gap: 0.75rem;
}

.button {
  flex: 1;
  padding: 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--shell-border);
  background: rgba(255,255,255,0.03);
  color: var(--shell-text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}

.button:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
}
.button:disabled { opacity: 0.4; cursor: not-allowed; }

#start:not(:disabled) { border-color: rgba(124,58,237,0.5); color: #fff; background: rgba(124,58,237,0.1); }
#stop:not(:disabled) { border-color: rgba(239,68,68,0.5); color: #fff; background: rgba(239,68,68,0.1); }

/* Conversation Panel inside sidebar */
#conversation-panel {
  flex: 1;
  min-height: 200px; /* ensure it has space to grow/shrink */
  padding-bottom: 0.75rem;
}

#chat-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.5rem;
  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
#chat-container::-webkit-scrollbar { width: 4px; }
#chat-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

/* Compact Transcript Bubbles */
.message {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
  word-wrap: break-word;
  max-width: 90%;
  font-family: 'Inter', sans-serif;
}

.user {
  background: rgba(255,255,255,0.05);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.assistant {
  background: rgba(124, 58, 237, 0.1);
  color: #d8b4fe;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.system {
  background: transparent;
  color: var(--shell-muted);
  font-style: italic;
  font-size: 0.7rem;
  align-self: center;
  text-align: center;
  padding: 0.2rem;
}

.role-label {
  display: none; /* Hide labels for a cleaner chat look, colors differentiate */
}

/* Thinking dots */
.thinking-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  height: 12px;
  margin-left: 4px;
}
.thinking-dots .dot {
  width: 4px; height: 4px;
  background: currentColor;
  border-radius: 50%;
  animation: pulse 1.5s infinite ease-in-out;
}
.thinking-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots .dot:nth-child(3) { animation-delay: 0.4s; }
.message.thinking { opacity: 0.7; }

/* ── Centre panel: live storefront preview ─────────────────── */
#storefront-preview {
  flex: 1;
  border: 1px solid var(--shell-border);
  border-radius: 16px;
  overflow-y: auto;
  background: var(--preview-bg, #ffffff);
  color: var(--preview-text, #1a1a1a);
  transition: background 0.5s ease, color 0.5s ease;
  /* Nice subtle shadow to separate from the dark shell */
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  /* The storefront uses Inter/Playfair, not the shell's Outfit */
  font-family: 'Inter', sans-serif;
}

/* Hero section */
#storefront-hero {
  padding: 3rem 3rem 2rem;
  border-bottom: 1px solid var(--preview-border, #e8e8e8);
  transition: border-color 0.5s;
}

#storefront-brand {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 2rem;
}

#storefront-name {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--preview-accent, #4f46e5);
  transition: color 0.5s;
}

#storefront-tagline {
  font-size: 0.85rem;
  color: var(--preview-muted, #6b7280);
  font-style: italic;
}

#storefront-hero-copy {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#storefront-headline {
  font-family: var(--preview-headline-font, 'Inter', sans-serif);
  font-size: clamp(1.8rem, 3vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--preview-text, #1a1a1a);
  min-height: 1.2em;
  transition: color 0.5s, font-family 0.3s;
}

#storefront-headline:empty::before {
  content: '';
  display: block;
  width: 50%;
  height: 1em;
  border-radius: 6px;
  background: var(--preview-border, #e8e8e8);
  animation: shimmer 1.8s infinite ease-in-out;
}

#storefront-subheadline {
  font-size: 1.1rem;
  color: var(--preview-muted, #6b7280);
  max-width: 50ch;
  line-height: 1.6;
  min-height: 0;
  transition: color 0.5s;
}
#storefront-subheadline:empty { display: none; }

.cta-btn {
  align-self: flex-start;
  padding: 0.8rem 1.8rem;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: default;
  background: var(--preview-cta-bg, #4f46e5);
  color: var(--preview-cta-text, #ffffff);
  transition: background 0.5s, color 0.5s;
  font-family: inherit;
  margin-top: 0.5rem;
}

/* Product section */
#product-section { padding: 2rem 3rem 3rem; }

#product-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--preview-muted, #6b7280);
  margin-bottom: 1.5rem;
  transition: color 0.5s;
}

#product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.product-card {
  background: var(--preview-card-bg, #ffffff);
  border: 1px solid var(--preview-card-border, #e8e8e8);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--preview-card-shadow, 0 1px 4px rgba(0,0,0,0.08));
  animation: fadeSlideIn 0.35s ease-out;
  transition: box-shadow 0.2s;
}
.product-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.12); }

.product-card-image {
  height: 120px;
  background: linear-gradient(135deg, var(--preview-gradient-a, #c7d2fe), var(--preview-gradient-b, #ddd6fe));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.5s;
}

.product-card-image-icon { font-size: 2.2rem; opacity: 0.6; }

.product-card-body { padding: 1rem; }

.product-card .product-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--preview-text, #1a1a1a);
  line-height: 1.3;
  transition: color 0.5s;
}

.product-card .product-price {
  color: var(--preview-price-color, #4f46e5);
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 0.35rem;
  transition: color 0.5s;
}

.product-card .product-desc {
  color: var(--preview-muted, #6b7280);
  font-size: 0.85rem;
  margin-top: 0.4rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card .product-category {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--preview-badge-bg, #ede9fe);
  color: var(--preview-badge-text, #4f46e5);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  margin-top: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background 0.5s, color 0.5s;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.4; }
  50%       { transform: scale(1);   opacity: 1; }
}
@keyframes shimmer {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.9; }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  #main-layout { flex-direction: column; overflow-y: auto; }
  #sidebar-left, #sidebar-right { flex: none; max-height: 50vh; overflow-y: auto; }
  #conversation-panel { min-height: 150px; }
  #storefront-hero { padding: 2rem 1.5rem; }
  #product-section { padding: 1.5rem 1.5rem 2rem; }
}

/* ── Onboarding View ───────────────────────────────────────── */
#onboarding-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--shell-bg);
}

.onboarding-hero {
  max-width: 600px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 4rem 3rem;
  background: var(--shell-surface);
  border: 1px solid var(--shell-border);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  backdrop-filter: blur(20px);
}

.onboarding-hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(to right, #fff, var(--shell-accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.onboarding-hero p {
  color: var(--shell-muted);
  font-size: 1.1rem;
}

#onboarding-orb-container {
  width: 120px;
  height: 120px;
  margin: 1rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.controls-container {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 300px;
}

#onboarding-chat-container {
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 1rem;
  border-top: 1px solid var(--shell-border);
  padding-top: 1rem;
  text-align: left;
}

/* ── User Panel ────────────────────────────────────────────── */
#user-panel {
  border: 1px solid var(--shell-border);
  border-radius: 16px;
  padding: 1.25rem;
  background: var(--shell-surface);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#user-panel h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--shell-muted);
  font-weight: 600;
  margin: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-stat {
  font-size: 0.85rem;
  color: var(--shell-text);
  background: rgba(255,255,255,0.03);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-stat strong {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--shell-muted);
  letter-spacing: 0.05em;
}

.checkpoint-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.button.small {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
}

.button.outline {
  background: transparent;
  border-color: rgba(255,255,255,0.2);
}
.button.outline:hover:not(:disabled) {
  background: rgba(255,255,255,0.05);
}
