:root {
  --bg: #f5f2ed;
  --surface: #ffffff;
  --surface-alt: #faf8f5;
  --border: #e8e2d9;
  --text: #1a1714;
  --text-muted: #8a8279;
  --text-light: #b0a89e;
  --accent: #b8282e;
  --accent-soft: #f9e8e8;
  --accent-hover: #961f24;
  --bot-bg: #ffffff;
  --user-bg: #1a1714;
  --user-text: #faf8f5;
  --shadow: 0 1px 3px rgba(26,23,20,0.06), 0 4px 12px rgba(26,23,20,0.04);
  --shadow-lg: 0 4px 24px rgba(26,23,20,0.10);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-msg: 18px;
  --chat-bg-image: url("assets/BG_Imag.jpg");
  --chat-bg-overlay-top: rgba(245, 242, 237, 0.78);
  --chat-bg-overlay-bottom: rgba(245, 242, 237, 0.92);
  --login-bg-image: url("assets/BG_Login.jpg");
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
}

#login-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(245,242,237,0.34) 0%, rgba(245,242,237,0.58) 100%),
    var(--login-bg-image) center center / cover no-repeat,
    var(--bg);
  animation: fadeIn 0.5s ease;
}

#login-screen.is-hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.login-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(232, 226, 217, 0.86);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 44px 36px 36px;
  position: relative;
  animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.login-logo img {
  height: 44px;
}

.login-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.login-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-lang {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  outline: none;
}

.login-lang:focus {
  border-color: var(--accent);
}

.login-step {
  display: none;
}

.login-step.active {
  display: block;
  animation: stepIn 0.3s ease;
}

@keyframes stepIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.field-group {
  margin-bottom: 16px;
}

.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.field-group input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-alt);
  outline: none;
  transition: border-color 0.15s;
}

.field-group input:focus {
  border-color: var(--accent);
}

.field-group input::placeholder {
  color: var(--text-light);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  background: var(--border);
  cursor: not-allowed;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  margin-top: 14px;
  display: inline-block;
}

.btn-link:hover {
  text-decoration: underline;
}

.login-error {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  display: none;
  line-height: 1.45;
}

.login-error.visible {
  display: block;
  animation: stepIn 0.2s ease;
}

.login-success {
  background: #f3f4f6;
  color: #4b5563;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  display: none;
  line-height: 1.45;
}

.login-success.visible {
  display: block;
  animation: stepIn 0.2s ease;
}

.otp-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
}

.otp-inputs input {
  width: 46px;
  height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.otp-inputs input:focus {
  border-color: var(--accent);
}

.step-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 18px;
  line-height: 1.5;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-light);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.field-row {
  display: flex;
  gap: 10px;
}

.field-row .field-group {
  flex: 1;
}

.privacy-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 12px;
}

.privacy-check input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.privacy-check label {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.privacy-check label a {
  color: var(--accent);
  text-decoration: underline;
}

.privacy-check label a:hover {
  color: var(--accent-hover);
}

#chat-screen {
  display: none;
  position: relative;
  height: 100dvh;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  animation: fadeIn 0.4s ease;
}

#chat-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      180deg,
      rgba(245, 242, 237, 0.16) 0%,
      rgba(245, 242, 237, 0.42) 48%,
      rgba(245, 242, 237, 0.76) 100%
    ),
    var(--chat-bg-image) center center / cover no-repeat,
    var(--bg);
  z-index: 0;
  pointer-events: none;
}

#chat-screen.active {
  display: flex;
}

#chat-screen > .header,
#chat-screen > .chat-container,
#chat-screen > .chat-input-bar,
#chat-screen > .footer-brand {
  position: relative;
  z-index: 1;
}

.header {
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
}

.header-logo {
  height: 30px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-logo img {
  height: 100%;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  justify-self: center;
}

.header-subtitle {
  display: none;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34a853;
  flex-shrink: 0;
}

.lang-select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 120px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
  background: transparent;
}

.chat-container::-webkit-scrollbar {
  width: 5px;
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.message-row {
  display: flex;
  gap: 10px;
  max-width: 580px;
  animation: msgIn 0.3s cubic-bezier(0.22,1,0.36,1);
}

.message-row.bot {
  align-self: flex-start;
}

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  margin-top: 2px;
}

.bot .avatar {
  background: var(--accent-soft);
  color: var(--accent);
  overflow: hidden;
  padding: 4px;
}

.bot .avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.user .avatar {
  background: var(--user-bg);
  color: var(--user-text);
}

.bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: var(--radius-msg);
}

.bot .bubble {
  background: rgba(255, 255, 255, 0.94);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 6px;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  animation: msgIn 0.35s cubic-bezier(0.22,1,0.36,1);
  align-self: flex-start;
  padding-left: 42px;
}

.quick-reply {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.quick-reply-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  object-fit: contain;
}

.quick-reply span {
  min-width: 0;
}

.quick-reply:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.typing-indicator {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 580px;
  animation: msgIn 0.25s ease;
}

.typing-dots {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  border-radius: var(--radius-msg);
  border-bottom-left-radius: 6px;
  padding: 14px 20px;
  display: flex;
  gap: 5px;
  align-items: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.4;
  animation: blink 1.4s infinite both;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,80%,100% { opacity: 0.2; transform: scale(0.85); }
  40% { opacity: 0.8; transform: scale(1); }
}

.download-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}

.download-link:hover {
  background: #f0d0d0;
}

.footer-brand {
  text-align: center;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-light);
  background: transparent;
  flex-shrink: 0;
  z-index: 5;
}

.chat-input-bar {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 680px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  padding: 8px 8px 8px 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 20;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.chat-input-bar input {
  flex: 1;
  border: none;
  border-radius: 24px;
  padding: 10px 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  outline: none;
  min-width: 0;
}

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

.chat-input-bar button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.chat-input-bar button:hover {
  background: var(--accent-hover);
}

.chat-input-bar button svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  .topbar,
  .header,
  .app-header {
    height: auto;
    min-height: 92px;
    padding: 14px 18px;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
  }

  .brand,
  .brand-area,
  .logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .brand img,
  .logo img,
  .header-logo {
    width: 145px;
    max-width: 145px;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
  }

  .brand-title,
  .portal-title,
  .client-portal-title {
    font-size: 22px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions,
  .topbar-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
  }

  .language-select,
  select {
    max-width: 140px;
    height: 44px;
    font-size: 16px;
  }

  .logout-btn,
  .logout-button {
    height: 44px;
    padding: 0 16px;
    font-size: 16px;
  }

  .chat-shell,
  .main,
  .app-main,
  .chat-container {
    width: 100%;
    max-width: 100%;
    padding: 28px 20px 24px;
    box-sizing: border-box;
  }

  .welcome-card,
  .bot-message,
  .message-bubble {
    max-width: calc(100vw - 80px);
    font-size: 21px;
    line-height: 1.45;
    padding: 22px 26px;
  }

  .quick-actions,
  .suggestions,
  .action-list {
    width: 100%;
    max-width: 100%;
    gap: 14px;
  }

  .quick-action,
  .suggestion-button,
  .action-button {
    width: fit-content;
    max-width: calc(100vw - 80px);
    min-height: 72px;
    padding: 0 28px;
    font-size: 21px;
    border-radius: 999px;
  }

  .quick-action svg,
  .suggestion-button svg,
  .action-button svg {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .composer,
  .chat-input-wrapper,
  .input-bar {
    width: calc(100% - 40px);
    left: 20px;
    right: 20px;
    bottom: 24px;
    box-sizing: border-box;
  }

  .composer input,
  .chat-input-wrapper input,
  .input-bar input {
    font-size: 20px;
    min-width: 0;
  }

  .send-button {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
  }

  .footer,
  .app-footer {
    font-size: 15px;
    padding-bottom: 16px;
  }
}

@media (max-width: 480px) {
  .topbar,
  .header,
  .app-header {
    padding: 12px 14px;
    gap: 10px;
  }

  .brand img,
  .logo img,
  .header-logo {
    width: 120px;
    max-width: 120px;
  }

  .brand-title,
  .portal-title,
  .client-portal-title {
    font-size: 19px;
  }

  .language-select,
  select {
    max-width: 115px;
    height: 40px;
    font-size: 15px;
  }

  .logout-btn,
  .logout-button {
    height: 40px;
    padding: 0 12px;
    font-size: 15px;
  }

  .welcome-card,
  .bot-message,
  .message-bubble {
    max-width: calc(100vw - 70px);
    font-size: 18px;
    padding: 18px 22px;
  }

  .quick-action,
  .suggestion-button,
  .action-button {
    max-width: calc(100vw - 70px);
    min-height: 62px;
    padding: 0 22px;
    font-size: 18px;
  }

  .quick-action svg,
  .suggestion-button svg,
  .action-button svg {
    width: 28px;
    height: 28px;
  }

  .composer,
  .chat-input-wrapper,
  .input-bar {
    width: calc(100% - 28px);
    left: 14px;
    right: 14px;
  }

  .send-button {
    width: 62px;
    height: 62px;
  }
}

@media (max-width: 640px) {
  .app-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    padding: 12px 14px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .header-logo,
  .app-header img {
    width: 128px !important;
    max-width: 128px !important;
    height: auto !important;
    object-fit: contain !important;
    flex-shrink: 0 !important;
  }

  .header-title {
    display: none !important;
  }

  .header-controls,
  .header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
  }

  .header-controls select,
  .header-actions select,
  #languageSelect,
  select {
    max-width: 112px !important;
    height: 40px !important;
    font-size: 15px !important;
  }

  .header-controls button,
  .header-actions button,
  #logoutBtn,
  button.logout {
    height: 40px !important;
    padding: 0 12px !important;
    font-size: 15px !important;
    white-space: nowrap !important;
  }
}

/* Mobile header layout previously embedded in index.html. Kept here so CSP can
   reject inline styles without changing the responsive presentation. */
@media (max-width: 700px) {
  .header-title {
    display: none !important;
  }

  .app-header,
  .header,
  header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    height: auto !important;
    min-height: 125px !important;
    padding: 14px 12px 12px !important;
    gap: 10px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    position: relative !important;
  }

  .app-header img,
  .header img,
  header img,
  .header-logo,
  .logo {
    display: block !important;
    width: auto !important;
    max-width: 230px !important;
    height: auto !important;
    max-height: 58px !important;
    object-fit: contain !important;
    position: static !important;
    transform: none !important;
    margin: 0 auto !important;
    flex: 0 0 auto !important;
  }

  .header-controls,
  .header-actions,
  .app-header > div:last-child {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    position: static !important;
    transform: none !important;
    margin: 0 !important;
    width: auto !important;
    flex: 0 0 auto !important;
  }

  select,
  .language-select {
    height: 42px !important;
    max-width: 135px !important;
    font-size: 16px !important;
    position: static !important;
    transform: none !important;
  }

  button,
  .logout-btn,
  .logout-button {
    height: 42px !important;
    padding: 0 14px !important;
    font-size: 16px !important;
    white-space: nowrap !important;
    position: static !important;
    transform: none !important;
  }
}
