/* ===== Akademia Bot — Professional Chat Widget ===== */

:root {
  --bot-primary: #248471;
  --bot-primary-dark: #1B6558;
  --bot-primary-light: #D6F2EA;
  --bot-black: #20224D;
  --bot-white: #FFFFFF;
  --bot-gray-50: #FAFAFA;
  --bot-gray-100: #F4F4F5;
  --bot-gray-200: #E4E4E7;
  --bot-gray-400: #A1A1AA;
  --bot-gray-500: #71717A;
  --bot-gray-900: #18181B;
  --bot-green: #22C55E;
  --bot-shadow-lg: 0 24px 64px rgba(0,0,0,0.15), 0 4px 20px rgba(0,0,0,0.08);
  --bot-radius: 24px;
  --bot-z: 99999;
}

/* ===== Floating Bubble ===== */
#akademia-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 4px 20px rgba(36, 132, 113, 0.45), 0 0 0 0 rgba(36, 132, 113, 0.25);
  cursor: pointer;
  z-index: var(--bot-z);
  overflow: hidden;
  padding: 0;
  background: var(--bot-primary);
  outline: none;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.22s ease;
  animation: bot-ring-idle 3s ease-in-out infinite;
}

@keyframes bot-ring-idle {
  0%, 100% { box-shadow: 0 4px 20px rgba(36,132,113,0.45), 0 0 0 0 rgba(36,132,113,0.2); }
  50%       { box-shadow: 0 4px 20px rgba(36,132,113,0.45), 0 0 0 8px rgba(36,132,113,0.0); }
}

#akademia-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(36, 132, 113, 0.55), 0 0 0 6px rgba(36, 132, 113, 0.15);
  animation: none;
}

#akademia-bubble:active {
  transform: scale(0.97);
}

#akademia-bubble .bot-bubble-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: opacity 0.2s ease, transform 0.22s ease;
}

#akademia-bubble .bot-bubble-close {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: var(--bot-primary);
  color: white;
  font-size: 20px;
  font-weight: 300;
}

#akademia-bubble.is-open .bot-bubble-photo { opacity: 0; transform: scale(0.6); }
#akademia-bubble.is-open .bot-bubble-close { display: flex; }

/* Notification dot */
#akademia-bubble .bot-notif {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 14px;
  height: 14px;
  background: #EF4444;
  border-radius: 50%;
  border: 2px solid white;
  z-index: 2;
  animation: bot-notif-pulse 2s ease infinite;
}

@keyframes bot-notif-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.25); }
}

/* ===== Chat Window ===== */
#akademia-chat {
  position: fixed;
  bottom: 112px;
  right: 28px;
  width: 390px;
  height: 580px;
  background: var(--bot-white);
  border-radius: var(--bot-radius);
  box-shadow: var(--bot-shadow-lg);
  z-index: var(--bot-z);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.88) translateY(16px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.22s ease;
}

#akademia-chat.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ===== Accent Bar ===== */
.bot-accent-bar {
  height: 4px;
  background: linear-gradient(90deg, #248471 0%, #3FBF9B 60%, #44D498 100%);
  flex-shrink: 0;
}

/* ===== Header ===== */
.bot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bot-white);
  border-bottom: 1px solid var(--bot-gray-100);
  flex-shrink: 0;
}

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

.bot-avatar-ring {
  position: relative;
  flex-shrink: 0;
}

.bot-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  display: block;
  box-shadow: 0 2px 10px rgba(36, 132, 113, 0.2);
  border: 2px solid var(--bot-gray-100);
}

.bot-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: var(--bot-green);
  border-radius: 50%;
  border: 2px solid white;
}

.bot-header-name {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: var(--bot-gray-900);
  letter-spacing: -0.2px;
}

.bot-header-sub {
  margin: 0;
  font-size: 12px;
  color: var(--bot-gray-500);
  font-weight: 400;
}

.bot-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bot-gray-100);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bot-gray-500);
  font-size: 16px;
  font-weight: 400;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  font-family: inherit;
}

.bot-close-btn:hover {
  background: var(--bot-gray-200);
  color: var(--bot-gray-900);
}

/* ===== Messages ===== */
.bot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bot-white);
  scroll-behavior: smooth;
}

.bot-messages::-webkit-scrollbar { width: 0; }

.bot-msg {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  animation: bot-msg-in 0.25s cubic-bezier(0.21, 1.02, 0.73, 1) both;
}

@keyframes bot-msg-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bot-msg.user { flex-direction: row-reverse; }

.bot-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  object-position: top center;
  border: 1.5px solid var(--bot-gray-200);
}

.bot-msg-bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.58;
  word-break: break-word;
}

.bot-msg.bot .bot-msg-bubble {
  background: var(--bot-gray-100);
  color: var(--bot-gray-900);
  border-bottom-left-radius: 5px;
}

.bot-msg.user .bot-msg-bubble {
  background: var(--bot-primary);
  color: white;
  border-bottom-right-radius: 5px;
}

.bot-msg-bubble a { color: var(--bot-primary); text-decoration: underline; }
.bot-msg.user .bot-msg-bubble a { color: #C7F9E5; }

/* ===== Typing ===== */
.bot-typing {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  animation: bot-msg-in 0.2s ease both;
}

.bot-typing-dots {
  background: var(--bot-gray-100);
  padding: 13px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.bot-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--bot-gray-400);
  border-radius: 50%;
  animation: bot-bounce 1.2s ease infinite;
}

.bot-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.bot-typing-dots span:nth-child(3) { animation-delay: 0.36s; }

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

/* ===== Quick Questions ===== */
.bot-quick-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
  animation: bot-msg-in 0.3s ease both;
}

.bot-quick-btn {
  background: var(--bot-white);
  border: 1.5px solid var(--bot-gray-200);
  color: var(--bot-gray-900);
  padding: 10px 15px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  line-height: 1.3;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bot-quick-btn::after {
  content: '→';
  color: var(--bot-gray-400);
  font-size: 14px;
  transition: transform 0.15s ease, color 0.15s ease;
}

.bot-quick-btn:hover {
  border-color: var(--bot-primary);
  background: #F2FBF8;
  transform: translateX(2px);
}

.bot-quick-btn:hover::after {
  color: var(--bot-primary);
  transform: translateX(3px);
}

/* ===== Email Form ===== */
.bot-email-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  animation: bot-msg-in 0.25s ease both;
}

.bot-email-form input {
  border: 1.5px solid var(--bot-gray-200);
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 14px;
  font-family: inherit;
  color: var(--bot-gray-900);
  outline: none;
  background: var(--bot-white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bot-email-form input:focus {
  border-color: var(--bot-primary);
  box-shadow: 0 0 0 3px rgba(36, 132, 113, 0.1);
}

.bot-email-form input::placeholder { color: var(--bot-gray-400); }

.bot-email-submit {
  background: var(--bot-black);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.15s ease;
}

.bot-email-submit:hover { background: #2C2F63; transform: translateY(-1px); }
.bot-email-submit:active { transform: translateY(0); }
.bot-email-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== Input Section (component-inspired) ===== */
.bot-input-section {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--bot-gray-100);
  background: var(--bot-white);
  flex-shrink: 0;
}

.bot-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bot-gray-100);
  border-radius: 20px;
  padding: 8px 8px 8px 16px;
  transition: box-shadow 0.2s ease, background 0.2s ease;
}

.bot-input-container:focus-within {
  background: var(--bot-white);
  box-shadow: 0 0 0 1.5px var(--bot-gray-200), 0 4px 16px rgba(0,0,0,0.07);
}

.bot-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--bot-gray-900);
  resize: none;
  min-height: 24px;
  max-height: 96px;
  line-height: 1.5;
  padding: 4px 0;
  overflow-y: auto;
}

.bot-input::placeholder { color: var(--bot-gray-400); }
.bot-input::-webkit-scrollbar { width: 0; }

.bot-send-btn {
  width: 40px !important;
  height: 40px !important;
  border-radius: 14px !important;
  background: var(--bot-primary) !important;
  border: none !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0 !important;
  color: #FFFFFF !important;
  transition: background 0.15s ease, transform 0.15s ease;
}

.bot-send-btn:hover  { background: var(--bot-primary-dark) !important; transform: scale(1.05); }
.bot-send-btn:active { transform: scale(0.96); }
.bot-send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* !important, bo motywy WordPressa czesto maja globalne reguly dla svg
   (max-width, height:auto, fill:currentColor) i zjadaja ikone. */
.bot-send-btn svg {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  min-height: 18px;
  max-width: none !important;
  fill: #FFFFFF !important;
  stroke: none !important;
  display: block !important;
  pointer-events: none;
}

.bot-send-btn svg path {
  fill: #FFFFFF !important;
}

/* ===== Footer ===== */
.bot-footer {
  text-align: center;
  font-size: 10.5px;
  color: var(--bot-gray-400);
  padding: 0 14px 11px;
  background: var(--bot-white);
}

.bot-footer a { color: var(--bot-primary); text-decoration: none; }

/* ===== Mobile ===== */
@media (max-width: 480px) {
  /* --bot-vh / --bot-vtop sa ustawiane z JS na podstawie visualViewport.
     Bez tego klawiatura na iOS zaslania pole tekstowe i przycisk wyslij:
     100dvh nie kurczy sie po jej otwarciu. */
  #akademia-chat {
    left: 0;
    right: 0;
    width: 100%;
    top: var(--bot-vtop, 0px);
    bottom: auto;
    height: var(--bot-vh, 100dvh);
    border-radius: 0;
    transform: translateY(100%);
    transform-origin: bottom center;
  }

  #akademia-chat.is-open { transform: translateY(0); }

  #akademia-bubble { bottom: 20px; right: 20px; }

  /* Zapas na pasek gestow / notch */
  .bot-input-section { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .bot-footer { padding-bottom: calc(11px + env(safe-area-inset-bottom, 0px)); }
}
