/* ==========================================================================
   iBatyr AI Support Widget - Modern Premium Styles
   ========================================================================== */

:root {
  --ib-orange: #e6642d;
  --ib-orange-hover: #cf5626;
  --ib-orange-light: #fff2ed;
  --ib-dark: #1e242b;
  --ib-dark-surface: #262d35;
  --ib-gray-50: #f8fafc;
  --ib-gray-100: #f1f5f9;
  --ib-gray-200: #e2e8f0;
  --ib-gray-300: #cbd5e1;
  --ib-gray-600: #475569;
  --ib-gray-700: #334155;
  --ib-gray-900: #0f172a;
  --ib-shadow-lg: 0 20px 35px -5px rgba(0, 0, 0, 0.18), 0 10px 15px -5px rgba(0, 0, 0, 0.08);
  --ib-radius-xl: 18px;
  --ib-radius-md: 10px;
}

/* Floating Launcher Button */
.ibatyr-chat-launcher {
  position: fixed;
  bottom: 26px;
  right: 26px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ib-orange), #ff7e47);
  box-shadow: 0 8px 24px rgba(230, 100, 45, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99999;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.ibatyr-chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(230, 100, 45, 0.55);
}

.ibatyr-chat-launcher svg {
  width: 30px;
  height: 30px;
  fill: #ffffff;
  transition: transform 0.3s ease;
}

.ibatyr-chat-launcher.active svg {
  transform: rotate(90deg);
}

/* Pulse animation on launcher */
.ibatyr-chat-launcher::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--ib-orange);
  opacity: 0;
  animation: ibatyr-pulse 2.8s infinite;
}

@keyframes ibatyr-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* Chat Main Window */
.ibatyr-chat-window {
  position: fixed;
  bottom: 100px;
  right: 26px;
  width: 390px;
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: var(--ib-radius-xl);
  box-shadow: var(--ib-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  border: 1px solid var(--ib-gray-200);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: "Inter", "Roboto", -apple-system, BlinkMacSystemFont, sans-serif;
}

.ibatyr-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.ibatyr-chat-header {
  background: linear-gradient(135deg, var(--ib-dark), var(--ib-dark-surface));
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--ib-orange);
}

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

.ibatyr-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  flex-shrink: 0;
}

.ibatyr-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.ibatyr-header-info span {
  font-size: 11px;
  color: var(--ib-gray-300);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ibatyr-header-actions {
  display: flex;
  gap: 6px;
}

.ibatyr-btn-icon {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.ibatyr-btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Chat Body / Messages Container */
.ibatyr-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--ib-gray-50);
}

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

.ibatyr-chat-body::-webkit-scrollbar-thumb {
  background: var(--ib-gray-300);
  border-radius: 4px;
}

/* Message items */
.ibatyr-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  font-size: 13.5px;
  line-height: 1.5;
  animation: ibatyr-msg-fade 0.25s ease forwards;
}

@keyframes ibatyr-msg-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ibatyr-msg.user {
  align-self: flex-end;
}

.ibatyr-msg.bot {
  align-self: flex-start;
}

.ibatyr-msg-bubble {
  padding: 12px 15px;
  border-radius: var(--ib-radius-md);
  position: relative;
  word-wrap: break-word;
}

.ibatyr-msg.user .ibatyr-msg-bubble {
  background: linear-gradient(135deg, var(--ib-orange), var(--ib-orange-hover));
  color: #ffffff;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(230, 100, 45, 0.2);
}

.ibatyr-msg.bot .ibatyr-msg-bubble {
  background: #ffffff;
  color: var(--ib-gray-900);
  border: 1px solid var(--ib-gray-200);
  border-bottom-left-radius: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.ibatyr-msg-bubble strong {
  color: inherit;
  font-weight: 600;
}

.ibatyr-msg-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}

.ibatyr-msg-bubble pre {
  background: #1e242b;
  color: #e2e8f0;
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 12px;
}

.ibatyr-msg-bubble ul, .ibatyr-msg-bubble ol {
  margin: 6px 0 6px 18px;
  padding: 0;
}

.ibatyr-msg-time {
  font-size: 10px;
  color: var(--ib-gray-600);
  margin-top: 4px;
  align-self: flex-end;
}

/* Sources Badge in Bot Message */
.ibatyr-sources-box {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--ib-gray-200);
  font-size: 11.5px;
  color: var(--ib-gray-600);
}

.ibatyr-sources-box span {
  display: inline-block;
  background: var(--ib-orange-light);
  color: var(--ib-orange-hover);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  margin-top: 3px;
}

/* Quick Suggestion Chips & Groups */
.ibatyr-welcome-suggestions {
  display: flex;
  flex-direction: column;
}

.ibatyr-chip-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--ib-gray-600);
  margin: 10px 0 4px;
}

.ibatyr-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0;
}

.ibatyr-chip {
  background: #ffffff;
  border: 1px solid var(--ib-gray-300);
  color: var(--ib-gray-700);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.3;
}

.ibatyr-chip:hover {
  background: var(--ib-orange-light);
  border-color: var(--ib-orange);
  color: var(--ib-orange-hover);
}

.ibatyr-escalate-wrapper {
  margin-top: 4px;
}

.ibatyr-chip-escalate {
  margin-top: 4px;
  border-color: var(--ib-orange);
  color: var(--ib-orange-hover);
  font-weight: 600;
  background: var(--ib-orange-light);
}

.ibatyr-chip-escalate:hover {
  background: var(--ib-orange);
  color: #ffffff;
}

/* L2 Operator Action Banner */
.ibatyr-l2-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--ib-radius-md);
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ibatyr-l2-btn {
  background: var(--ib-orange);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}

.ibatyr-l2-btn:hover {
  background: var(--ib-orange-hover);
}

/* Typing Indicator */
.ibatyr-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--ib-gray-200);
  border-radius: var(--ib-radius-md);
  width: fit-content;
}

.ibatyr-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--ib-orange);
  border-radius: 50%;
  animation: ibatyr-bounce 1.2s infinite ease-in-out;
}

.ibatyr-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ibatyr-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ibatyr-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* Footer / Input Bar */
.ibatyr-chat-footer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid var(--ib-gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ibatyr-input {
  flex: 1;
  border: 1px solid var(--ib-gray-300);
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.ibatyr-input:focus {
  border-color: var(--ib-orange);
  box-shadow: 0 0 0 2px rgba(230, 100, 45, 0.15);
}

.ibatyr-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ib-orange);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
}

.ibatyr-send-btn:hover:not(:disabled) {
  background: var(--ib-orange-hover);
  transform: scale(1.05);
}

.ibatyr-send-btn:disabled {
  background: var(--ib-gray-300);
  cursor: not-allowed;
}

/* Escalation Modal */
.ibatyr-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.ibatyr-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.ibatyr-modal {
  background: #ffffff;
  border-radius: var(--ib-radius-md);
  padding: 18px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--ib-shadow-lg);
}

.ibatyr-modal h5 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ib-gray-900);
}

.ibatyr-modal p {
  margin: 0;
  font-size: 12px;
  color: var(--ib-gray-600);
}

.ibatyr-contact-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ibatyr-contact-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--ib-gray-200);
  border-radius: var(--ib-radius-md);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.ibatyr-contact-card:hover {
  border-color: var(--ib-orange);
  background: #fff7ed;
}

.ibatyr-contact-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  line-height: 1;
}

.ibatyr-contact-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ibatyr-contact-info {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
}

.ibatyr-contact-info strong {
  font-size: 13.5px;
  color: var(--ib-gray-900);
}

.ibatyr-contact-info span {
  color: var(--ib-gray-600);
}

.ibatyr-modal-btns {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.ibatyr-btn-secondary {
  background: var(--ib-gray-100);
  border: 1px solid var(--ib-gray-200);
  color: var(--ib-gray-700);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* Mobile full-screen */
@media (max-width: 480px) {
  .ibatyr-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}
