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

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #1a1a1a;
  --gold: #d4af37;
  --gold-light: #f4d35e;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);
  --border-color: rgba(212, 175, 55, 0.3);
  --message-bg: rgba(30, 30, 30, 0.8);
  --user-message-bg: rgba(212, 175, 55, 0.15);
  --font-serif: 'Playfair Display', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* Corner decorative images */
.corner-image {
  position: fixed;
  width: 280px;
  height: 200px;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  opacity: 0.4;
  z-index: 0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.corner-image::before {
  content: '';
  position: absolute;
  inset: -8px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  pointer-events: none;
}

.corner-top-left {
  top: 20px;
  left: 20px;
  background: linear-gradient(135deg, rgba(139, 115, 85, 0.3) 0%, rgba(42, 42, 42, 0.5) 100%);
  transform: rotate(-2deg);
}

.corner-top-right {
  top: 20px;
  right: 20px;
  background: linear-gradient(225deg, rgba(139, 115, 85, 0.3) 0%, rgba(42, 42, 42, 0.5) 100%);
  transform: rotate(2deg);
}

.corner-bottom-left {
  bottom: 20px;
  left: 20px;
  background: linear-gradient(45deg, rgba(139, 115, 85, 0.3) 0%, rgba(42, 42, 42, 0.5) 100%);
  transform: rotate(2deg);
}

.corner-bottom-right {
  bottom: 20px;
  right: 20px;
  background: linear-gradient(315deg, rgba(139, 115, 85, 0.3) 0%, rgba(42, 42, 42, 0.5) 100%);
  transform: rotate(-2deg);
}

/* Main container */
.chat-container {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

/* Header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 30px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-primary);
}

.logo-icon svg {
  width: 20px;
  height: 20px;
}

.header-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.back-link {
  color: var(--gold);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.3s ease;
}

.back-link:hover {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--gold);
}

/* Main chat area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gallery-name {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 400;
  text-align: center;
  color: var(--gold);
  margin: 0 0 40px 0;
  letter-spacing: 1px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* Welcome message */
.welcome-message {
  background: var(--message-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 30px;
  max-width: 700px;
  margin: 0 auto;
}

.welcome-text {
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 20px 0;
}

.welcome-subheading {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 12px 0;
}

.welcome-list {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.8;
  margin: 0 0 20px 0;
  padding-left: 20px;
}

.welcome-list li {
  margin-bottom: 8px;
}

.example-text {
  color: var(--gold-light);
  font-size: 14px;
  line-height: 1.6;
  margin: 20px 0 0 0;
  font-style: italic;
}

/* Chat messages */
.message {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: slideIn 0.3s ease;
}

.message--user {
  align-items: flex-end;
}

.message--assistant {
  align-items: flex-start;
}

.message-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0 12px;
}

.message-bubble {
  background: var(--message-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  max-width: 70%;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message--user .message-bubble {
  background: var(--user-message-bg);
  border-color: var(--gold);
  color: var(--gold-light);
}

.message--assistant .message-bubble {
  background: var(--message-bg);
}

.message--error .message-bubble {
  border-color: rgba(255, 99, 99, 0.5);
  background: rgba(255, 99, 99, 0.1);
  color: #ff9999;
}

/* Related artwork section */
.related-artwork {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.related-artwork-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.related-artwork-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.view-gallery-btn {
  background: var(--gold);
  color: var(--bg-primary);
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.view-gallery-btn:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
}

.artwork-thumbnails {
  display: flex;
  gap: 12px;
  overflow-x: auto;
}

.artwork-thumb {
  flex-shrink: 0;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
}

.artwork-thumb:hover {
  border-color: var(--gold);
  transform: scale(1.05);
}

.artwork-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Input container */
.chat-input-container {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 20px 0;
  border-top: 1px solid var(--border-color);
  margin-top: 20px;
}

.chat-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.3s ease;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input:focus {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.05);
}

.chat-submit {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  border: none;
  border-radius: 8px;
  color: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chat-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.chat-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-submit svg {
  width: 24px;
  height: 24px;
}

/* Loading state */
.message--loading .message-bubble::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.5s ease-in-out infinite;
}

/* Animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Responsive design */
@media (max-width: 768px) {
  .corner-image {
    width: 200px;
    height: 150px;
  }

  .chat-container {
    padding: 15px;
  }

  .gallery-name {
    font-size: 32px;
    margin-bottom: 30px;
  }

  .header-title {
    font-size: 14px;
  }

  .back-link {
    font-size: 12px;
    padding: 6px 12px;
  }

  .welcome-message {
    padding: 20px;
  }

  .message-bubble {
    max-width: 85%;
  }

  .chat-input-container {
    gap: 8px;
  }

  .chat-submit {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 480px) {
  .corner-image {
    width: 150px;
    height: 100px;
  }

  .gallery-name {
    font-size: 24px;
  }

  .message-bubble {
    max-width: 90%;
    padding: 12px 16px;
  }
}
