/**
 * Alloroots FAQ chat — matches main site (alloroots.com) brand
 * Tokens from brand: #F26523 orange, #1A1A2E dark, Poppins
 */

.faq-widget {
    --faq-orange: #F26523;
    --faq-orange-hover: #e05a1c;
    --faq-orange-light: #FEF0E8;
    --faq-dark: #1A1A2E;
    --faq-dark-input: #2D2D3F;
    --faq-border: #E8E8F0;
    --faq-text: #333333;
    --faq-text-muted: #6B6B7B;
    --faq-online: #22c55e;
    --faq-wa: #25D366;
    --faq-radius: 12px;
    --faq-radius-pill: 20px;
    --faq-dock-stack: 108px;
    --faq-shadow: 0 12px 40px rgba(26, 26, 46, 0.18);
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

/* —— Dock (Ask Alloroots + WhatsApp) —— */
.faq-dock {
    position: fixed;
    z-index: 10050;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

.faq-dock > * {
    pointer-events: auto;
}

.faq-dock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--faq-radius-pill);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.faq-dock-btn--chat {
    padding: 12px 20px;
    background: var(--faq-dark);
    color: #fff;
    border: 2px solid var(--faq-orange);
    box-shadow: 0 0 0 1px rgba(242, 101, 35, 0.25), 0 4px 16px rgba(242, 101, 35, 0.35);
}

.faq-dock-btn--chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(242, 101, 35, 0.4), 0 6px 20px rgba(242, 101, 35, 0.45);
}

.faq-dock-btn--chat[aria-expanded="true"] {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

.faq-dock-btn--wa {
    padding: 12px 18px;
    background: var(--faq-wa);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
}

.faq-dock-btn--wa:hover {
    transform: translateY(-2px);
    color: #fff;
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.5);
}

.faq-dock-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Legacy circular FAB (assessment site when dock not used) */
.faq-widget .faq-fab {
    position: fixed;
    z-index: 10050;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--faq-orange);
    color: #fff;
    box-shadow: 0 4px 14px rgba(242, 101, 35, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.faq-widget .faq-fab:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 20px rgba(242, 101, 35, 0.5);
}

.faq-widget .faq-fab.faq-fab--hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

.faq-widget .faq-fab-icon {
    width: 24px;
    height: 24px;
}

.faq-widget--dock .faq-fab {
    display: none;
}

/* —— Panel —— */
.faq-widget .faq-panel {
    position: fixed;
    z-index: 10049;
    right: 24px;
    bottom: calc(24px + var(--faq-dock-stack) + 12px);
    width: min(400px, calc(100vw - 32px));
    max-height: min(560px, calc(100dvh - 120px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: #fff;
    border-radius: var(--faq-radius);
    box-shadow: var(--faq-shadow);
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

.faq-widget:not(.faq-widget--dock) .faq-panel {
    bottom: 92px;
}

.faq-widget .faq-panel.open {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.faq-widget .faq-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--faq-dark);
    color: #fff;
    flex-shrink: 0;
}

.faq-widget .faq-panel-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.faq-widget .faq-panel-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--faq-orange);
    color: #fff;
    flex-shrink: 0;
}

.faq-widget .faq-panel-icon svg {
    width: 20px;
    height: 20px;
}

.faq-widget .faq-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
}

.faq-widget .faq-panel-status {
    margin: 4px 0 0;
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.faq-widget .faq-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--faq-online);
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}

.faq-widget .faq-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.faq-widget .faq-panel-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.faq-widget .faq-disclaimer {
    display: none;
}

.faq-widget .faq-messages {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px 8px;
    min-height: 0;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.faq-widget .faq-msg {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 14px;
    max-width: 100%;
}

.faq-widget .faq-msg-user {
    align-items: flex-end;
}

.faq-widget .faq-msg-bot {
    align-items: flex-start;
}

.faq-widget .faq-msg-body {
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.faq-widget .faq-msg-bot .faq-msg-body {
    background: #fff;
    color: var(--faq-text);
    border: 1px solid var(--faq-border);
    border-radius: 12px 12px 12px 4px;
    max-width: min(92%, 300px);
}

.faq-widget .faq-msg-user .faq-msg-body {
    background: var(--faq-orange);
    color: #fff;
    border: none;
    border-radius: 12px 12px 4px 12px;
    max-width: min(88%, 280px);
}

.faq-widget .faq-msg-time {
    font-size: 11px;
    color: var(--faq-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.faq-widget .faq-msg-user .faq-msg-time {
    text-align: right;
}

.faq-widget .faq-msg-bot .faq-msg-body p {
    margin: 0 0 6px;
}

.faq-widget .faq-msg-bot .faq-msg-body p:last-child {
    margin-bottom: 0;
}

.faq-widget .faq-msg-bot .faq-msg-body ul {
    margin: 4px 0 6px;
    padding-left: 18px;
}

.faq-widget .faq-msg-bot .faq-msg-body a {
    color: var(--faq-orange);
    font-weight: 500;
    text-decoration: underline;
}

.faq-widget .faq-msg-streaming .faq-msg-body {
    white-space: pre-wrap;
}

.faq-widget .faq-msg-streaming .faq-msg-body::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--faq-orange);
    animation: faq-cursor-blink 0.9s step-end infinite;
}

@keyframes faq-cursor-blink {
    50% { opacity: 0; }
}

.faq-widget .faq-typing-dots {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.faq-widget .faq-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa3ab;
    animation: faq-typing-bounce 1.2s ease-in-out infinite;
}

.faq-widget .faq-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.faq-widget .faq-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes faq-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.faq-widget .faq-panel-footer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid var(--faq-border);
    padding: 0 12px 12px;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
}

.faq-widget .faq-quick-replies {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 0 4px;
    overflow: visible;
    max-width: 100%;
}

.faq-widget .faq-quick-replies--hidden {
    display: none;
}

.faq-widget .faq-chip {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--faq-orange);
    border-radius: var(--faq-radius-pill);
    background: var(--faq-orange-light);
    color: var(--faq-orange);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: normal;
    box-sizing: border-box;
}

.faq-widget .faq-chip:hover {
    background: var(--faq-orange);
    color: #fff;
}

.faq-widget .faq-chip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.faq-widget .faq-chip--lead {
    display: block;
    width: 100%;
    margin: 4px 0 0;
    background: var(--faq-orange);
    border-color: var(--faq-orange);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(242, 101, 35, 0.35);
}

.faq-widget .faq-chip--lead:hover {
    background: var(--faq-orange-hover);
    border-color: var(--faq-orange-hover);
    color: #fff;
    box-shadow: 0 4px 12px rgba(242, 101, 35, 0.45);
}

.faq-widget .faq-lead-panel {
    padding: 8px 0 4px;
}

.faq-widget .faq-lead-panel--hidden {
    display: none;
}

.faq-widget .faq-lead-intro {
    font-size: 12px;
    line-height: 1.45;
    color: var(--faq-text);
    margin: 0 0 10px;
}

.faq-widget .faq-lead-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.faq-widget .faq-lead-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--faq-text-muted);
}

.faq-widget .faq-lead-field em {
    font-weight: 400;
    font-style: normal;
}

.faq-widget .faq-lead-field input {
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    padding: 10px 12px;
    border: 1px solid var(--faq-border);
    border-radius: 10px;
    color: var(--faq-text);
    background: #fff;
    box-sizing: border-box;
    width: 100%;
}

.faq-widget .faq-lead-field input:focus {
    outline: none;
    border-color: var(--faq-orange);
    box-shadow: 0 0 0 2px rgba(242, 101, 35, 0.15);
}

.faq-widget .faq-lead-field--phone .faq-phone-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.faq-widget .faq-country-select {
    flex: 0 0 auto;
    max-width: 42%;
    min-width: 108px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 8px;
    border: 1px solid var(--faq-border);
    border-radius: 10px;
    color: var(--faq-text);
    background: #fff;
    cursor: pointer;
}

.faq-widget .faq-country-select:focus {
    outline: none;
    border-color: var(--faq-orange);
    box-shadow: 0 0 0 2px rgba(242, 101, 35, 0.15);
}

.faq-widget .faq-phone-input-row input[type="tel"] {
    flex: 1;
    min-width: 0;
}

.faq-widget .faq-lead-error {
    font-size: 12px;
    color: #c0392b;
    margin: 0;
    min-height: 0;
}

.faq-widget .faq-lead-error:not(:empty) {
    min-height: 16px;
}

.faq-widget .faq-lead-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.faq-widget .faq-lead-submit {
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 16px;
    border: none;
    border-radius: var(--faq-radius-pill);
    background: var(--faq-orange);
    color: #fff;
    cursor: pointer;
}

.faq-widget .faq-lead-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.faq-widget .faq-lead-cancel {
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--faq-text-muted);
    cursor: pointer;
    text-decoration: underline;
}

.faq-widget .faq-panel-footer--lead-open .faq-input-row {
    display: none;
}

.faq-widget .faq-remaining {
    font-size: 11px;
    color: var(--faq-text-muted);
    text-align: center;
    padding: 4px 0 0;
    margin: 0;
    min-height: 16px;
}

.faq-widget .faq-remaining:empty {
    display: none;
}

.faq-widget .faq-whatsapp-link {
    display: none;
}

.faq-widget .faq-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 0 0;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.faq-widget .faq-input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    max-height: 100px;
    resize: none;
    border: 1px solid var(--faq-border);
    border-radius: var(--faq-radius-pill);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    background: #fff;
    color: var(--faq-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.faq-widget .faq-input::placeholder {
    color: var(--faq-text-muted);
}

.faq-widget .faq-input:focus {
    outline: none;
    border-color: var(--faq-orange);
    box-shadow: 0 0 0 2px rgba(242, 101, 35, 0.2);
}

.faq-widget .faq-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    border-radius: 10px;
    background: #fff;
    color: var(--faq-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    border: 1px solid var(--faq-border);
    transition: background 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
}

.faq-widget .faq-send-btn:hover:not(:disabled) {
    background: var(--faq-orange-light);
    color: var(--faq-orange);
    border-color: var(--faq-orange);
}

.faq-widget .faq-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.faq-widget .faq-footer-note {
    font-size: 10px;
    color: var(--faq-text-muted);
    text-align: center;
    padding: 8px 0 0;
    margin: 0;
    line-height: 1.35;
}

/* Embed page */
body.faq-embed {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: transparent;
}

body.faq-embed .faq-widget {
    position: relative;
    width: 100%;
    height: 100%;
}

body.faq-embed .faq-dock {
    right: 16px;
    bottom: 16px;
}

body.faq-embed .faq-panel {
    right: 16px;
    bottom: calc(16px + var(--faq-dock-stack) + 12px);
    width: min(400px, calc(100vw - 32px));
    max-height: min(560px, calc(100dvh - 120px));
}

body.hide-public-chat-fabs .faq-widget {
    display: none !important;
}

@media (max-width: 767px) {
    .faq-widget .faq-panel,
    body.faq-embed .faq-panel {
        right: max(10px, env(safe-area-inset-right, 0px));
        left: max(10px, env(safe-area-inset-left, 0px));
        width: auto;
        max-height: min(72dvh, calc(100dvh - 120px));
    }

    .faq-dock {
        right: max(12px, env(safe-area-inset-right, 0px));
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }

    .faq-dock-btn {
        font-size: 13px;
        padding: 10px 16px;
    }
}
