*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f1eb;
  --surface: #ffffff;
  --primary: #4a5a47;
  --primary-light: #8b9d83;
  --accent: #b85c42;
  --accent-hover: #a04e38;
  --text: #1f2937;
  --text-secondary: #5b6b7c;
  --text-muted: #9ca3af;
  --border: #e5e1db;
  --border-light: #f0ece6;
  --user-bg: #4a5a47;
  --user-text: #ffffff;
  --assistant-bg: #ffffff;
  --assistant-border: #e5e1db;
  --chip-bg: #f0ece6;
  --chip-text: #4a5a47;
  --chip-hover: #e5dfd7;
  --chip-border: #d5cfc7;
  --danger: #b91c1c;
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(31, 41, 55, 0.06);
  --shadow: 0 4px 12px rgba(31, 41, 55, 0.08);
  --shadow-lg: 0 18px 40px rgba(31, 41, 55, 0.12);
}

html, body {
  height: 100%;
  font-family: "Arial", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

.concierge-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.concierge-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  height: min(88vh, 780px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
}

/* --- Header --- */
.concierge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.concierge-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.concierge-header .subtitle {
  font-size: 0.78rem;
  opacity: 0.8;
  margin-top: 2px;
  font-weight: 400;
}

.header-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.header-icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.header-icon-btn.active {
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary);
}

.lang-toggle {
  display: inline-flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  padding: 3px;
  border-radius: 999px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.lang-btn.active {
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary);
}

.lang-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* --- Panel overlays (tips, map, photos) --- */
.panel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(31, 41, 55, 0.4);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.panel-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.panel-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--chip-bg);
  color: var(--text-secondary);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}

.panel-close:hover {
  background: var(--chip-hover);
  color: var(--text);
}

.tips-list {
  list-style: none;
  padding: 12px 20px 20px;
  margin: 0;
}

.tips-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
}

.tips-list li:last-child {
  border-bottom: none;
}

.map-container {
  padding: 16px 20px 20px;
}

.map-image {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.map-caption {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 10px;
  text-align: center;
  line-height: 1.4;
}

.photos-links {
  padding: 16px 20px 20px;
}

.photos-links p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.photo-link-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.photo-link-btn:hover {
  background: var(--chip-hover);
  border-color: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* --- Chat body --- */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
  scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* --- Messages --- */
.message {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msgIn 0.25s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.assistant {
  align-self: flex-start;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.assistant .avatar {
  background: var(--primary);
  color: #fff;
}

.message.user .avatar {
  background: var(--accent);
  color: #fff;
}

.message-content {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
  word-break: break-word;
}

.message-content p {
  margin: 0 0 0.6em;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul {
  margin: 0.4em 0 0.6em;
  padding-left: 1.3em;
  list-style: disc;
}

.message-content ul:last-child {
  margin-bottom: 0;
}

.message-content li {
  margin-bottom: 0.25em;
}

.message-content li:last-child {
  margin-bottom: 0;
}

.message.assistant .message-content {
  background: var(--assistant-bg);
  color: var(--text);
  border: 1px solid var(--assistant-border);
  border-top-left-radius: 4px;
}

.message.user .message-content {
  background: var(--user-bg);
  color: var(--user-text);
  border-top-right-radius: 4px;
}

.message-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message.user .message-content a {
  color: #f0cfc7;
}

.chat-qr-img {
  display: block;
  max-width: 180px;
  height: auto;
  margin: 8px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
}

.chat-pin {
  display: inline;
  text-decoration: none;
  font-size: 1.05em;
  vertical-align: middle;
  margin-right: 2px;
  cursor: pointer;
  transition: transform 0.15s;
}

.chat-pin:hover {
  transform: scale(1.25);
}

/* --- Typing indicator --- */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* --- Suggestions toggle --- */
.suggestions-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 0 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.suggestions-toggle:hover {
  color: var(--primary);
}

.suggestions-toggle .toggle-arrow {
  transition: transform 0.2s ease;
}

.suggestions-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}

/* --- Suggestion chips --- */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0 4px;
  overflow: visible;
}

.suggestions[hidden] {
  display: none;
}

.chip {
  background: var(--chip-bg);
  color: var(--chip-text);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chip:hover:not(:disabled) {
  background: var(--chip-hover);
  border-color: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.chip:active:not(:disabled) {
  transform: scale(0.97);
}

.chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* --- Footer / Input --- */
.chat-footer {
  padding: 16px 24px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#chatInput {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.92rem;
  font-family: inherit;
  line-height: 1.45;
  resize: none;
  outline: none;
  max-height: 120px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#chatInput:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(139, 157, 131, 0.2);
}

#chatInput::placeholder {
  color: var(--text-muted);
}

#sendBtn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

#sendBtn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

#sendBtn:not(:disabled):hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.footer-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
}

.reset-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 14px;
  border-radius: 999px;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.reset-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(185, 28, 28, 0.04);
}

.disclaimer {
  font-size: 0.66rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  line-height: 1.4;
  margin: 0;
  text-align: right;
}

/* --- Error messages --- */
.error-message .message-content {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .concierge-wrapper {
    padding: 0;
    align-items: stretch;
  }

  .concierge-card {
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }

  .concierge-header {
    padding: 14px 16px;
  }

  .concierge-header h1 {
    font-size: 1.05rem;
  }

  .chat-body {
    padding: 16px;
    gap: 12px;
  }

  .message {
    max-width: 92%;
  }

  .chat-footer {
    padding: 12px 16px 16px;
  }

  .suggestions {
    gap: 5px;
  }

  .chip {
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  .footer-meta {
    flex-direction: column-reverse;
    align-items: center;
    gap: 6px;
  }

  .disclaimer {
    text-align: center;
    font-size: 0.62rem;
  }

  .panel-overlay {
    padding: 12px;
  }

  .panel-content {
    max-height: 85vh;
  }

  .header-icon-btn {
    width: 30px;
    height: 30px;
  }

  .header-icon-btn svg {
    width: 15px;
    height: 15px;
  }
}

/* --- Widget / iframe mode --- */
@media (max-height: 500px) {
  .concierge-card {
    height: 100vh;
    border-radius: 0;
  }
}

body.widget-mode .concierge-wrapper {
  padding: 0;
  min-height: 100%;
}

body.widget-mode .concierge-card {
  height: 100vh;
  max-width: 100%;
  border-radius: 0;
  box-shadow: none;
}

/* Fullscreen image lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-body {
  width: 100%;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: pinch-zoom;
}
