/* ==========================================================================
   Agile Ask to AI — Widget Styles
   Scoped under #aata-widget to avoid conflicts with any theme.
   ========================================================================== */

/* ---- Reset for our elements ---- */
#aata-widget,
#aata-widget * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.4;
}

/* ---- Floating trigger button ---- */
#aata-trigger {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
    animation: aata-slide-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

#aata-trigger::before,
#aata-trigger::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(52, 52, 117, 0.18);
    opacity: 0;
    animation: aata-ripple 3.5s ease-out 2s infinite;
    pointer-events: none;
}

#aata-trigger::after {
    animation-delay: 2.75s;
}

#aata-trigger:hover::before,
#aata-trigger:hover::after,
#aata-trigger:focus::before,
#aata-trigger:focus::after {
    animation: none;
    opacity: 0;
}

#aata-trigger:hover,
#aata-trigger:focus {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.04);
    outline: none;
}

#aata-trigger img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
}

#aata-trigger span {
    font-size: 28px;
    line-height: 1;
}

/* ---- Trigger animations ---- */
@keyframes aata-slide-in {
    0% {
        opacity: 0;
        transform: translateY(60px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes aata-ripple {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* ---- Chat panel (main container) ----
   Flexbox container that limits height based on viewport.
   Prevents panel from exceeding viewport on small screens.
   Dynamic Viewport Height (100dvh) used for mobile Safari compatibility. */
#aata-panel {
    position: fixed;
    bottom: 92px;
    left: 24px;
    z-index: 999999;
    width: 320px;
    max-width: calc(100vw - 48px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 20px 20px 0;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    /* Flexbox layout for scrollable child views */
    display: flex;
    flex-direction: column;
    /* Height limited to fit in viewport with trigger button below */
    max-height: calc(100vh - 108px);           /* Fallback: 100vh browsers */
    max-height: calc(100dvh - 108px);          /* Correct: Dynamic viewport height (mobile Safari) */
    overflow: hidden;                           /* Hide overflow; let child views handle scrolling */
}

#aata-panel.aata-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ---- Panel views: flex containers for each view (home/ai/form) ----
   Each view is a flex column that occupies available space in the panel.
   min-height: 0 is CRITICAL for flexbox overflow to work correctly. */
#aata-view-home,
#aata-view-ai,
#aata-view-form {
    display: flex;
    flex-direction: column;
    overflow: hidden;                       /* Hide overflow; let .aata-view-body handle scrolling */
    flex: 1;                                /* Grow to fill available panel space */
    min-height: 0;                          /* CRITICAL: allows flex items to shrink below content size */
}

/* ---- View body: scrollable content area ----
   Direct child of each view containing the actual content.
   This is the only scrollable element within each view. */
.aata-view-body {
    flex: 1;                                /* Grow to fill view height */
    overflow-y: auto;                       /* Enable vertical scrolling */
    overflow-x: hidden;                     /* Prevent horizontal overflow */
    min-height: 0;                          /* CRITICAL: same as parent flex items */
    padding-bottom: 24px;                   /* Space at bottom of scrollable content */
    padding-right: 8px;                     /* Account for scrollbar space */
}

/* ---- Scrollbar styling for .aata-view-body (webkit browsers) ---- */
.aata-view-body::-webkit-scrollbar {
    width: 4px;
}

.aata-view-body::-webkit-scrollbar-track {
    background: transparent;
}

.aata-view-body::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.aata-view-body::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* ---- Panel header (title/back + close on same row) ---- */
.aata-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.aata-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
    flex-shrink: 0;
}

.aata-close-btn:hover,
.aata-close-btn:focus {
    color: #333;
    outline: none;
}

/* ---- Greeting / titles ---- */
.aata-greeting {
    font-size: 16px;
    font-weight: 600;
    color: #343475;
    margin: 0;
}

/* ---- Description text ---- */
.aata-description {
    font-size: 13px;
    line-height: 1.6;
    color: #555;
    margin: 0 0 16px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ---- Option block (home view) ---- */
.aata-option-block {
    font-size: 12px;
    line-height: 1.55;
    color: #666;
    margin: 0 0 10px;
    padding: 14px 16px;
    background: #F7F7F7;
    border-radius: 10px;
    border: none;
    word-wrap: break-word;
}

.aata-option-block .aata-block-title {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #343475;
    margin-bottom: 2px;
}

.aata-option-block .aata-block-subtitle {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.aata-option-block .aata-block-body {
    display: block;
    font-size: 12px;
    color: #777;
}

.aata-view-title {
    font-size: 15px;
    font-weight: 600;
    color: #343475;
    margin: 0 0 6px;
}

.aata-view-sub {
    font-size: 12px;
    color: #666;
    margin: 0 0 14px;
}

/* ---- Main choice buttons ---- */
.aata-choice-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 24px;
    border-radius: 12px;
    border: none;
    background: #343475;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(52, 52, 117, 0.15);
}

.aata-choice-btn:last-child {
    margin-bottom: 0;
}

.aata-choice-btn:hover,
.aata-choice-btn:focus {
    background: #2a2a60;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 52, 117, 0.25);
    outline: none;
}

/* ---- Back link ---- */
.aata-back {
    background: none;
    border: none;
    color: #F45E2D;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    display: block;
    transition: opacity 0.15s;
}

.aata-back:hover,
.aata-back:focus {
    opacity: 0.75;
    outline: none;
}

/* ---- AI provider links ---- */
.aata-providers {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aata-provider-link {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: #F7F7F7;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.aata-provider-link:hover,
.aata-provider-link:focus {
    border-color: #343475;
    background: #ffffff;
    outline: none;
}

/* ---- Form container ----
   Wrapper for language-specific form instances.
   Scrolling is handled by parent .aata-view-body, not this container. */
#aata-form-container {
    margin-top: 8px;
}

/* ---- Fluent Forms overrides (scoped to widget) ---- */

/* Field groups spacing */
#aata-form-container .ff-el-group {
    margin-bottom: 14px !important;
}

/* Labels */
#aata-form-container .ff-el-input--label label,
#aata-form-container .ff-el-input--label .ff-el-input--label {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #343475 !important;
    margin-bottom: 4px !important;
}

/* Text inputs, textareas, selects */
#aata-form-container .ff-el-form-control,
#aata-form-container input[type="text"],
#aata-form-container input[type="email"],
#aata-form-container input[type="tel"],
#aata-form-container input[type="url"],
#aata-form-container input[type="number"],
#aata-form-container textarea,
#aata-form-container select {
    font-size: 13px !important;
    padding: 9px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    background: #F7F7F7 !important;
    color: #1a1a1a !important;
    transition: border-color 0.2s ease, background 0.2s ease !important;
    width: 100% !important;
    box-shadow: none !important;
}

#aata-form-container .ff-el-form-control:focus,
#aata-form-container input:focus,
#aata-form-container textarea:focus,
#aata-form-container select:focus {
    border-color: #343475 !important;
    background: #ffffff !important;
    outline: none !important;
    outline-width: 0 !important;
    box-shadow: 0 0 0 3px rgba(52, 52, 117, 0.08) !important;
}

/* Kill browser default focus outline on all form elements */
#aata-form-container *:focus {
    outline: none !important;
    outline-width: 0 !important;
}

/* Textarea height */
#aata-form-container textarea {
    min-height: 80px !important;
    resize: vertical !important;
}

/* Placeholder */
#aata-form-container ::placeholder {
    color: #aaa !important;
    font-size: 12px !important;
}

/* Submit button */
#aata-form-container .ff-btn-submit,
#aata-form-container button[type="submit"] {
    width: 100% !important;
    padding: 11px 16px !important;
    border: none !important;
    border-radius: 10px !important;
    background: #343475 !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    text-align: center !important;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease !important;
    box-shadow: 0 2px 8px rgba(52, 52, 117, 0.15) !important;
    margin-top: 4px !important;
}

#aata-form-container .ff-btn-submit:hover,
#aata-form-container button[type="submit"]:hover {
    background: #2a2a60 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(52, 52, 117, 0.25) !important;
}

/* Checkboxes, radios, terms & conditions */
#aata-form-container .ff-el-form-check label,
#aata-form-container .ff_tc_wrap label,
#aata-form-container .ff_t_c {
    font-size: 11px !important;
    color: #666 !important;
    line-height: 1.5 !important;
}

/* Privacy/disclaimer text blocks */
#aata-form-container .ff-el-section-break,
#aata-form-container .ff-custom_html,
#aata-form-container .ff-el-group p,
#aata-form-container .ff_tc_wrap,
#aata-form-container .ff-el-tc {
    font-size: 11px !important;
    color: #888 !important;
    line-height: 1.5 !important;
    margin-top: 8px !important;
}

/* Links inside form (e.g. "informativa privacy") */
#aata-form-container a {
    color: #343475 !important;
    text-decoration: underline !important;
    font-weight: 500 !important;
}

#aata-form-container a:hover {
    color: #F45E2D !important;
}

/* Error messages */
#aata-form-container .ff-el-is-error .ff-el-form-control,
#aata-form-container .ff-el-is-error input {
    border-color: #c0392b !important;
}

#aata-form-container .error.text-danger,
#aata-form-container .ff_error_msg {
    font-size: 11px !important;
    color: #c0392b !important;
    margin-top: 4px !important;
}

/* Success message */
#aata-form-container .ff-message-success {
    font-size: 13px !important;
    color: #7AB52F !important;
    background: rgba(122, 181, 47, 0.08) !important;
    border-radius: 8px !important;
    padding: 12px !important;
    border: none !important;
}

/* Hide unnecessary Fluent Form chrome */
#aata-form-container .ff-form-loading {
    font-size: 12px !important;
    color: #888 !important;
}

/* Scrollbar styling */
#aata-form-container::-webkit-scrollbar {
    width: 4px;
}

#aata-form-container::-webkit-scrollbar-track {
    background: transparent;
}

#aata-form-container::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

#aata-form-container::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* ---- Loading / error states ---- */
.aata-loading,
.aata-error {
    font-size: 13px;
    color: #888;
    margin: 0;
    padding: 8px 0;
}

.aata-error {
    color: #c0392b;
}

/* ---- Mobile: narrow screens (< 480px width) ----
   Panel spans full width with small margins.
   Height adjusted for mobile keyboard space. */
@media (max-width: 480px) {
    #aata-panel {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        bottom: 86px;
        max-height: calc(100dvh - 100px);      /* Tighter height for mobile */
    }

    #aata-trigger {
        bottom: 16px;
        left: 16px;
    }
}

/* ---- Low-height screens: landscape mode and short displays ----
   Triggered when viewport height < 500px (e.g., landscape mobile).
   Reduces panel height and adjusts positioning. */
@media (max-height: 500px) {
    #aata-panel {
        max-height: calc(100dvh - 88px);      /* Even tighter for short screens */
        bottom: 80px;                         /* Reduce bottom gap */
    }

    #aata-trigger {
        bottom: 12px;                         /* Bring trigger higher */
    }
}
