/* KSDC HelpBot - Official CSS Design System (Orange Theme) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700&display=swap');

:root {
  color-scheme: light;
  --primary-orange: #ea580c;
  --primary-hover: #c2410c;
  --secondary-orange: #f97316;
  --light-orange-bg: #fff7ed;
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --header-gradient: linear-gradient(135deg, #c2410c 0%, #ea580c 50%, #f97316 100%);
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(226, 232, 240, 0.8);
  --user-msg-bg: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  --bot-msg-bg: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
}

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

html,
body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: var(--text-dark);
  height: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
.app-header {
  background: var(--header-gradient);
  color: #ffffff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(234, 88, 12, 0.2);
  z-index: 10;
  flex-shrink: 0;
}

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

.logo-container {
  width: 44px;
  height: 44px;
  background: #ffffff;
  border-radius: 50%;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.title-area h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.badge-official {
  font-size: 0.65rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.subtitle {
  font-size: 0.75rem;
  color: #ffedd5;
  margin-top: 1px;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-clear {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

.btn-clear:hover {
  background: rgba(239, 68, 68, 0.85);
  border-color: rgba(239, 68, 68, 1);
  transform: translateY(-1px);
}

.btn-location {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

.btn-location:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* ── Mobile Responsive Overrides ── */
@media (max-width: 640px) {
  .app-header {
    padding: 8px 12px;
  }

  .header-brand {
    gap: 8px;
    min-width: 0;
    flex: 1;
  }

  .logo-container {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .logo-img {
    width: 24px;
    height: 24px;
  }

  .title-area h1 {
    font-size: 0.92rem;
  }

  .subtitle {
    font-size: 0.68rem;
  }

  .header-city {
    display: none;
  }

  .header-actions {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .btn-location,
  .btn-clear {
    padding: 6px 10px;
    font-size: 0.72rem;
    border-radius: 8px;
    gap: 4px;
  }

  .chat-container {
    padding: 12px 10px;
    gap: 12px;
  }

  .message-bubble {
    max-width: 90%;
    padding: 10px 14px;
    font-size: 0.88rem;
  }

  .input-footer {
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .input-form {
    gap: 8px;
    width: 100%;
  }

  .chat-input {
    font-size: 16px !important;
    /* Prevents iOS auto-zoom on focus */
    padding: 10px 42px 10px 14px;
    border-radius: 12px;
  }

  .btn-send {
    padding: 0 16px;
    font-size: 0.85rem;
    border-radius: 12px;
    white-space: nowrap;
  }

  .info-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
    border-radius: 16px;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-body {
    padding: 14px;
  }

  .map-container {
    height: 220px;
  }
}

/* ── Main Chat Area ── */
.chat-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px;
  width: 100%;
  max-width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.message-wrapper {
  display: flex;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}

.message-wrapper.user {
  justify-content: flex-end;
}

.message-wrapper.bot {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.6;
  position: relative;
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  animation: fadeIn 0.3s ease-out forwards;
}

/* Ensure ALL child elements inside message bubble break lines cleanly without clipping */
.message-bubble *,
.message-bubble p,
.message-bubble div,
.message-bubble span,
.message-bubble pre,
.message-bubble code,
.message-bubble blockquote {
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

.message-bubble pre,
.message-bubble code {
  white-space: pre-wrap !important;
  overflow-x: auto !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-wrapper.user .message-bubble {
  background: var(--user-msg-bg);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
}

.message-wrapper.bot .message-bubble {
  background: var(--bot-msg-bg);
  color: var(--text-dark);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
}

/* ── Formatted Content inside Bot Messages ── */
.message-bubble ul,
.message-bubble ol {
  margin-top: 8px;
  margin-bottom: 8px;
  padding-left: 20px;
}

.message-bubble li {
  margin-bottom: 6px;
}

.message-bubble p {
  margin-bottom: 8px;
}

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

.message-bubble strong {
  color: #0f172a;
  font-weight: 600;
}

.message-wrapper.user .message-bubble strong {
  color: #ffffff;
}

.message-bubble a {
  color: var(--primary-orange);
  font-weight: 600;
  text-decoration: underline;
  word-break: break-all;
}

.message-bubble a:hover {
  color: var(--primary-hover);
}

/* Audio TTS Button */
.tts-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s ease;
}

.tts-btn:hover {
  background: #fff7ed;
  color: var(--primary-orange);
  border-color: #fed7aa;
}

.tts-btn.speaking {
  background: #ffedd5;
  color: var(--primary-hover);
  border-color: #fdba74;
}

/* ── Quick Suggestion Chips ── */
.chips-container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 10px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.chips-container::-webkit-scrollbar {
  height: 4px;
}

.chips-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.chip-btn {
  white-space: nowrap;
  background: #ffffff;
  color: var(--primary-hover);
  border: 1px solid #fed7aa;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.chip-btn:hover {
  background: #fff7ed;
  border-color: var(--secondary-orange);
  transform: translateY(-1px);
}

/* ── Footer Input Area ── */
.input-footer {
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

.input-form {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}

.input-input-group {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.chat-input {
  width: 100%;
  padding: 12px 48px 12px 18px;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background-color: #ffffff !important;
  color: #1e293b !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input::placeholder {
  color: #64748b !important;
  opacity: 1;
}

.chat-input:focus {
  border-color: var(--secondary-orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.btn-mic {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 1.15rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-mic:hover {
  background: #f1f5f9;
  transform: scale(1.08);
}

.btn-mic.listening {
  background: #ef4444;
  color: white;
  animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.btn-send {
  background: var(--user-msg-bg);
  color: #ffffff;
  border: none;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
}

.btn-send:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Typing Indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

/* ── Callback Card ── */
.callback-card {
  margin-top: 12px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid #fed7aa;
  border-radius: 14px;
  padding: 16px;
}

.callback-card h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-hover);
  margin-bottom: 4px;
}

.callback-card p {
  font-size: 0.78rem;
  color: var(--primary-orange);
  margin-bottom: 12px;
}

.callback-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.callback-form input {
  padding: 8px 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  font-size: 0.8rem;
  outline: none;
}

.callback-form button {
  background: var(--primary-orange);
  color: #ffffff;
  padding: 9px;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}

.callback-form button:hover {
  background: var(--primary-hover);
}

.callback-success {
  padding: 12px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  border-radius: 10px;
  font-size: 0.82rem;
  text-align: center;
  font-weight: 600;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #ffffff;
  border-radius: 20px;
  width: 90%;
  max-width: 650px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  animation: modalSlideUp 0.3s ease-out forwards;
}

@keyframes modalSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 16px 20px;
  background: var(--header-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.3rem;
  cursor: pointer;
  opacity: 0.8;
}

.modal-close:hover {
  opacity: 1;
}

.modal-body {
  padding: 20px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.info-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 12px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.info-item label {
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #64748b;
  display: block;
  margin-bottom: 2px;
}

.map-container {
  width: 100%;
  height: 280px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.map-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
}