/* =========================================
   AI SLAVIK Chatbot - Base Styles
   Optimized for performance & compatibility
   PHP 7.4+ / Weak Hosting Ready
   ========================================= */

/* ===== CSS Variables for Dynamic Colors ===== */
.arcb-chatbot {
  --arcb-header-bg: linear-gradient(135deg, #6366f1, #ec4899);
  --arcb-header-text: #fff;
  --arcb-window-bg: #ffffff;
  --arcb-window-border: rgba(15,23,42,0.08);
  --arcb-window-text: #0f172a;
  --arcb-messages-bg: #f8fafc;
  --arcb-bubble-user-bg: #dbeafe;
  --arcb-bubble-user-text: #0f172a;
  --arcb-bubble-bot-bg: #fff;
  --arcb-bubble-bot-text: #0f172a;
  --arcb-bubble-bot-border: rgba(15,23,42,0.06);
  --arcb-input-bg: #fff;
  --arcb-input-border: rgba(15,23,42,0.12);
  --arcb-input-text: #0f172a;
  --arcb-suggestions-bg: #fff;
  --arcb-suggestion-btn-bg: #f8fafc;
  --arcb-suggestion-btn-text: #334155;
  --arcb-suggestion-btn-border: rgba(15,23,42,0.1);
  --arcb-hint-text: #64748b;
  --arcb-send-bg: linear-gradient(135deg, #dc3232, #ef4444);
  --arcb-send-text: #fff;
  --arcb-toggle-bg: linear-gradient(135deg, #6366f1, #ec4899);
  --arcb-toggle-text: #fff;
}

.arcb-chatbot {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  z-index: 999999;
  line-height: 1.5;
  box-sizing: border-box;
}
.arcb-chatbot *, .arcb-chatbot *::before, .arcb-chatbot *::after {
  box-sizing: border-box;
}

/* =========================================
   Widget Mode (Floating)
   ========================================= */
.arcb-chatbot:not(.arcb-embedded) {
  position: fixed;
  inset: 0 auto auto 0;
  pointer-events: none;
}
.arcb-inner {
  pointer-events: auto;
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.arcb-pos-bottom-right { right: 24px; bottom: 24px; align-items: flex-end; }
.arcb-pos-bottom-left { left: 24px; bottom: 24px; align-items: flex-start; }
.arcb-pos-top-right { right: 24px; top: 24px; align-items: flex-end; }
.arcb-pos-top-left { left: 24px; top: 24px; align-items: flex-start; }

/* =========================================
   Shortcode / Embedded Mode
   ========================================= */
.arcb-chatbot.arcb-embedded {
  position: relative;
  width: 100%;
}
.arcb-chatbot.arcb-embedded .arcb-inner {
  position: relative;
  right: auto; left: auto; top: auto; bottom: auto;
  align-items: stretch;
}
.arcb-chatbot.arcb-embedded .arcb-toggle { display: none; }
.arcb-chatbot.arcb-embedded .arcb-window {
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  position: static;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* =========================================
   Toggle Button
   ========================================= */
.arcb-toggle {
  border: 0;
  background: var(--arcb-toggle-bg);
  color: var(--arcb-toggle-text);
  font-weight: 700;
  border-radius: 999px;
  width: 56px;
  height: 56px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(99,102,241,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.arcb-toggle:hover { transform: scale(1.05); box-shadow: 0 10px 24px rgba(99,102,241,0.45); }
.arcb-toggle-icon { font-size: 18px; letter-spacing: 0.5px; }

/* =========================================
   Chat Window
   ========================================= */
.arcb-window {
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 80px);
  background: var(--arcb-window-bg);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.18);
  border: 1px solid var(--arcb-window-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  color: var(--arcb-window-text);
}

/* =========================================
   Header & Bot Icon
   ========================================= */
.arcb-header {
  padding: 14px 16px;
  background: var(--arcb-header-bg);
  color: var(--arcb-header-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.arcb-title-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.arcb-bot-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  background: transparent !important;
  flex-shrink: 0;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}
.arcb-title {
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arcb-close {
  border: 0;
  background: rgba(255,255,255,0.2);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 20px;
  line-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.arcb-close:hover { background: rgba(255,255,255,0.35); }

/* =========================================
   Messages Area
   ========================================= */
.arcb-messages {
  padding: 14px 14px 0 14px;
  overflow-y: auto;
  flex: 1;
  background: var(--arcb-messages-bg);
  transition: background-color 0.2s ease;
  scroll-behavior: smooth;
}
.arcb-bubble {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  max-width: 92%;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.arcb-bubble p { margin: 0 0 6px; }
.arcb-bubble p:last-child { margin-bottom: 0; }
.arcb-bubble a { color: #2563eb; text-decoration: underline; }
.arcb-bubble.user {
  background: var(--arcb-bubble-user-bg);
  margin-left: auto;
  color: var(--arcb-bubble-user-text);
}
.arcb-bubble.bot {
  background: var(--arcb-bubble-bot-bg);
  border: 1px solid var(--arcb-bubble-bot-border);
  color: var(--arcb-bubble-bot-text);
}

/* =========================================
   Suggestions & Input
   ========================================= */
.arcb-suggestions {
  padding: 8px 12px 0 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--arcb-suggestions-bg);
  transition: background-color 0.2s ease;
}
.arcb-suggestion-btn {
  border: 1px solid var(--arcb-suggestion-btn-border);
  border-radius: 999px;
  background: var(--arcb-suggestion-btn-bg);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--arcb-suggestion-btn-text);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}
.arcb-suggestion-btn:hover { background: #e2e8f0; border-color: #cbd5e1; }
.arcb-suggestion-btn:active { transform: scale(0.98); }

.arcb-input-row {
  padding: 12px;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--arcb-window-border);
  background: var(--arcb-input-bg);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.arcb-input-row input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid var(--arcb-input-border);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  color: var(--arcb-input-text);
  background: var(--arcb-input-bg);
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.arcb-input-row input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
}
.arcb-send {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--arcb-send-bg);
  color: var(--arcb-send-text);
  font-weight: 700;
  font-size: 14px;
  transition: opacity 0.2s ease, transform 0.1s ease;
}
.arcb-send:hover { opacity: 0.9; }
.arcb-send:active { transform: scale(0.98); }
.arcb-send:disabled { opacity: 0.5; cursor: not-allowed; }

.arcb-hint {
  padding: 12px;
  font-size: 13px;
  color: var(--arcb-hint-text);
  text-align: center;
  transition: color 0.2s ease;
}

/* =========================================
   Dark Mode Support (overrides variables)
   ========================================= */
@media (prefers-color-scheme: dark) {
  .arcb-chatbot:not(.arcb-embedded),
  .arcb-chatbot.arcb-dark {
    --arcb-window-bg: #1e293b;
    --arcb-window-border: rgba(255,255,255,0.1);
    --arcb-window-text: #f1f5f9;
    --arcb-messages-bg: #0f172a;
    --arcb-bubble-bot-bg: #1e293b;
    --arcb-bubble-bot-text: #e2e8f0;
    --arcb-bubble-bot-border: rgba(255,255,255,0.08);
    --arcb-bubble-user-bg: #334155;
    --arcb-bubble-user-text: #f8fafc;
    --arcb-input-bg: #1e293b;
    --arcb-input-border: rgba(255,255,255,0.15);
    --arcb-input-text: #f1f5f9;
    --arcb-suggestions-bg: #1e293b;
    --arcb-suggestion-btn-bg: #334155;
    --arcb-suggestion-btn-text: #e2e8f0;
    --arcb-suggestion-btn-border: rgba(255,255,255,0.1);
    --arcb-hint-text: #94a3b8;
  }
  .arcb-chatbot:not(.arcb-embedded) .arcb-input-row input:focus,
  .arcb-chatbot.arcb-dark .arcb-input-row input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(129,140,248,0.25);
  }
}

/* Theme classes: .is-style-dark / .is-style-light */
html.is-style-dark .arcb-chatbot:not(.arcb-embedded),
html.is-style-dark .arcb-chatbot.arcb-dark,
body.is-style-dark .arcb-chatbot:not(.arcb-embedded),
body.is-style-dark .arcb-chatbot.arcb-dark {
  --arcb-window-bg: #1e293b;
  --arcb-window-border: rgba(255,255,255,0.1);
  --arcb-window-text: #f1f5f9;
  --arcb-messages-bg: #0f172a;
  --arcb-bubble-bot-bg: #1e293b;
  --arcb-bubble-bot-text: #e2e8f0;
  --arcb-bubble-bot-border: rgba(255,255,255,0.08);
  --arcb-bubble-user-bg: #334155;
  --arcb-bubble-user-text: #f8fafc;
  --arcb-input-bg: #1e293b;
  --arcb-input-border: rgba(255,255,255,0.15);
  --arcb-input-text: #f1f5f9;
  --arcb-suggestions-bg: #1e293b;
  --arcb-suggestion-btn-bg: #334155;
  --arcb-suggestion-btn-text: #e2e8f0;
  --arcb-suggestion-btn-border: rgba(255,255,255,0.1);
  --arcb-hint-text: #94a3b8;
}
html.is-style-dark .arcb-chatbot:not(.arcb-embedded) .arcb-input-row input:focus,
html.is-style-dark .arcb-chatbot.arcb-dark .arcb-input-row input:focus,
body.is-style-dark .arcb-chatbot:not(.arcb-embedded) .arcb-input-row input:focus,
body.is-style-dark .arcb-chatbot.arcb-dark .arcb-input-row input:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(129,140,248,0.25);
}

html.is-style-light .arcb-chatbot:not(.arcb-embedded),
html.is-style-light .arcb-chatbot.arcb-light,
body.is-style-light .arcb-chatbot:not(.arcb-embedded),
body.is-style-light .arcb-chatbot.arcb-light {
  --arcb-window-bg: #ffffff;
  --arcb-window-border: rgba(15,23,42,0.08);
  --arcb-window-text: #0f172a;
  --arcb-messages-bg: #f8fafc;
  --arcb-bubble-bot-bg: #fff;
  --arcb-bubble-bot-text: #0f172a;
  --arcb-bubble-bot-border: rgba(15,23,42,0.06);
  --arcb-bubble-user-bg: #dbeafe;
  --arcb-bubble-user-text: #0f172a;
  --arcb-input-bg: #fff;
  --arcb-input-border: rgba(15,23,42,0.12);
  --arcb-input-text: #0f172a;
  --arcb-suggestions-bg: #fff;
  --arcb-suggestion-btn-bg: #f8fafc;
  --arcb-suggestion-btn-text: #0f172a;
  --arcb-suggestion-btn-border: rgba(15,23,42,0.1);
  --arcb-hint-text: #64748b;
}
html.is-style-light .arcb-chatbot:not(.arcb-embedded) .arcb-input-row input:focus,
html.is-style-light .arcb-chatbot.arcb-light .arcb-input-row input:focus,
body.is-style-light .arcb-chatbot:not(.arcb-embedded) .arcb-input-row input:focus,
body.is-style-light .arcb-chatbot.arcb-light .arcb-input-row input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
}

/* =========================================
   Accessibility & Focus States
   ========================================= */
.arcb-toggle:focus-visible,
.arcb-close:focus-visible,
.arcb-send:focus-visible,
.arcb-suggestion-btn:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}
