/* ==========================================================================
   Odystock Intelligent AI Chat Widget - Official Styles
   ========================================================================== */

:root {
  --ody-chat-bg: #07111f;
  --ody-chat-panel-bg: #0b1728;
  --ody-chat-header-bg: #07111f;
  --ody-chat-border: rgba(255, 255, 255, 0.12);
  --ody-chat-primary: #6366f1;
  --ody-chat-primary-hover: #4f46e5;
  --ody-chat-accent: #06b6d4;
  --ody-chat-text: #f8fafc;
  --ody-chat-text-muted: #94a3b8;
  --ody-chat-user-bubble: #4f46e5;
  --ody-chat-bot-bubble: #112238;
  --ody-chat-bot-bubble-border: rgba(255, 255, 255, 0.08);
  --ody-chat-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7), 0 0 25px rgba(99, 102, 241, 0.2);
  --ody-chat-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Floating Action Button */
.odystock-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--ody-chat-primary), #4338ca);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  font-family: var(--ody-chat-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  text-decoration: none;
}

.odystock-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.55);
  background: linear-gradient(135deg, #7174f8, var(--ody-chat-primary));
}

.odystock-chat-toggle:active {
  transform: translateY(0);
}

.odystock-chat-toggle:focus-visible {
  outline: 3px solid #818cf8;
  outline-offset: 3px;
}

.odystock-chat-toggle-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.odystock-chat-toggle-text {
  letter-spacing: -0.01em;
}

/* Chat Dialog Panel */
.odystock-chat-panel {
  position: fixed;
  bottom: 84px;
  right: 24px;
  z-index: 99999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 100px);
  background: var(--ody-chat-panel-bg);
  border: 1px solid var(--ody-chat-border);
  border-radius: 20px;
  box-shadow: var(--ody-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--ody-chat-font);
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}

.odystock-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

/* Chat Header */
.odystock-chat-header {
  background: var(--ody-chat-header-bg);
  border-bottom: 1px solid var(--ody-chat-border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.odystock-chat-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.odystock-chat-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--ody-chat-primary), var(--ody-chat-accent));
  color: #ffffff;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.odystock-chat-header-info {
  display: flex;
  flex-direction: column;
}

.odystock-chat-title {
  color: var(--ody-chat-text);
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.odystock-chat-subtitle {
  color: var(--ody-chat-text-muted);
  font-size: 12px;
  margin: 2px 0 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.odystock-chat-status-dot {
  width: 7px;
  height: 7px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
}

.odystock-chat-close-btn {
  background: transparent;
  border: none;
  color: var(--ody-chat-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.odystock-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ody-chat-text);
}

.odystock-chat-close-btn:focus-visible {
  outline: 2px solid var(--ody-chat-primary);
}

/* Chat Notice / Disclaimer */
.odystock-chat-disclaimer {
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 16px;
  font-size: 11px;
  color: var(--ody-chat-text-muted);
  line-height: 1.4;
  text-align: center;
  flex-shrink: 0;
}

.odystock-chat-disclaimer a {
  color: var(--ody-chat-accent);
  text-decoration: underline;
}

/* Messages Area */
.odystock-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

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

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

/* Message Bubble */
.odystock-msg {
  max-width: 85%;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 14px;
  word-break: break-word;
  animation: odyFadeSlide 0.2s ease forwards;
}

.odystock-msg-user {
  align-self: flex-end;
  background: var(--ody-chat-user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  white-space: pre-wrap;
}

.odystock-msg-bot {
  align-self: flex-start;
  background: var(--ody-chat-bot-bubble);
  color: var(--ody-chat-text);
  border: 1px solid var(--ody-chat-bot-bubble-border);
  border-bottom-left-radius: 4px;
  white-space: normal;
}

.odystock-bot-content p {
  margin: 0 0 8px 0;
}

.odystock-bot-content p:last-child {
  margin-bottom: 0;
}

.odystock-bot-content ul, .odystock-bot-content ol {
  margin: 6px 0 8px 0;
  padding-left: 18px;
}

.odystock-bot-content ul {
  list-style-type: disc;
}

.odystock-bot-content ol {
  list-style-type: decimal;
}

.odystock-bot-content li {
  margin-bottom: 4px;
  line-height: 1.45;
}

.odystock-bot-content li:last-child {
  margin-bottom: 0;
}

.odystock-bot-content strong {
  color: #ffffff;
  font-weight: 600;
}

.odystock-bot-content a {
  color: #38bdf8;
  text-decoration: underline;
  word-break: break-all;
}

.odystock-bot-content a:hover {
  color: #7dd3fc;
}

.odystock-msg-system {
  align-self: center;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
  font-size: 12px;
  max-width: 92%;
  text-align: center;
}

.odystock-msg-error {
  align-self: center;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 12px;
  max-width: 92%;
  text-align: center;
}

/* Typing Indicator */
.odystock-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--ody-chat-bot-bubble);
  border: 1px solid var(--ody-chat-bot-bubble-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.odystock-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--ody-chat-primary);
  border-radius: 50%;
  animation: odyBounce 1.4s infinite ease-in-out both;
}

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

/* Input Area */
.odystock-chat-input-box {
  background: var(--ody-chat-header-bg);
  border-top: 1px solid var(--ody-chat-border);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.odystock-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.odystock-chat-textarea {
  flex: 1;
  background: #0e1e33;
  color: var(--ody-chat-text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  min-height: 40px;
  max-height: 100px;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.odystock-chat-textarea:focus {
  outline: none;
  border-color: var(--ody-chat-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.odystock-chat-send-btn {
  width: 40px;
  height: 40px;
  background: var(--ody-chat-primary);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.odystock-chat-send-btn:hover:not(:disabled) {
  background: var(--ody-chat-primary-hover);
  transform: scale(1.04);
}

.odystock-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.odystock-chat-send-btn:focus-visible {
  outline: 2px solid #818cf8;
}

.odystock-chat-input-meta {
  display: flex;
  justify-content: flex-end;
  font-size: 11px;
  color: var(--ody-chat-text-muted);
}

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

@keyframes odyBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Mobile Responsiveness (100dvh with 100vh fallback) */
@media (max-width: 480px) {
  .odystock-chat-toggle {
    bottom: 16px;
    right: 16px;
    padding: 10px 16px;
    font-size: 13px;
  }

  .odystock-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
}