/* ==========================================================================
   HIBBA LIMITED CHATBOT - Widget Styles
   Floating chat widget matching the Hibba Limited design system.
   Desktop: bottom-right panel. Mobile: full-screen overlay.
   ========================================================================== */

/* --- Launcher Button --- */

.chatbot-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1001;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--color-green-dark);
  color: var(--color-white);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chatbot-launcher:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-xl);
}

.chatbot-launcher:active {
  transform: scale(0.95);
}

.chatbot-launcher svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chatbot-launcher--hidden {
  display: none;
}

/* Notification dot */
.chatbot-launcher__dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-white);
}


/* --- Widget Panel --- */

.chatbot-widget {
  position: fixed;
  z-index: 1001;
  bottom: 100px;
  right: 20px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--color-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-body);
}

.chatbot-widget.active {
  display: flex;
}

/* Open / close animation */
.chatbot-widget--entering {
  animation: chatbot-slide-in 0.3s ease forwards;
}

.chatbot-widget--leaving {
  animation: chatbot-slide-out 0.2s ease forwards;
}

@keyframes chatbot-slide-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chatbot-slide-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.95); }
}


/* --- Header --- */

.chatbot-header {
  background: var(--color-green-dark);
  color: var(--color-white);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatbot-header__info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.chatbot-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-green-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.chatbot-header__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  line-height: 1.2;
}

.chatbot-header__subtitle {
  font-size: var(--text-xs);
  opacity: 0.8;
}

.chatbot-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.chatbot-header__restart,
.chatbot-header__close {
  background: none;
  border: none;
  color: var(--color-white);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.chatbot-header__restart:hover,
.chatbot-header__close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.chatbot-header__restart svg,
.chatbot-header__close svg {
  width: 20px;
  height: 20px;
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
}


/* --- Messages Area --- */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background: var(--color-cream-light);
  scroll-behavior: smooth;
}

/* Scrollbar styling */
.chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--color-grey-warm);
  border-radius: 2px;
}


/* --- Message Bubble --- */

.chatbot-msg {
  display: flex;
  gap: var(--space-xs);
  max-width: 85%;
  animation: chatbot-msg-in 0.3s ease;
}

@keyframes chatbot-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

.chatbot-msg__bubble {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-lg);
  font-size: var(--text-sm);
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-line;
}

.chatbot-msg--bot .chatbot-msg__bubble {
  background: var(--color-white);
  color: var(--color-charcoal);
  border: 1px solid var(--color-grey-warm);
  border-bottom-left-radius: var(--border-radius);
}

.chatbot-msg--user .chatbot-msg__bubble {
  background: var(--color-green-dark);
  color: var(--color-white);
  border-bottom-right-radius: var(--border-radius);
}

.chatbot-msg__bubble a {
  color: var(--color-green-dark);
  text-decoration: underline;
}

.chatbot-msg--user .chatbot-msg__bubble a {
  color: var(--color-gold-light);
}

.chatbot-msg__bubble strong {
  font-weight: var(--weight-semibold);
  color: var(--color-green-dark);
}


/* --- Typing Indicator --- */

.chatbot-typing {
  display: flex;
  gap: 4px;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-white);
  border: 1px solid var(--color-grey-warm);
  border-radius: var(--border-radius-lg);
  border-bottom-left-radius: var(--border-radius);
  align-self: flex-start;
  animation: chatbot-msg-in 0.3s ease;
}

.chatbot-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-grey-medium);
}

.chatbot-typing__dot:nth-child(1) { animation: chatbot-bounce 1.4s 0s infinite; }
.chatbot-typing__dot:nth-child(2) { animation: chatbot-bounce 1.4s 0.2s infinite; }
.chatbot-typing__dot:nth-child(3) { animation: chatbot-bounce 1.4s 0.4s infinite; }

@keyframes chatbot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}


/* --- Option Buttons --- */

.chatbot-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  align-self: flex-start;
  max-width: 90%;
  animation: chatbot-msg-in 0.3s ease;
}

.chatbot-options__btn {
  background: var(--color-white);
  border: 1.5px solid var(--color-green-dark);
  color: var(--color-green-dark);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.3;
}

.chatbot-options__btn:hover {
  background: var(--color-green-dark);
  color: var(--color-white);
}

.chatbot-options__btn:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.chatbot-options__btn--back {
  border-color: var(--color-grey-medium);
  color: var(--color-grey-medium);
  font-weight: var(--weight-regular);
}

.chatbot-options__btn--back:hover {
  background: var(--color-grey-warm);
  color: var(--color-charcoal);
  border-color: var(--color-grey-warm);
}


/* --- Inline Forms --- */

.chatbot-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-white);
  border: 1px solid var(--color-grey-warm);
  border-radius: var(--border-radius-lg);
  align-self: flex-start;
  max-width: 95%;
  animation: chatbot-msg-in 0.3s ease;
}

.chatbot-form__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chatbot-form__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-charcoal);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chatbot-form__input,
.chatbot-form__textarea,
.chatbot-form__select {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--color-charcoal);
  background: var(--color-white);
  border: 1px solid var(--color-grey-warm);
  border-radius: var(--border-radius);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}

.chatbot-form__textarea {
  resize: vertical;
  min-height: 60px;
  max-height: 120px;
}

.chatbot-form__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A9590' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.chatbot-form__input:focus,
.chatbot-form__textarea:focus,
.chatbot-form__select:focus {
  outline: none;
  border-color: var(--color-green-dark);
  box-shadow: 0 0 0 3px rgba(10, 14, 26, 0.1);
}

.chatbot-form__group--error .chatbot-form__input,
.chatbot-form__group--error .chatbot-form__textarea,
.chatbot-form__group--error .chatbot-form__select {
  border-color: var(--color-error);
}

.chatbot-form__error {
  font-size: 11px;
  color: var(--color-error);
  display: none;
}

.chatbot-form__group--error .chatbot-form__error {
  display: block;
}

.chatbot-form__hint {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 3px;
  line-height: 1.4;
}

.chatbot-form__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-cream);
  background: var(--color-green-dark);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition-base);
  margin-top: var(--space-xs);
}

.chatbot-form__submit:hover {
  background: var(--color-green-medium);
}

.chatbot-form__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chatbot-form__cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-charcoal);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  margin-top: var(--space-xs);
  opacity: 0.7;
}

.chatbot-form__cancel:hover {
  opacity: 1;
  color: var(--color-green-dark);
}


/* --- Footer / Branding --- */

.chatbot-footer {
  padding: var(--space-xs) var(--space-md);
  text-align: center;
  font-size: 10px;
  color: var(--color-grey-medium);
  border-top: 1px solid var(--color-grey-warm);
  flex-shrink: 0;
  background: var(--color-white);
}


/* --- Responsive: Mobile --- */

@media (max-width: 768px) {
  .chatbot-launcher {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 56px;
    height: 56px;
  }

  .chatbot-launcher svg {
    width: 24px;
    height: 24px;
  }

  .chatbot-widget {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .chatbot-header {
    border-radius: 0;
    padding-top: calc(var(--space-md) + env(safe-area-inset-top, 0px));
  }

  .chatbot-messages {
    padding: var(--space-md);
  }

  .chatbot-form__input,
  .chatbot-form__textarea,
  .chatbot-form__select {
    min-height: 44px;
  }

  .chatbot-options__btn {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .chatbot-form__submit {
    min-height: 48px;
  }

  .chatbot-footer {
    padding-bottom: calc(var(--space-xs) + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 480px) {
  .chatbot-msg {
    max-width: 92%;
  }

  .chatbot-options {
    max-width: 95%;
  }
}

/* Landscape phones - constrain height */
@media (max-height: 500px) and (orientation: landscape) {
  .chatbot-widget {
    height: 100vh;
    max-height: 100vh;
  }

  .chatbot-form__textarea {
    min-height: 40px;
    max-height: 60px;
  }
}
