/* L'Oréal-inspired colors used throughout the page. */
:root {
  --loreal-red: #ff003b;
  --loreal-gold: #e3a535;
  --ink: #171717;
  --muted: #686868;
  --cream: #fffaf1;
  --line: #ded8cf;
}

/* Basic reset */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Montserrat", Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fff 0, var(--cream) 100%);
  min-height: 100vh;
}

button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible,
.product-card:focus-visible, summary:focus-visible {
  outline: 3px solid var(--loreal-gold);
  outline-offset: 3px;
}

.page-wrapper { width: min(92%, 1120px); margin: 0 auto; }

.site-header {
  text-align: center;
  padding: 48px 20px 28px;
  border-bottom: 4px solid var(--loreal-gold);
}
.logo { width: min(250px, 70vw); margin-bottom: 14px; }
.site-title { font-size: clamp(20px, 3vw, 28px); font-weight: 500; letter-spacing: .04em; }
.search-section { margin: 32px 0; display: flex; gap: 12px; }
.search-section select, .search-section input {
  width: 100%; padding: 16px; font-size: 17px; border: 2px solid var(--ink);
  border-radius: 4px; background: #fff; font-weight: 500;
}
.search-section select { flex: 0 1 38%; cursor: pointer; }
.search-input-wrapper { position: relative; flex: 1 1 62%; }
.search-input-wrapper input { padding-inline-start: 46px; }
.search-input-wrapper i {
  position: absolute; inset-inline-start: 17px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}

.placeholder-message, .status-message {
  width: 100%; text-align: center; padding: 42px 20px; color: var(--muted);
}

/* Product cards */
.products-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 30px 0;
}
.product-card {
  position: relative; min-width: 0; border: 2px solid var(--line); padding: 20px;
  border-radius: 8px; background: #fff; cursor: pointer; transition: .2s ease;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .05);
}
.product-card:hover { transform: translateY(-3px); border-color: var(--loreal-gold); }
.product-card.selected {
  border-color: var(--loreal-red); box-shadow: 0 0 0 3px rgba(255, 0, 59, .12);
}
.selection-badge {
  position: absolute; top: 12px; inset-inline-end: 12px; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%; color: #fff; background: var(--ink);
}
.product-card.selected .selection-badge { background: var(--loreal-red); }
.product-card > img { width: 100%; height: 160px; object-fit: contain; margin-bottom: 18px; }
.product-brand { color: var(--loreal-red); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.product-card h3 { font-size: 16px; line-height: 1.35; margin: 6px 0; }
.product-category { color: var(--muted); font-size: 13px; text-transform: capitalize; }
.product-description { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.product-description summary { color: var(--ink); font-size: 13px; font-weight: 700; cursor: pointer; }
.product-description p { color: var(--muted); font-size: 13px; line-height: 1.55; margin-top: 10px; }

/* Selected products */
.selected-products, .chatbox {
  margin: 40px 0; padding: 26px; border: 2px solid var(--ink); border-top: 6px solid var(--loreal-gold);
  border-radius: 8px; background: #fff;
}
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.section-heading h2, .chatbox h2 { font-size: 20px; }
.clear-btn { border: 0; color: var(--loreal-red); background: transparent; font-weight: 700; cursor: pointer; }
#selectedProductsList { display: flex; flex-wrap: wrap; gap: 10px; }
.empty-selection { color: var(--muted); }
.selected-product {
  display: flex; align-items: center; gap: 9px; max-width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--cream); font-size: 13px;
}
.selected-product img { width: 30px; height: 30px; object-fit: contain; }
.selected-product span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-product button { border: 0; background: transparent; color: var(--loreal-red); cursor: pointer; padding: 4px; }
.generate-btn {
  width: 100%; margin-top: 22px; padding: 16px; color: #fff; background: var(--loreal-red);
  border: 0; border-radius: 4px; cursor: pointer; font-size: 17px; font-weight: 700;
}
.generate-btn:hover:not(:disabled) { background: #d90032; }
.generate-btn:disabled, .chat-form button:disabled { opacity: .45; cursor: not-allowed; }
.generate-btn i { margin-inline-end: 8px; color: var(--loreal-gold); }

/* Chat */
.chatbox { border-top-color: var(--loreal-red); }
.chatbox h2 { margin-bottom: 20px; }
.chat-window {
  min-height: 280px; max-height: 520px; overflow-y: auto; padding: 18px;
  background: #f7f5f2; border-radius: 4px; display: flex; flex-direction: column; gap: 12px;
}
.chat-placeholder { margin: auto; color: var(--muted); text-align: center; }
.chat-message { max-width: 86%; padding: 12px 15px; border-radius: 12px; line-height: 1.55; }
.chat-message p + p, .chat-message p + ul, .chat-message p + ol,
.chat-message ul + p, .chat-message ol + p { margin-top: 10px; }
.chat-message ul, .chat-message ol { padding-inline-start: 24px; margin-block: 8px; }
.chat-message h3, .chat-message h4, .chat-message h5 { margin-block: 12px 6px; }
.chat-message code { padding: 2px 4px; border-radius: 3px; background: #ece8e2; font-size: .9em; }
.chat-message a { color: inherit; font-weight: 700; }
.assistant-message { align-self: flex-start; background: #fff; border-inline-start: 4px solid var(--loreal-gold); }
.user-message { align-self: flex-end; color: #fff; background: var(--loreal-red); }
.status-message { align-self: center; padding: 20px; }
.error-message { color: #a40026; }
.chat-form { display: flex; gap: 10px; margin-top: 16px; }
.chat-form input { flex: 1; min-width: 0; padding: 13px; border: 2px solid var(--line); border-radius: 4px; }
.chat-form input:focus { border-color: var(--loreal-gold); }
.chat-form button {
  width: 50px; border: 0; border-radius: 4px; color: #fff; background: var(--ink); cursor: pointer;
}
.chat-form button:hover:not(:disabled) { background: var(--loreal-red); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.site-footer { margin: 60px 0 40px; text-align: center; font-size: 14px; color: var(--muted); }
.site-footer nav { margin-top: 12px; }
.site-footer a { margin: 0 8px; color: var(--ink); text-decoration-color: var(--loreal-gold); }
.site-footer a:hover { color: var(--loreal-red); }

/* Logical CSS properties make spacing and borders mirror automatically in RTL. */
[dir="rtl"] body { text-align: right; }
[dir="rtl"] .products-grid { direction: rtl; }
[dir="rtl"] .assistant-message { align-self: flex-start; }
[dir="rtl"] .user-message { align-self: flex-end; }
[dir="rtl"] .chat-form button i { transform: scaleX(-1); }

@media (max-width: 820px) { .products-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) {
  .search-section { flex-direction: column; }
  .search-section select { flex-basis: auto; }
  .products-grid { grid-template-columns: 1fr; }
  .selected-products, .chatbox { padding: 18px; }
  .chat-message { max-width: 94%; }
}
