/* Chat Widget CSS extracted from Chat_Bot_Widget.php */
/* Prevent horizontal overflow inside widget */
.chat-container, .chat-container * { box-sizing: border-box; }
.chat-container, .chat-body { overflow-x: hidden !important; }

/* When chat is open, prevent the page from acquiring horizontal scroll */
body.chat-open { overflow-x: hidden !important; }

.chat-icon {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  right: 1rem;
  width: 60px;
  height: 60px;
  background: linear-gradient(145deg, #1d4ed8 0%, #3b82f6 55%, #6366f1 100%);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.25), 0 4px 10px rgba(15, 23, 42, 0.15);
  z-index: 1200;
  font-size: 1.45rem;
  transition: all 0.28s cubic-bezier(.4,0,.2,1);
  animation: float 4s ease-in-out infinite;
  border: 1px solid rgba(255, 255, 255, 0.45);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  touch-action: manipulation;
}
.chat-icon:hover { transform: translateY(-2px) scale(1.06); box-shadow: 0 18px 34px rgba(37, 99, 235, 0.33), 0 8px 18px rgba(15, 23, 42, 0.18); }
.chat-icon.has-unread::after { content: ''; position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; background: #ef4444; border-radius: 50%; border: 2px solid white; animation: pulse 2s infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.8; } 100% { transform: scale(1); opacity: 1; } }

.chat-container { position: fixed; bottom: max(1rem, env(safe-area-inset-bottom)); right: 1rem; width: min(390px, calc(100vw - 2rem)); max-width: calc(100% - 2rem); height: min(620px, calc(100vh - 5.5rem)); max-height: calc(100vh - 5.5rem); background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%); border-radius: 20px; box-shadow: 0 24px 52px rgba(15, 23, 42, 0.22), 0 8px 22px rgba(37, 99, 235, 0.12); display: none; flex-direction: column; z-index: 1250; overflow: hidden; border: 1px solid rgba(148, 163, 184, 0.35); transition: all 0.35s cubic-bezier(.4,0,.2,1); outline: none; }
.chat-container.visible { display: flex; animation: slideUp 0.4s cubic-bezier(.4,0,.2,1); }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.chat-header { padding: 1rem 1.1rem; background: linear-gradient(120deg, #0f2d77 0%, #1d4ed8 55%, #2563eb 100%); color: white; border-radius: 20px 20px 0 0; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 1rem; box-shadow: inset 0 -1px 0 rgba(255,255,255,0.2); position: relative; }
.chat-header > span:first-child { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; letter-spacing: 0.01em; }
.chat-header > span:first-child::before { display: none; }
.chat-header .close-btn { cursor: pointer; font-size: 1.5rem; opacity: 0.95; transition: all 0.2s; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; }
.chat-header .close-btn:focus { outline: 2px solid #fff; outline-offset: 2px; }
.chat-header .close-btn:hover { opacity: 1; background: rgba(255,255,255,0.22); }

.chat-body { flex: 1; padding: 0.95rem 0.85rem 1rem 0.85rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.85rem; background: radial-gradient(circle at 0% 0%, rgba(59,130,246,0.06), transparent 45%), radial-gradient(circle at 100% 100%, rgba(99,102,241,0.06), transparent 42%), #f8fafc; scroll-behavior: smooth; }
.chat-body::-webkit-scrollbar { width: 8px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.5); border-radius: 999px; }

.message { max-width: 88%; padding: 0.8rem 0.9rem; border-radius: 16px; font-size: 0.94rem; line-height: 1.5; animation: fadeIn 0.3s; position: relative; box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06); }
.bot-message { background: #ffffff; border: 1px solid #e2e8f0; align-self: flex-start; color: #334155; border-bottom-left-radius: 6px; }
.user-message { background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 58%, #4f46e5 100%); color: white; align-self: flex-end; border-bottom-right-radius: 6px; }
.message-time { font-size: 0.75rem; opacity: 0.7; margin-top: 0.5rem; text-align: right; }
.typing-indicator { display: flex; gap: 0.5rem; padding: 0.75rem 0.9rem; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 16px; width: fit-content; margin: 0.5rem 0; }
.typing-dot { width: 8px; height: 8px; background: #64748b; border-radius: 50%; animation: typing 1.4s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.chat-input { padding: 0.75rem; background: rgba(255,255,255,0.95); border-top: 1px solid #e2e8f0; backdrop-filter: blur(8px); display: flex; gap: 0.5rem; align-items: center; flex-wrap: nowrap; }
.chat-input input { flex: 1 1 0%; min-width: 0; padding: 0.75rem 0.95rem; border: 1px solid #cbd5e1; border-radius: 14px; font-size: 0.95rem; transition: all 0.2s; }
.chat-input input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.chat-input button { width: 42px; height: 42px; padding: 0; background: #2563eb; color: white; border: none; border-radius: 12px; cursor: pointer; transition: all 0.2s; font-size: 1rem; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.chat-input button#emojiBtn { background: #eef2ff; color: #1d4ed8; font-size: 1rem; }
.chat-input button:last-child { background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%); }
.chat-input button:hover, .register-btn:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.13); }
.chat-input button:active { transform: translateY(0); }
.register-btn { background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%); color: white; padding: 0.85rem 1.5rem; border: none; border-radius: 14px; cursor: pointer; font-weight: 500; margin-top: 1rem; transition: all 0.2s; width: 100%; font-size: 0.98rem; letter-spacing: 0.01em; }
.register-btn:focus { outline: 2px solid #2563eb; outline-offset: 2px; }
.input-group { margin: 1rem 0; position: relative; }
.float-input { width: 100%; padding: 0.75rem 1rem; border: 2px solid #e0e7ef; border-radius: 12px; font-size: 1rem; background: #fff; transition: all 0.2s; }
.float-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.float-label { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); background: #fff; padding: 0 0.5rem; color: #64748b; transition: all 0.2s; pointer-events: none; }
.float-input:focus ~ .float-label, .float-input:not(:placeholder-shown) ~ .float-label { top: 0; font-size: 0.75rem; color: #2563eb; transform: translateY(-50%) scale(0.9); }
.file-upload { display: none; }
.file-upload-label { width: 42px; height: 42px; padding: 0; background: #f1f5f9; color: #475569; border-radius: 12px; cursor: pointer; transition: all 0.2s; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.file-upload-label:hover { background: #e2e8f0; color: #475569; }

/* --- Mobile Redesign --- */
@media (max-width: 1024px) and (min-width: 601px) {
  .chat-container { width: min(420px, calc(100vw - 2.5rem)); height: min(650px, calc(100vh - 6rem)); }
  .chat-body { padding: 1rem; }
  .animated-menu { gap: 0.8rem; grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 600px) {
  .chat-icon { width: 54px !important; height: 54px !important; right: 0.85rem !important; bottom: max(0.85rem, env(safe-area-inset-bottom)) !important; font-size: 1.25rem !important; }
  .chat-container { width: 95vw !important; max-width: 95vw !important; height: min(76vh, 620px) !important; max-height: calc(100vh - 1.7rem) !important; border-radius: 18px !important; right: 2.5vw !important; left: 2.5vw !important; bottom: max(0.85rem, env(safe-area-inset-bottom)) !important; top: auto !important; box-shadow: 0 14px 36px rgba(0,0,0,0.22); border: 1px solid rgba(148, 163, 184, 0.35); display: none; flex-direction: column; z-index: 1100; overflow: hidden; transition: all 0.35s cubic-bezier(.4,0,.2,1); max-width: calc(100vw - 4vw) !important; }
  .chat-container.visible { display: flex; animation: slideUp 0.4s cubic-bezier(.4,0,.2,1); }
  .chat-header { border-radius: 18px 18px 0 0 !important; padding-top: 1.35rem; padding-bottom: 0.95rem; position: relative; }
  .chat-header::before { content: ''; display: block; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 38px; height: 5px; background: #e0e7ef; border-radius: 3px; margin-bottom: 8px; }
  .chat-body { padding: 0.8rem 0.65rem 0.8rem 0.65rem; font-size: 0.95em; }
  .animated-menu { grid-template-columns: 1fr; gap: 0.6rem }
  .message { max-width: 93%; font-size: 0.92rem; }
  .chat-input { padding: 0.62rem; gap: 0.45rem; }
  .chat-input input { font-size: 0.93rem; padding: 0.68rem 0.82rem; }
  .register-btn { font-size: 0.95rem; padding: 0.76rem 1rem; }
  .animated-card { padding: 1rem 0.8rem; border-radius: 13px; }
}

.fade-in { animation: fadeIn 0.5s; }
.fade-out { animation: fadeOut 0.35s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px);} to { opacity: 1; transform: none; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Robust compact menu: responsive grid and stable card layout */
.animated-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 0.6rem; align-items: start; }
.menu-icon { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #eef6ff 0%, #eef8ff 100%); color: #1d4ed8; display: inline-flex; align-items: center; justify-content: center; margin-right: 0.65rem; font-size: 1rem; flex-shrink: 0; flex: 0 0 auto; }
.animated-card { background: #ffffff; border-radius: 12px; box-shadow: 0 6px 14px rgba(15, 23, 42, 0.05); border: 1px solid #e6eef8; padding: 0.5rem 0.6rem; display: flex; align-items: center; gap: 0.6rem; cursor: pointer; transition: box-shadow .18s, transform .18s, border-color .18s; min-height: 72px; width: 100%; min-width: 0; max-width: 100%; overflow: hidden; }
.animated-card .menu-text { display:flex;flex-direction:column;min-width:0;overflow:hidden;flex:1 1 0; }
.menu-text h4 { color: #0f172a; font-size: 0.88rem; line-height: 1.08; margin: 0; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; max-height: 2.4em; }
.menu-text p { color: #6b7280; font-size: 0.75rem; margin: 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.animated-card:hover { border-color: #cfe5ff; box-shadow: 0 10px 24px rgba(37,99,235,0.08); transform: translateY(-3px); }

/* Ensure inputs don't force horizontal scroll */
.chat-input input, .float-input { min-width: 0; }
.chat-menu-flat { max-width: 100% !important; width: 100% !important; align-self: stretch !important; background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0.15rem 0.1rem 0.2rem 0.1rem !important; border-radius: 0 !important; }
.loading-spinner { display: flex; justify-content: center; align-items: center; height: 120px; }
.loading-spinner .dot { width: 12px; height: 12px; margin: 0 6px; border-radius: 50%; background: #2563eb; display: inline-block; animation: bounce 1s infinite alternate; }
.loading-spinner .dot:nth-child(2) { animation-delay: 0.2s; }
.loading-spinner .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { to { transform: translateY(-16px); opacity: 0.5; } }
.chatbot-toast{position:fixed;bottom:32px;left:50%;transform:translateX(-50%);background:#2563eb;color:#fff;padding:0.7rem 1.5rem;border-radius:8px;font-size:1rem;opacity:0;pointer-events:none;z-index:9999;transition:opacity .4s, bottom .4s;}.chatbot-toast.show{opacity:1;bottom:56px;}
/* Enhanced bot answer styling */
.enhanced-bot-answer { background: #f8fbff; border-radius: 12px; padding: 12px 13px; margin: 4px 0; font-size: 1em; line-height: 1.6; color: #222; box-shadow: none; white-space: pre-line; border: 1px solid #e2e8f0; }
.enhanced-bot-answer b { color: #2a7be4; }
.enhanced-bot-answer ul { margin: 10px 0 10px 20px; padding: 0; }
.bot-heading { color: #2563eb; font-weight: bold; font-size: 1.08em; margin: 12px 0 6px 0; display: block; }
