/* —— CSS Custom Properties for L'Oréal Brand Colors —— */
:root {
  --loreal-red: #ff003b;
  --loreal-gold: #e3a535;
  --loreal-dark: #1a1a1a;
  --loreal-light-gray: #f8f8f8;
  --loreal-medium-gray: #666;
  --text-dark: #333;
  --white: #ffffff;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

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

/* —— body + fonts —— */
body {
  font-family: "Montserrat", Arial, Helvetica, sans-serif;
  color: var(--text-dark);
  display: flex;
  justify-content: center;
  background: linear-gradient(135deg, var(--loreal-light-gray) 0%, #fff 100%);
  min-height: 100vh;
}

.page-wrapper {
  width: 90%;
  max-width: 1200px;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px var(--shadow-light);
  margin: 20px 0;
  overflow: hidden;
}

/* header */
.site-header {
  text-align: center;
  padding: 40px 30px 30px;
  background: linear-gradient(135deg, var(--loreal-red) 0%, var(--loreal-gold) 100%);
  color: var(--white);
}

.logo {
  width: 220px;
  margin-bottom: 15px;
  filter: brightness(0) invert(1);
}

.site-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* category filter */
.search-section {
  margin: 30px;
  display: flex;
}

.search-section select {
  width: 100%;
  padding: 18px 24px;
  font-size: 16px;
  border: 2px solid var(--loreal-light-gray);
  border-radius: var(--border-radius);
  cursor: pointer;
  background: var(--white);
  font-weight: 500;
  color: var(--text-dark);
  box-shadow: 0 4px 12px var(--shadow-light);
  transition: var(--transition);
}

.search-section select:focus {
  outline: none;
  border-color: var(--loreal-red);
  box-shadow: 0 4px 16px var(--shadow-medium);
}

.search-section select:hover {
  border-color: var(--loreal-gold);
}

/* chat section */
.chatbox {
  margin: 30px;
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 30px;
  box-shadow: 0 4px 12px var(--shadow-light);
}

.chatbox h2 {
  font-size: 22px;
  margin-bottom: 20px;
  color: var(--loreal-red);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbox h2::before {
  content: "💬";
  font-size: 20px;
}

.chat-window {
  padding: 24px;
  font-size: 16px;
  line-height: 1.6;
  height: 300px;
  overflow-y: auto;
  background: var(--loreal-light-gray);
  margin-bottom: 20px;
  border-radius: var(--border-radius);
  border: 2px solid transparent;
  transition: var(--transition);
}

.chat-window:hover {
  border-color: var(--loreal-gold);
}

/* Chat messages styling */
.chat-message {
  margin-bottom: 16px;
  padding: 16px 20px;
  border-radius: 12px;
  max-width: 85%;
  word-wrap: break-word;
  line-height: 1.6;
}

.user-message {
  background: linear-gradient(135deg, var(--loreal-red) 0%, var(--loreal-gold) 100%);
  color: var(--white);
  margin-left: auto;
  text-align: right;
}

.ai-message {
  background: var(--white);
  color: var(--text-dark);
  border: 2px solid var(--loreal-light-gray);
  margin-right: auto;
}

.loading-message {
  background: var(--loreal-light-gray);
  color: var(--loreal-medium-gray);
  border: 2px solid var(--loreal-medium-gray);
  margin-right: auto;
  font-style: italic;
}

/* Formatted content within messages */
.chat-message p {
  margin: 0 0 12px 0;
}

.chat-message p:last-child {
  margin-bottom: 0;
}

.chat-message h3 {
  color: var(--loreal-red);
  font-size: 18px;
  margin: 16px 0 8px 0;
  font-weight: 600;
}

.chat-message h4 {
  color: var(--loreal-gold);
  font-size: 16px;
  margin: 12px 0 6px 0;
  font-weight: 600;
}

.chat-message strong {
  font-weight: 600;
  color: var(--loreal-red);
}

.ai-message strong {
  color: var(--loreal-red);
}

.user-message strong {
  color: var(--white);
}

.chat-message em {
  font-style: italic;
  color: var(--loreal-gold);
}

.user-message em {
  color: rgba(255, 255, 255, 0.9);
}

.list-item {
  display: flex;
  align-items: flex-start;
  margin: 6px 0;
  padding-left: 8px;
}

.list-number {
  color: var(--loreal-red);
  font-weight: 600;
  margin-right: 8px;
  min-width: 20px;
}

.bullet {
  color: var(--loreal-gold);
  font-weight: bold;
  margin-right: 8px;
  min-width: 12px;
}

.user-message .list-number,
.user-message .bullet {
  color: rgba(255, 255, 255, 0.9);
}

.user-message .list-item {
  text-align: left;
}

/* Special formatting for routine sections */
.chat-message .routine-section {
  background: rgba(227, 165, 53, 0.1);
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
  border-left: 4px solid var(--loreal-gold);
}

/* placeholder message */
.placeholder-message {
  width: 100%;
  text-align: center;
  padding: 60px 20px;
  color: var(--loreal-medium-gray);
  font-size: 16px;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="none" stroke="%23e3a535" stroke-width="2" opacity="0.3"/></svg>') center center no-repeat;
  background-size: 60px 60px;
  padding-top: 100px;
}

/* input row */
.chat-form {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.chat-form input {
  flex: 1;
  padding: 16px 20px;
  font-size: 16px;
  border: 2px solid var(--loreal-light-gray);
  border-radius: var(--border-radius);
  background: var(--white);
  color: var(--text-dark);
  transition: var(--transition);
}

.chat-form input:focus {
  outline: none;
  border-color: var(--loreal-red);
  box-shadow: 0 4px 16px var(--shadow-medium);
}

.chat-form input::placeholder {
  color: var(--loreal-medium-gray);
}

.chat-form button {
  font-size: 18px;
  background: linear-gradient(135deg, var(--loreal-red) 0%, var(--loreal-gold) 100%);
  color: var(--white);
  border: none;
  padding: 16px 20px;
  min-width: 60px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(255, 0, 59, 0.3);
}

.chat-form button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 0, 59, 0.4);
}

.chat-form button:focus {
  outline: 2px solid var(--loreal-gold);
  outline-offset: 2px;
}

.chat-form button:disabled {
  background: var(--loreal-medium-gray);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* visually hidden */
.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;
}

/* footer */
.site-footer {
  margin: 0;
  padding: 30px;
  text-align: center;
  font-size: 14px;
  color: var(--white);
  background: var(--loreal-dark);
}

.site-footer nav {
  margin-top: 12px;
}

.site-footer a {
  margin: 0 12px;
  color: var(--loreal-gold);
  text-decoration: none;
  transition: var(--transition);
}

.site-footer a:hover {
  color: var(--white);
  text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
  .page-wrapper {
    width: 95%;
    margin: 10px 0;
  }
  
  .products-grid {
    grid-template-columns: 1fr;
    margin: 20px;
    gap: 16px;
  }
  
  .site-header {
    padding: 30px 20px 20px;
  }
  
  .logo {
    width: 180px;
  }
  
  .site-title {
    font-size: 24px;
  }
  
  .search-section,
  .selected-products,
  .chatbox {
    margin: 20px;
  }
  
  .product-card {
    flex-direction: column;
    text-align: center;
    min-height: auto;
  }
  
  .product-card img {
    width: 100px;
    height: 100px;
    align-self: center;
  }
  
  .chat-form {
    flex-direction: column;
  }
  
  .chat-form button {
    width: 100%;
    min-width: auto;
  }
}

/* products grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin: 30px;
  padding: 0;
}

.product-card {
  border: 2px solid var(--loreal-light-gray);
  padding: 20px;
  border-radius: var(--border-radius);
  display: flex;
  gap: 16px;
  min-height: 180px;
  background: var(--white);
  box-shadow: 0 4px 12px var(--shadow-light);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow-medium);
  border-color: var(--loreal-gold);
}

.product-card.selected {
  border-color: var(--loreal-red);
  background: linear-gradient(135deg, rgba(255, 0, 59, 0.05) 0%, rgba(227, 165, 53, 0.05) 100%);
  box-shadow: 0 8px 24px rgba(255, 0, 59, 0.2);
}

.product-card.selected::before {
  content: "✓";
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--loreal-red);
  color: var(--white);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
}

.product-card img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
}

.product-card .product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
}

.product-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-dark);
  font-weight: 600;
  line-height: 1.3;
}

.product-card .brand {
  font-size: 14px;
  color: var(--loreal-red);
  font-weight: 500;
  margin-bottom: 8px;
}

.product-card .category-tag {
  display: inline-block;
  background: var(--loreal-gold);
  color: var(--white);
  padding: 4px 8px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.show-description-btn {
  background: var(--loreal-light-gray);
  border: 1px solid var(--loreal-medium-gray);
  color: var(--text-dark);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
  align-self: flex-start;
}

.show-description-btn:hover {
  background: var(--loreal-gold);
  color: var(--white);
  border-color: var(--loreal-gold);
}

.product-description {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  padding: 20px;
  border-radius: var(--border-radius);
  display: none;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(10px);
}

.product-description.show {
  display: flex;
}

.product-description h4 {
  color: var(--loreal-red);
  font-size: 16px;
  margin-bottom: 12px;
  font-weight: 600;
}

.product-description p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dark);
  flex: 1;
}

.hide-description-btn {
  background: var(--loreal-red);
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 12px;
  align-self: flex-end;
}

.hide-description-btn:hover {
  background: var(--loreal-dark);
}

/* selected products */
.selected-products {
  margin: 30px;
  padding: 24px;
  background: linear-gradient(135deg, var(--loreal-light-gray) 0%, var(--white) 100%);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px var(--shadow-light);
}

.selected-products h2 {
  font-size: 22px;
  margin-bottom: 20px;
  color: var(--loreal-red);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.selected-products h2::before {
  content: "🛒";
  font-size: 20px;
}

#selectedProductsList {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  min-height: 40px;
}

.selected-product-item {
  background: var(--white);
  border: 2px solid var(--loreal-gold);
  border-radius: 24px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
  box-shadow: 0 2px 8px var(--shadow-light);
  transition: var(--transition);
}

.selected-product-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-medium);
}

.remove-product-btn {
  background: var(--loreal-red);
  color: var(--white);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

.remove-product-btn:hover {
  background: var(--loreal-dark);
  transform: scale(1.1);
}

.clear-all-btn {
  background: var(--loreal-medium-gray);
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 16px;
}

.clear-all-btn:hover {
  background: var(--loreal-red);
}

.generate-btn {
  width: 100%;
  padding: 18px;
  font-size: 18px;
  font-weight: 600;
  color: var(--white);
  background: linear-gradient(135deg, var(--loreal-red) 0%, var(--loreal-gold) 100%);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(255, 0, 59, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 0, 59, 0.4);
}

.generate-btn:disabled {
  background: var(--loreal-medium-gray);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.generate-btn i {
  margin-right: 8px;
}
