/* AI Baking Assistant - Styles
   Aesthetic: "Strawberry frosting" — pastel pink chat app.
*/

:root {
  --cream: #FFF7FA;
  --cream-dark: #FFEDF3;
  --blush: #FFDDE9;
  --blush-soft: #FFF0F5;
  --brown-light: #F6C6D8;
  --brown: #D6457F;
  --brown-dark: #B32D66;
  --gold: #F49BBE;
  --gold-light: #FFD3E3;
  --mint: #CDEFE3;
  --mint-dark: #2F7A62;
  --white: #FFFFFF;
  --text-primary: #3E2332;
  --text-secondary: #6E4A5C;
  --text-muted: #A07C8E;
  --border: #F6D9E4;
  --shadow: rgba(214, 69, 127, 0.10);

  --font-display: 'Fredoka', 'Nunito', 'Segoe UI', sans-serif;
  --font-body: 'Nunito', -apple-system, 'Segoe UI', sans-serif;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 9999px;

  --transition-fast: 150ms ease;
  --transition-normal: 240ms cubic-bezier(.2, .8, .2, 1);
  --transition-slow: 360ms ease;

  --sidebar-width: 300px;
  --header-height: 56px;
  --column: 720px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100%;
  overflow: hidden;
}

::selection { background: var(--blush); color: var(--text-primary); }

:focus-visible {
  outline: 2.5px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--cream-dark);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: transform var(--transition-normal);
  z-index: 100;
}

.sidebar-header { padding: var(--space-lg); }

.logo { display: flex; align-items: center; gap: var(--space-sm); }

.logo-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background: var(--white);
  border: 1.5px solid var(--brown-light);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--brown-light);
}

.logo h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.tagline { font-size: 0.82rem; color: var(--text-muted); margin-top: var(--space-xs); }

.recipe-panel {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-lg) var(--space-lg);
  display: none;
}

.recipe-panel.active { display: block; }

.recipe-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.recipe-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  line-height: 1.3;
}

.recipe-meta {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.recipe-meta span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.recipe-progress { margin-bottom: var(--space-lg); }

.progress-bar {
  height: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background:
    repeating-linear-gradient(-45deg, rgba(255,255,255,.45) 0 6px, transparent 6px 12px),
    var(--gold);
  transition: width var(--transition-normal);
}

.progress-text {
  display: block;
  text-align: center;
  margin-top: var(--space-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ingredients-section, .steps-section { margin-bottom: var(--space-lg); }

.ingredients-section h4, .steps-section h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

#ingredientsList { list-style: none; }

#ingredientsList li {
  padding: 6px var(--space-sm);
  margin: 0 calc(var(--space-sm) * -1);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

#ingredientsList li:hover { background: var(--white); }

#ingredientsList li::before {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1.5px solid var(--brown-light);
  background: var(--white);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  color: var(--white);
  transition: all var(--transition-fast);
}

#ingredientsList li.checked::before {
  content: '✓';
  background: var(--brown);
  border-color: var(--brown);
}

#ingredientsList li.checked {
  text-decoration: line-through;
  text-decoration-color: var(--gold);
  color: var(--text-muted);
}

#stepsList { list-style: none; counter-reset: steps; }

#stepsList li {
  position: relative;
  padding: var(--space-sm) 0 var(--space-md) var(--space-xl);
  font-size: 0.88rem;
  border-left: 2px dashed var(--brown-light);
  margin-left: 12px;
  color: var(--text-secondary);
}

#stepsList li:last-child { border-left-color: transparent; }

#stepsList li::before {
  counter-increment: steps;
  content: counter(steps);
  position: absolute;
  left: -13px;
  top: var(--space-sm);
  width: 24px;
  height: 24px;
  background: var(--white);
  border: 1.5px solid var(--brown-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

#stepsList li.current { color: var(--text-primary); font-weight: 600; }

#stepsList li.current::before {
  background: var(--brown);
  border-color: var(--brown);
  color: var(--white);
  box-shadow: 0 0 0 4px var(--blush);
}

#stepsList li.completed { color: var(--text-muted); }

#stepsList li.completed::before {
  content: '✓';
  background: var(--mint);
  border-color: var(--mint);
  color: var(--mint-dark);
}

.recipe-actions { display: flex; gap: var(--space-sm); margin-top: var(--space-lg); }
.recipe-actions .btn { flex: 1; }

.preferences-section {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
}

.preferences-toggle {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.preferences-toggle:hover {
  border-color: var(--brown-light);
  box-shadow: 0 2px 0 var(--brown-light);
}

.preferences-panel { display: none; margin-top: var(--space-md); }
.preferences-panel.active { display: block; }

.pref-group { margin-bottom: var(--space-md); }

.pref-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.pref-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.pref-group select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--blush);
}

.checkbox-group { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 4px 12px 4px 8px;
  border-radius: var(--radius-full);
  margin: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.checkbox-group label:has(input:checked) {
  background: var(--blush);
  border-color: var(--brown-light);
}

.checkbox-group input[type="checkbox"] { accent-color: var(--brown); }

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
}

/* Buttons */
.btn {
  padding: 10px var(--space-md);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast),
              box-shadow var(--transition-fast), border-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--brown);
  color: var(--white);
  box-shadow: 0 3px 0 var(--brown-dark);
}

.btn-primary:hover { background: var(--brown-dark); }
.btn-primary:active { box-shadow: 0 1px 0 var(--brown-dark); }

.btn-secondary {
  background: var(--white);
  color: var(--text-primary);
  border: 1.5px solid var(--brown-light);
}

.btn-secondary:hover { background: var(--blush-soft); }

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  width: 100%;
  justify-content: flex-start;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}

.btn-ghost:hover { background: var(--white); border-color: var(--border); }

.btn-ghost span {
  width: 24px;
  height: 24px;
  background: var(--blush);
  color: var(--brown-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-icon:hover { background: var(--blush); color: var(--brown-dark); }

/* Main chat area */
.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  position: relative;
  overflow: hidden;
}

.mobile-header {
  display: none;
  padding: var(--space-sm) var(--space-md);
  min-height: var(--header-height);
  background: rgba(255, 247, 250, 0.9);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  align-items: center;
  gap: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.mobile-header h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
}

.menu-toggle:hover { background: var(--blush); }

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl) var(--space-lg);
  display: flex;
  flex-direction: column;
  background-color: var(--cream);
  background-image:
    radial-gradient(var(--gold-light) 1.2px, transparent 1.4px),
    radial-gradient(var(--mint) 1.2px, transparent 1.4px);
  background-size: 34px 34px, 34px 34px;
  background-position: 0 0, 17px 17px;
}

.chat-messages {
  max-width: var(--column);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Messages */
.message {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  animation: pop 0.22s ease;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.message.user { justify-content: flex-end; }

.message-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  background: var(--white);
  border: 1.5px solid var(--brown-light);
  border-radius: 50%;
}

.message.user .message-avatar { display: none; }

.message-content { max-width: 76%; min-width: 0; }
.message.assistant .message-content { max-width: 86%; }

.message-text {
  font-size: 0.96rem;
  line-height: 1.65;
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  overflow-wrap: anywhere;
}

.message.user .message-text {
  background: var(--blush);
  color: var(--text-primary);
  border-bottom-right-radius: 6px;
}

.message.assistant .message-text {
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 10px var(--shadow);
}

.message-text p { margin-bottom: var(--space-sm); }
.message-text p:last-child { margin-bottom: 0; }
.message-text strong { color: var(--brown-dark); font-weight: 700; }

.message-text ul, .message-text ol {
  margin: var(--space-sm) 0;
  padding-left: var(--space-lg);
}

.message-text li { margin-bottom: var(--space-xs); }
.message-text li::marker { color: var(--gold); }

/* Recipe card with scalloped cake-paper top */
.recipe-card {
  position: relative;
  background: var(--blush-soft);
  border: 1.5px solid var(--brown-light);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-lg);
  padding-top: calc(var(--space-lg) + 4px);
  margin-top: calc(var(--space-md) + 10px);
}

.recipe-card::before {
  content: '';
  position: absolute;
  left: -1.5px;
  right: -1.5px;
  top: -12px;
  height: 12px;
  background:
    radial-gradient(circle at 10px 12px, var(--blush-soft) 9px, var(--brown-light) 9.5px, var(--brown-light) 10.5px, transparent 11px)
    0 0 / 20px 12px repeat-x;
}

.recipe-card h4 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.recipe-card-meta {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: var(--space-md);
}

.recipe-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.recipe-card .start-btn { width: 100%; margin-top: var(--space-md); }

/* Typing indicator */
.typing-indicator {
  display: none;
  align-items: center;
  max-width: var(--column);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-sm);
}

.typing-indicator.active { display: flex; }

.typing-dots {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 6px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--gold);
  border-radius: 50%;
  animation: bounce 1.3s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .6; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Composer */
.chat-input-container {
  padding: var(--space-sm) var(--space-lg) var(--space-lg);
  background: linear-gradient(to bottom, rgba(255,247,250,0), var(--cream) 30%);
}

.quick-actions {
  display: flex;
  gap: var(--space-sm);
  margin: 0 auto var(--space-sm);
  overflow-x: auto;
  padding: 2px 0 var(--space-xs);
  max-width: var(--column);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.quick-actions::-webkit-scrollbar { display: none; }

.quick-action {
  padding: 6px 14px;
  background: var(--white);
  border: 1px solid var(--brown-light);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.quick-action:hover { background: var(--blush); color: var(--text-primary); }

.chat-form { max-width: var(--column); margin: 0 auto; }

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  background: var(--white);
  border: 1.5px solid var(--brown-light);
  border-radius: 26px;
  padding: 6px 6px 6px var(--space-sm);
  box-shadow: 0 4px 18px var(--shadow);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px var(--blush), 0 4px 18px var(--shadow);
}

#messageInput {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.98rem;
  line-height: 1.5;
  padding: 8px var(--space-sm);
  resize: none;
  max-height: 150px;
  background: transparent;
  color: var(--text-primary);
}

#messageInput::placeholder { color: var(--text-muted); }

.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--brown);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.send-btn:hover { background: var(--brown-dark); transform: scale(1.05); }

.send-btn:disabled {
  background: var(--brown-light);
  cursor: not-allowed;
  transform: none;
}

.send-btn svg { width: 18px; height: 18px; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brown-light); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(62, 35, 50, 0.25);
  backdrop-filter: blur(2px);
  z-index: 99;
}

.sidebar-overlay.active { display: block; }

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
}

.empty-state-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-md);
  display: grid;
  place-items: center;
  font-size: 2.2rem;
  background: var(--white);
  border: 1.5px solid var(--brown-light);
  border-radius: 24px;
  box-shadow: 0 4px 0 var(--brown-light);
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--blush);
  border-top-color: var(--brown);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-100%);
    box-shadow: 8px 0 30px rgba(62, 35, 50, 0.12);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-header { display: flex; }
  .chat-container { padding: var(--space-md) var(--space-sm); }
  .chat-input-container { padding: var(--space-xs) var(--space-sm) var(--space-sm); }
  .typing-indicator { padding: 0 var(--space-sm) var(--space-sm); }
  .message-content, .message.assistant .message-content { max-width: 85%; }
  .message-avatar { width: 28px; height: 28px; font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
