/* ================================================================
   AI Design Assistant — House of Estila
   ChatGPT-style: clean, minimal, centred conversation
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  line-height: 1.7;
  color: #1a1a1a;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: #BF9F5A; text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ── App shell ──────────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: #fff;
}
.app__body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar — narrow, minimal ──────────────────────────────────── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #f7f7f8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease, transform 0.25s ease;
}
.sidebar.is-collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
  overflow: hidden;
}
.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}
.sidebar__collapse {
  background: none;
  border: none;
  color: #999;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.sidebar__collapse:hover { color: #555; background: #eee; }
.sidebar__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #999;
}
.sidebar__new {
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sidebar__new:hover { background: #fff; }
.sidebar__list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.sidebar__item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s;
}
.sidebar__item:hover { background: #ececec; }
.sidebar__item--active { background: #e8e8e8; color: #1a1a1a; }
.sidebar__item--empty {
  text-align: center;
  color: #bbb;
  font-style: italic;
  padding: 32px 12px;
  font-size: 13px;
}
.sidebar__foot {
  padding: 12px 14px;
  border-top: 1px solid #eee;
}
.sidebar__foot-link { font-size: 12px; color: #999; }
.sidebar__foot-link:hover { color: #BF9F5A; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}

/* ── Topbar — mobile only ────────────────────────────────────────── */
.topbar {
  display: none;
}

/* ── Sidebar toggle — floating button when sidebar collapsed ────── */
.sidebar-open-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 80;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 8px;
  color: #666;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: opacity 0.2s;
}
.sidebar-open-btn:hover { color: #1a1a1a; background: #f7f7f8; }
.sidebar.is-collapsed ~ .chat .sidebar-open-btn { display: flex; }

/* ── Chat area — centred column ─────────────────────────────────── */
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
  position: relative;
}

/* ── Messages — centred, max-width, breathing room ──────────────── */
.chat__messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat__messages-inner {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Welcome — large, centred, elegant ──────────────────────────── */
.chat__welcome {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat__welcome-inner {
  text-align: center;
  max-width: 520px;
  padding: 40px 24px;
}
.chat__welcome-logo {
  height: 24px;
  margin: 0 auto 28px;
  opacity: 0.35;
}
.chat__welcome-title {
  font-family: 'Abhaya Libre', serif;
  font-size: 32px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 14px;
  line-height: 1.2;
}
.chat__welcome-text {
  font-size: 16px;
  color: #888;
  line-height: 1.7;
}

/* ── Messages ───────────────────────────────────────────────────── */
.chat__message {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}
.chat__message--user {
  display: flex;
  justify-content: flex-end;
}
.chat__message--user .chat__message-content {
  background: #f0f0f0;
  color: #1a1a1a;
  border-radius: 20px;
  padding: 12px 18px;
  max-width: 70%;
  font-size: 15px;
}
.chat__message--assistant {
  display: flex;
  justify-content: flex-start;
}
.chat__message--assistant .chat__message-content {
  padding: 4px 0;
  max-width: 100%;
  font-size: 15px;
  color: #1a1a1a;
}
.chat__message-content p { margin-bottom: 10px; }
.chat__message-content p:last-child { margin-bottom: 0; }
.chat__message-content h2, .chat__message-content h3 {
  font-family: 'Abhaya Libre', serif;
  margin: 20px 0 8px;
}
.chat__message-content h2 { font-size: 18px; }
.chat__message-content h3 { font-size: 16px; }
.chat__message-content ul, .chat__message-content ol {
  margin: 10px 0;
  padding-left: 22px;
}
.chat__message-content li { margin-bottom: 6px; }
.chat__message-content strong { font-weight: 700; }
.chat__message-content code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.chat__message-image {
  max-width: 220px;
  border-radius: 12px;
  margin-bottom: 8px;
}

/* Loading — pulsing dot cursor (inspired by assistant-ui) */
.chat__message--loading { display: flex; justify-content: flex-start; }
.chat__message--loading .chat__message-content { padding: 12px 0; }
.chat__typing-indicator {
  font-size: 15px;
  color: #999;
}
.chat__typing-indicator::after {
  content: '\25CF';
  animation: aui-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  margin-left: 2px;
}
@keyframes aui-pulse {
  50% { opacity: 0.3; }
}

/* Smooth message entrance */
.chat__message {
  animation: msg-in 0.3s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Product cards — clean grid ─────────────────────────────────── */
.chat__product-cards {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 16px 0 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chat__product-cards::-webkit-scrollbar { display: none; }
.chat__product-card {
  flex-shrink: 0;
  width: 148px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.15s;
}
.chat__product-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.06);
  transform: translateY(-2px);
  text-decoration: none;
}
.chat__product-card-image {
  width: 100%;
  aspect-ratio: 1;
  background: #f5f5f5;
  overflow: hidden;
}
.chat__product-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat__product-card-image--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #ddd;
}
.chat__product-card-image--placeholder::after { content: '\25CB'; }
.chat__product-card-info { padding: 10px 10px 12px; }
.chat__product-card-brand {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #BF9F5A;
  margin-bottom: 3px;
}
.chat__product-card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: #1a1a1a;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat__product-card-price {
  font-size: 13px;
  color: #888;
  margin-top: 4px;
}

/* ── Bottom — centred input ─────────────────────────────────────── */
.chat__bottom {
  flex-shrink: 0;
  padding: 0 24px 24px;
  background: #fff;
}
.chat__bottom-inner {
  max-width: 680px;
  margin: 0 auto;
}
/* Suggestion chips */
.chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding-bottom: 16px;
}
.chat__chip {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  padding: 8px 18px;
  font-size: 13px;
  color: #555;
  transition: border-color 0.15s, color 0.15s;
}
.chat__chip:hover {
  border-color: #BF9F5A;
  color: #1a1a1a;
}

/* Image preview */
.chat__image-preview { padding-bottom: 8px; }
#image-preview-inner { display: flex; gap: 8px; flex-wrap: wrap; }
.chat__image-thumb {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #eee;
}
.chat__image-thumb img { width: 100%; height: 100%; object-fit: cover; }
.chat__image-thumb-remove {
  position: absolute;
  top: 2px; right: 2px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Form — pill-shaped, ChatGPT style */
.chat__form {
  background: #f4f4f4;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  padding: 6px 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat__form:focus-within {
  border-color: #ccc;
  box-shadow: 0 0 0 4px rgba(191, 159, 90, 0.08);
}
.chat__form-row {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.chat__input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 10px;
  min-height: 38px;
  max-height: 160px;
  background: transparent;
  color: #1a1a1a;
}
.chat__input::placeholder { color: #aaa; }

/* Buttons */
.chat__plus-btn, .chat__icon-btn {
  background: none;
  border: none;
  color: #aaa;
  padding: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat__plus-btn:hover, .chat__icon-btn:hover {
  color: #555;
  background: rgba(0,0,0,0.04);
}
.chat__icon-btn--recording {
  color: #e53935;
  animation: pulse-record 1.5s ease-in-out infinite;
}
@keyframes pulse-record { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.chat__send {
  background: #1a1a1a;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}
.chat__send:hover { background: #BF9F5A; }
.chat__send:disabled { opacity: 0.3; cursor: default; }

/* Attach menu */
.chat__attach-wrap { position: relative; }
.chat__attach-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  overflow: hidden;
  min-width: 180px;
  z-index: 10;
}
.chat__attach-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 11px 16px;
  font-size: 14px;
  color: #333;
}
.chat__attach-option:hover { background: #f7f7f7; }

.chat__hint {
  text-align: center;
  font-size: 11px;
  color: #bbb;
  margin-top: 10px;
}

/* ── Auth gate ──────────────────────────────────────────────────── */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-gate__inner {
  text-align: center;
  max-width: 380px;
  padding: 40px 24px;
}
.auth-gate__logo {
  height: 24px;
  margin: 0 auto 28px;
  opacity: 0.5;
}
.auth-gate__title {
  font-family: 'Abhaya Libre', serif;
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 12px;
}
.auth-gate__text {
  font-size: 15px;
  color: #888;
  line-height: 1.7;
  margin-bottom: 28px;
}
.auth-gate__btn {
  display: inline-block;
  background: #1a1a1a;
  color: #fff;
  padding: 14px 40px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: 24px;
  transition: background 0.2s;
}
.auth-gate__btn:hover { background: #BF9F5A; text-decoration: none; }
.auth-gate__sub { margin-top: 16px; font-size: 13px; color: #bbb; }
.auth-gate__sub a { color: #BF9F5A; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 48px;
    background: #fff;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
  }
  .topbar__menu {
    background: none;
    border: none;
    color: #1a1a1a;
    padding: 6px;
  }
  .topbar__brand { display: flex; align-items: center; gap: 8px; flex: 1; }
  .topbar__logo { height: 18px; width: auto; }
  .topbar__title { font-family: 'Abhaya Libre', serif; font-size: 14px; font-weight: 700; color: #1a1a1a; }
  .topbar__link { color: #BF9F5A; font-size: 12px; }
  .sidebar-open-btn { display: none !important; }
  .sidebar {
    display: none;
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 0;
    width: 260px !important;
    z-index: 95;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }
  .sidebar.is-open { display: flex; }
  .sidebar.is-open ~ .sidebar-backdrop { display: block; }
  .chat__welcome-title { font-size: 24px; }
  .chat__welcome-text { font-size: 14px; }
  .chat__message { padding: 0 16px; }
  .chat__message--user .chat__message-content { max-width: 85%; }
  .chat__bottom { padding: 0 16px 16px; }
  .chat__input { font-size: 16px; }
  .chat__chip { font-size: 12px; padding: 7px 14px; }
  .chat__product-card { width: 132px; }
  .app { height: -webkit-fill-available; height: 100dvh; }
  .app__body { flex: 1; min-height: 0; overflow: hidden; }
  .chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .chat__messages { flex: 1; min-height: 0; overflow-y: auto; }
  .chat__bottom { flex-shrink: 0; }
}
