/* ─── Phelippe AI Chat Widget ─── HM brand DNA */
:root {
  --cream: #f5efe4;
  --cream-deep: #ede3d0;
  --cream-card: #f9f3e7;
  --dark: #1a1410;
  --dark-soft: #2a221c;
  --gold: #d99520;
  --gold-light: #e0a83a;
  --gold-deep: #c8841e;
  --sun: #d97a30;
  --ember: #b94a26;
  --oxblood: #7a2418;
  --muted: rgba(26, 20, 16, 0.55);
  --line: rgba(26, 20, 16, 0.10);
  --line-soft: rgba(26, 20, 16, 0.06);
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow-bubble: 0 1px 2px rgba(26, 20, 16, 0.04), 0 4px 12px rgba(26, 20, 16, 0.06);
  --shadow-user: 0 2px 6px rgba(26, 20, 16, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100vh; display: flex; flex-direction: column; }

/* ─── Header ─── */
.ph-header {
  padding: 20px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--cream-card) 0%, var(--cream) 100%);
  display: flex; align-items: center; gap: 16px;
  flex-shrink: 0;
  position: relative;
}
.ph-header::after {
  content: '';
  position: absolute;
  left: 28px; right: 28px; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
  opacity: 0.35;
}
.ph-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--dark);
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid var(--gold-light);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(217, 149, 32, 0.18);
}
.ph-avatar-h {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: 24px;
  color: var(--gold-light);
  margin-top: -2px;
}
.ph-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: 24px;
  color: var(--dark);
  line-height: 1;
  letter-spacing: -0.01em;
}
.ph-subtitle {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-top: 6px;
}
.ph-quota {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(217, 149, 32, 0.08);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(217, 149, 32, 0.2);
}

/* ─── Messages ─── */
.ph-scroll {
  flex: 1; overflow-y: auto;
  padding: 28px 28px 12px;
  display: flex; flex-direction: column; gap: 22px;
  scroll-behavior: smooth;
}
.ph-msg {
  max-width: 78%;
  line-height: 1.6;
  font-size: 15.5px;
  animation: ph-fadeIn 0.3s ease-out;
}
@keyframes ph-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ph-msg.user {
  align-self: flex-end;
  background: var(--dark);
  color: var(--cream);
  padding: 13px 18px;
  border-radius: 20px 20px 4px 20px;
  box-shadow: var(--shadow-user);
  font-weight: 500;
  letter-spacing: 0.005em;
}
.ph-msg.phelippe {
  align-self: flex-start;
  display: flex; gap: 12px; align-items: flex-start;
}
.ph-msg.phelippe .ph-mini-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--dark);
  border: 2px solid var(--gold-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 3px;
  box-shadow: 0 2px 6px rgba(217, 149, 32, 0.15);
}
.ph-msg.phelippe .ph-mini-avatar span {
  font-family: var(--serif); font-style: italic; font-weight: 700;
  font-size: 17px; color: var(--gold-light); margin-top: -2px;
}
.ph-bubble {
  background: var(--cream-card);
  color: var(--dark);
  padding: 16px 20px;
  border-radius: 4px 20px 20px 20px;
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-bubble);
  position: relative;
}
.ph-bubble.streaming::after {
  content: '▍';
  display: inline-block;
  animation: ph-blink 1s steps(2) infinite;
  color: var(--gold-deep);
  margin-left: 3px;
  font-weight: 400;
}
@keyframes ph-blink { 50% { opacity: 0; } }

/* ─── Markdown inside bubble ─── */
.ph-bubble .ph-md-p {
  margin: 0 0 12px;
  line-height: 1.6;
}
.ph-bubble .ph-md-p:last-child { margin-bottom: 0; }
.ph-bubble strong {
  font-weight: 700;
  color: var(--dark);
}
.ph-bubble em {
  font-style: italic;
}
.ph-bubble .ph-md-code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(122, 36, 24, 0.07);
  color: var(--oxblood);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(122, 36, 24, 0.1);
}
.ph-bubble .ph-md-ol,
.ph-bubble .ph-md-ul {
  margin: 4px 0 12px;
  padding-left: 22px;
}
.ph-bubble .ph-md-ol:last-child,
.ph-bubble .ph-md-ul:last-child { margin-bottom: 0; }
.ph-bubble .ph-md-ol li,
.ph-bubble .ph-md-ul li {
  margin-bottom: 6px;
  line-height: 1.55;
}
.ph-bubble .ph-md-ol li:last-child,
.ph-bubble .ph-md-ul li:last-child { margin-bottom: 0; }
.ph-bubble .ph-md-ol {
  list-style-type: decimal;
}
.ph-bubble .ph-md-ol li::marker {
  color: var(--gold-deep);
  font-weight: 700;
}
.ph-bubble .ph-md-ul li::marker {
  color: var(--gold-deep);
}

/* ─── Suggested chips ─── */
.ph-suggest {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 4px 28px 16px;
}
.ph-chip {
  background: rgba(217, 149, 32, 0.06);
  border: 1.5px solid var(--gold-light);
  color: var(--dark);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  transition: all 0.18s ease;
  letter-spacing: 0.005em;
}
.ph-chip:hover {
  background: var(--gold-light);
  color: var(--dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(217, 149, 32, 0.25);
}

/* ─── Input ─── */
.ph-input-wrap {
  padding: 14px 18px 20px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-card) 100%);
  display: flex; gap: 12px; align-items: flex-end;
  flex-shrink: 0;
  position: relative;
}
.ph-input-wrap::before {
  content: '';
  position: absolute;
  left: 18px; right: 18px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
  opacity: 0.25;
}
.ph-input {
  flex: 1;
  background: white;
  border: 1.5px solid var(--line);
  border-radius: 24px;
  padding: 13px 20px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--dark);
  resize: none;
  min-height: 48px;
  max-height: 140px;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(26, 20, 16, 0.04);
}
.ph-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(217, 149, 32, 0.12);
}
.ph-input::placeholder { color: var(--muted); font-weight: 500; }

.ph-send {
  flex-shrink: 0;
  height: 48px;
  width: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--sun) 0%, var(--ember) 55%, var(--oxblood) 100%);
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow:
    0 2px 8px rgba(122, 36, 24, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  transition: transform 0.12s ease, box-shadow 0.18s ease;
}
.ph-send:hover:not(:disabled) {
  transform: translateY(-1.5px);
  box-shadow:
    0 6px 14px rgba(122, 36, 24, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}
.ph-send:active:not(:disabled) {
  transform: translateY(0);
}
.ph-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: saturate(0.6);
}
.ph-send svg {
  width: 20px; height: 20px;
  transform: rotate(-45deg);
  margin-top: 1px; margin-right: 1px;
  stroke-width: 2.5;
}

/* ─── Error ─── */
.ph-error {
  margin: 12px 28px;
  padding: 13px 18px;
  background: rgba(185, 74, 38, 0.08);
  border: 1px solid rgba(185, 74, 38, 0.28);
  color: var(--ember);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  animation: ph-fadeIn 0.25s ease-out;
}

/* ─── Mobile ─── */
@media (max-width: 600px) {
  .ph-header { padding: 16px 18px 14px; gap: 12px; }
  .ph-header::after { left: 18px; right: 18px; }
  .ph-avatar { width: 42px; height: 42px; }
  .ph-avatar-h { font-size: 21px; }
  .ph-title { font-size: 20px; }
  .ph-subtitle { font-size: 9.5px; letter-spacing: 1.6px; margin-top: 4px; }
  .ph-quota { font-size: 11px; padding: 5px 10px; }
  .ph-scroll { padding: 18px 18px 8px; gap: 18px; }
  .ph-suggest { padding: 2px 18px 12px; gap: 8px; }
  .ph-chip { font-size: 13px; padding: 9px 14px; }
  .ph-msg { max-width: 88%; font-size: 14.5px; }
  .ph-msg.phelippe .ph-mini-avatar { width: 32px; height: 32px; }
  .ph-msg.phelippe .ph-mini-avatar span { font-size: 15px; }
  .ph-bubble { padding: 13px 16px; }
  .ph-input-wrap { padding: 11px 14px 16px; gap: 10px; }
  .ph-input { font-size: 16px; /* prevent iOS zoom */ padding: 12px 18px; }
  .ph-send { height: 46px; width: 46px; }
}

/* ─── Empty state ─── */
.ph-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 48px 28px 24px;
  gap: 18px;
  animation: ph-fadeIn 0.4s ease-out;
}
.ph-empty-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--dark);
  border: 3px solid var(--gold-light);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(217, 149, 32, 0.22);
  margin-bottom: 4px;
}
.ph-empty-avatar span {
  font-family: var(--serif); font-style: italic; font-weight: 700;
  font-size: 42px; color: var(--gold-light); margin-top: -4px;
}
.ph-greet {
  font-family: var(--serif); font-style: italic; font-weight: 700;
  font-size: 26px; color: var(--dark); line-height: 1.25; max-width: 420px;
  letter-spacing: -0.005em;
}
.ph-eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--gold-deep);
}
.ph-prompt-hint {
  font-size: 14.5px; color: var(--muted); max-width: 380px; line-height: 1.6;
  font-weight: 500;
}

/* ─── Scrollbar styling ─── */
.ph-scroll::-webkit-scrollbar {
  width: 8px;
}
.ph-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.ph-scroll::-webkit-scrollbar-thumb {
  background: rgba(26, 20, 16, 0.12);
  border-radius: 4px;
}
.ph-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 20, 16, 0.22);
}
