/**
 * Solertia Chatbot Styles - Adapted for Solertia brand colors
 * Primary color: #0a2850 (blue)
 * Secondary color: #da123c (red)
 */

/* Variables CSS */
:root {
  /* Couleurs Solertia */
  --solertia-blue-primary: #0a2850;
  --solertia-blue-secondary: #094b99;
  --solertia-red-primary: #da123c;
  --solertia-red-accent: #ae1833;
  --solertia-red-dark: #6a0e1f;

  /* Couleurs neutres */
  --color-white: #ffffff;
  --color-grey-dark: #333333;
  --color-grey-medium: #999999;
  --color-grey-light: #f9fafb;

  /* Gradients */
  --primary-gradient: linear-gradient(135deg, #0c3262, #0a2850, #081f40);

  /* Typographie */
  --font-primary: 'Poppins', sans-serif;

  /* Dimensions */
  --chat-width: 450px;
  --chat-height: 520px;
  --header-height: 56px;
  --border-radius: 16px;
  --transition-speed: 0.3s;
}

#chatbot-popup, #open-chat {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
}

/* Open chat button (floating button) */
#open-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: auto;
    height: 60px;
    background: var(--primary-gradient);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.36);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 24px 0 20px;
    box-shadow: 0 0 20px 7px rgba(255, 255, 255, 0.13);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    color: var(--color-white);
}

#open-chat:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 48px rgba(10, 40, 80, 0.4);
}

#open-chat:focus {
  outline: 3px solid rgba(10, 40, 80, 0.5);
  outline-offset: 3px;
}

#open-chat svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

#open-chat span {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}

#open-chat.hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
}

/* Chatbot popup container */
#chatbot-popup {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: min(650px, calc(100vw - 48px));
    height: min(650px, calc(100vh - 120px));
    max-height: calc(100vh - 120px);
    background: var(--color-white);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}

#chatbot-popup.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

#chatbot-header {
  background: var(--primary-gradient);
  padding: 16px 20px;
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--color-white);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 500;
}

.header-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.icon-button {
  background: none;
  border: none;
  color: var(--color-white);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-button:hover {
  color: var(--color-white);
  background: rgba(255, 255, 255, 0.1);
}

.icon-button:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

#webchat {
  height: calc(100% - var(--header-height));
  background-color: var(--color-grey-light);
  position: relative;
}

.webchat-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  pointer-events: none;
  z-index: 1;
}

#webchat > div {
  position: relative;
  z-index: 2;
}

#webchat .webchat__basic-transcript__content {
  white-space: pre-wrap ;
  word-break: break-word ;
}

#webchat .webchat__bubble__content {
  padding: 8px 12px ;
}

.webchat__render-markdown p{
    margin: 10px;
    line-height: 1.3em;
}

.webchat__send-box__main form{
    padding-left: 10px !important;
}

/* Prevent iOS zoom on input focus - font-size must be at least 16px */
.webchat__send-box-text-box__input,
.webchat__send-box textarea,
.webchat__send-box input[type="text"],
.ac-input{
    font-size: 16px !important;
    touch-action: manipulation;
}

/* Additional iOS zoom prevention */
#webchat input,
#webchat textarea,
#webchat select {
    font-size: 16px !important;
    touch-action: manipulation;
}

#webchat .webchat__bubble {
  max-width: 85% ;
  margin: 8px ;
}

#webchat .webchat__basic-transcript__content ul,
#webchat .webchat__basic-transcript__content ol,
#webchat .webchat__bubble__content ul,
#webchat .webchat__bubble__content ol {
  padding-left: 24px ;
  margin: 8px 0 ;
  list-style-position: outside ;
}

#webchat .webchat__basic-transcript__content li,
#webchat .webchat__bubble__content li {
  margin: 4px 0 ;
  padding-left: 4px ;
}

.webchat__suggested-actions__flow-box{
    justify-content: center;
    padding: 12px 16px ;
}

/* Styles des boutons d'actions suggérées */
.ac-pushButton,
.webchat__suggested-actions__button {
    background: var(--solertia-red-primary) !important;
    border: 2px solid var(--solertia-red-primary) !important;
    border-radius: 25px !important;
    color: var(--color-white) !important;
    padding: 12px 24px !important;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    min-width: 120px;
}

.ac-pushButton:hover,
.webchat__suggested-actions__button:hover {
    background: var(--solertia-blue-primary) !important;
    border-color: var(--solertia-blue-primary) !important;
}

.webchat__suggested-actions__button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(218, 18, 60, 0.2);
}

.webchat__suggested-action__text {
    color: var(--color-white);
    font-size: 14px;
    letter-spacing: 0.02em;
}

.webchat__suggested-actions__flow-item-box {
    margin: 6px ;
}

/* Indicateur de focus pour l'accessibilité */
.webchat__suggested-action__keyboard-focus-indicator {
    border-radius: 8px ;
}

.webchat__text-content{
    font-size: 14px ;
}

.webchat__stacked-layout--from-user .webchat__stacked-layout__avatar-gutter {
    display: none !important;
}




/* Adaptive Cards Form Styling - Match Solertia Website Theme */

/* Container styling */
.ac-container.ac-adaptiveCard {
  font-family: var(--font-primary);
  background: var(--color-white);
}

/* Text blocks styling */
.ac-textBlock {
  font-family: var(--font-primary);
  font-size: 14px;
  line-height: 22px;
  color: var(--color-grey-dark);
}

/* Input fields styling */
.ac-input.ac-textInput {
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 46px;
  height: 48px;
  padding: 0 10px;
  border: 1px solid var(--color-grey-dark);
  border-radius: 0;
  background-color: var(--color-white);
  color: var(--color-grey-dark);
  transition: border-color 0.3s ease;
}

.ac-input.ac-textInput:focus {
  border-color: var(--solertia-blue-secondary);
  outline: none;
}

.ac-input.ac-textInput::placeholder {
  color: var(--color-grey-medium);
  opacity: 1;
}

/* Textarea styling */
.ac-input.ac-textInput.ac-multiline {
  min-height: 100px;
  height: 220px;
  line-height: 22px;
  padding: 10px;
  resize: vertical;
}

/* Checkbox styling */
.ac-input.ac-toggleInput {
  font-family: var(--font-primary);
}

.ac-input.ac-toggleInput input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border: 1px solid var(--color-grey-dark);
  border-radius: 3px;
  cursor: pointer;
  accent-color: var(--solertia-red-accent);
}

.ac-input.ac-toggleInput label {
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 20px;
  color: var(--color-grey-dark);
  cursor: pointer;
  margin-left: 8px;
}

/* Button active state */
.ac-pushButton:active {
  background-color: var(--solertia-red-dark);
  border-color: var(--solertia-red-dark);
}

/* Action set styling */
.ac-actionSet {
  margin-top: 16px;
}

/* Column set adjustments */
.ac-columnSet {
    gap: 4px;
    align-content: center;
    align-items: flex-start;
    flex-direction: row;
}

.ac-columnSet:has(#requestPayEquity) {
    flex-direction: column !important;
}

/* Horizontal separators */
.ac-horizontal-separator {
  height: 12px;
}

/* Input container */
.ac-input-container {
  margin-bottom: 4px;
}

/* Markdown content in adaptive cards */
.webchat__render-markdown.webchat__render-markdown--adaptive-cards p {
  margin: 0;
  font-family: var(--font-primary);
}

/* Error fallback styles */
.chatbot-error-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px;
  background-color: var(--color-grey-light);
}

.chatbot-error-content {
  text-align: center;
  max-width: 400px;
}

.chatbot-error-content h3 {
  font-family: var(--font-primary);
  font-size: 20px;
  font-weight: 600;
  color: var(--color-grey-dark);
  margin-bottom: 12px;
  line-height: 1.3;
}

.chatbot-error-content p {
  font-family: var(--font-primary);
  font-size: 15px;
  color: var(--color-grey-medium);
  line-height: 1.5;
  margin-bottom: 28px;
}

.chatbot-error-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.chatbot-retry-button,
.chatbot-contact-button {
  font-family: var(--font-primary);
  font-size: 15px;
  font-weight: 600;
  padding: 14px 24px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.chatbot-retry-button {
  background-color: var(--solertia-blue-primary);
  color: var(--color-white);
}

.chatbot-retry-button:hover {
  background-color: var(--solertia-blue-secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10, 40, 80, 0.2);
}

.chatbot-retry-button:active {
  transform: translateY(0);
}

.chatbot-contact-button {
  background-color: var(--solertia-red-primary);
  color: var(--color-white);
}

.chatbot-contact-button:hover {
  background-color: var(--solertia-red-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(218, 18, 60, 0.2);
}

.chatbot-contact-button:active {
  transform: translateY(0);
}

.chatbot-retry-button svg,
.chatbot-contact-button svg {
  flex-shrink: 0;
}

/* Loading indicator styles */
.chatbot-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px;
  background-color: var(--color-grey-light);
}

.chatbot-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-grey-light);
  border-top: 4px solid var(--solertia-blue-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.chatbot-loading p {
  font-family: var(--font-primary);
  font-size: 15px;
  color: var(--color-grey-medium);
  margin: 0;
}

.chatbot-cta-button {
    background: rgb(218, 18, 60);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.36);
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    max-width: 420px;
    margin: 24px auto 0 auto;


    &:hover {
        background: rgb(10, 40, 80);
    }

}

/* Responsive design */
@media (max-width: 800px) {
    #chatbot-popup {
        top: 0;
        bottom: auto;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    #open-chat {
        bottom: 20px;
        right: 20px;
        height: 56px;
        padding: 0 20px 0 16px;
    }

    #open-chat span {
        font-size: 14px;
    }

    #open-chat svg {
        width: 18px;
        height: 18px;
    }

    .ac-columnSet {
        flex-direction: column;
    }

    .ac-container{
        width: 100%;
    }

    .webchat__render-markdown p {
        line-height: 1.27em;
    }
}

/* Toggle form visibility via .toggle-form-btn links */
#contact-page-wrapper .hidden-form_wrapper {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0 40px;
    background: var(--color-white);
    transition: max-height var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1),
                opacity var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1),
                padding var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

#contact-page-wrapper .hidden-form_wrapper.visible {
    max-height: 2000px;
    opacity: 1;
    padding: 40px;
}

@media (max-width: 800px) {
    #contact-page-wrapper .hidden-form_wrapper.visible {
        padding: 15px;
    }
}