/**
 * Public styles for Formaloo Multilingual Forms
 */

/* Form container */
.fml-form-container {
    max-width: 600px;
    margin: 20px 0;
}

.fml-form-title {
    margin-bottom: 20px;
    color: #333;
}

/* Form fields */
.fml-form-field {
    margin-bottom: 20px;
}

.fml-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.fml-required {
    color: #d63638;
}

/* Input fields */
.fml-input,
.fml-textarea,
.fml-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.fml-input:focus,
.fml-textarea:focus,
.fml-select:focus {
    outline: none;
    border-color: #0073aa;
}

.fml-input.error,
.fml-textarea.error,
.fml-select.error {
    border-color: #d63638;
}

.fml-checkbox.error,
.fml-radio.error {
    outline: 2px solid #d63638;
    outline-offset: 2px;
}

/* Checkbox and radio */
.fml-checkbox-label,
.fml-radio-label {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    cursor: pointer;
}

.fml-checkbox,
.fml-radio {
    margin-right: 8px;
    margin-top: 3px;
    flex-shrink: 0;
}

/* Consent checkbox with HTML content */
.fml-checkbox-label a {
    color: #0073aa;
    text-decoration: underline;
}

.fml-checkbox-label a:hover {
    text-decoration: none;
}

.fml-radio-group {
    display: flex;
    flex-direction: column;
}

/* Submit button */
.fml-form-actions {
    margin-top: 30px;
}

/* Submit button — high specificity to override Elementor */
.fml-form-container button.fml-submit-button,
.fml-submit-button {
    background-color: #0073aa !important;
    color: white !important;
    padding: 12px 24px !important;
    border: none !important;
    border-radius: 4px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    min-height: 0 !important;
    cursor: pointer;
    transition: background-color 0.3s;
    box-shadow: none !important;
}

.fml-form-container button.fml-submit-button:hover,
.fml-submit-button:hover {
    background-color: #005a87 !important;
    color: white !important;
}

.fml-form-container button.fml-submit-button:disabled,
.fml-submit-button:disabled {
    background-color: #ccc !important;
    color: white !important;
    cursor: not-allowed;
}

/* Messages */
.fml-form-messages {
    margin-bottom: 0;
}

.fml-error-message {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Success state */
.fml-success-message {
    padding: 0;
    background: none;
    border: none;
}

.fml-success-state {
    text-align: center;
    padding: 32px 16px;
}

.fml-success-icon {
    color: #28a745;
    margin-bottom: 16px;
}

.fml-success-text {
    font-size: 16px;
    color: #333;
    margin: 0 0 20px;
    line-height: 1.5;
}

.fml-send-another {
    display: inline-block;
    font-size: 14px;
    color: #666;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.fml-send-another:hover {
    color: #333;
}

/* Field errors */
.fml-field-error {
    display: block;
    color: #d63638;
    font-size: 14px;
    margin-top: 5px;
}

.fml-field-error:empty {
    display: none;
}

/* Loading state */
.fml-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,0,0,.1);
    border-radius: 50%;
    border-top-color: #0073aa;
    animation: fml-spin 1s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes fml-spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 600px) {
    .fml-form-container {
        margin: 20px 10px;
    }

    .fml-input,
    .fml-textarea,
    .fml-select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ── Floating Bubble ── */

/* Overlay */
.fml-bubble-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

.fml-bubble-overlay.active {
    display: block;
}

/* Toggle button — high specificity to override Elementor global button styles */
button.fml-bubble-toggle,
.fml-bubble-toggle {
    position: fixed !important;
    z-index: 9999 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 14px 20px !important;
    border: none !important;
    border-radius: 50px !important;
    background-color: var(--fml-bubble-bg, #2271b1) !important;
    color: var(--fml-bubble-color, #fff) !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    min-height: 0 !important;
    cursor: pointer;
    box-shadow: var(--fml-bubble-shadow, 0 4px 12px rgba(0, 0, 0, 0.15)) !important;
    transition: transform 0.2s, box-shadow 0.2s;
    opacity: 0;
    transform: translateY(100px);
    animation: fml-bubble-slide-in 0.5s ease-out 1.5s forwards;
}

button.fml-bubble-toggle:hover,
.fml-bubble-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2) !important;
    background-color: var(--fml-bubble-bg, #2271b1) !important;
    color: var(--fml-bubble-color, #fff) !important;
}

.fml-bubble-toggle.fml-bubble-bottom-right {
    bottom: 20px;
    right: 20px;
}

.fml-bubble-toggle.fml-bubble-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Bubble text — hidden by default, expands on hover */
.fml-bubble-text {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
    transition: max-width 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    padding-right: 0;
}

.fml-bubble-toggle:hover .fml-bubble-text {
    max-width: 200px;
    opacity: 1;
    padding-right: 4px;
}

.fml-bubble-icon {
    flex-shrink: 0;
}

/* Slide-in animation */
@keyframes fml-bubble-slide-in {
    from {
        opacity: 0;
        transform: translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chatbox / Popup */
.fml-bubble-chatbox {
    display: none;
    position: fixed;
    z-index: 9999;
    background: #fff;
    border-radius: var(--fml-bubble-radius, 12px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    width: var(--fml-bubble-width, 350px);
}

.fml-bubble-chatbox.active {
    display: flex;
    flex-direction: column;
}

.fml-bubble-chatbox.fml-bubble-bottom-right {
    bottom: 90px;
    right: 20px;
}

.fml-bubble-chatbox.fml-bubble-bottom-left {
    bottom: 90px;
    left: 20px;
}

/* Size variants */
.fml-bubble-size-small {
    width: 280px;
}

.fml-bubble-size-medium {
    width: 350px;
}

.fml-bubble-size-large {
    width: 420px;
}

/* Header */
.fml-bubble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background-color: var(--fml-bubble-bg, #2271b1);
    color: var(--fml-bubble-header-color, var(--fml-bubble-color, #fff));
}

.fml-bubble-header-text {
    font-size: 16px;
    font-weight: 600;
    color: inherit !important;
}

/* Close button — high specificity to override Elementor global button styles */
button.fml-bubble-close,
.fml-bubble-close {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    color: inherit !important;
    font-size: 24px !important;
    line-height: 1 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    min-height: 0 !important;
    cursor: pointer;
    padding: 0 4px !important;
    opacity: 0.8;
    transition: opacity 0.2s;
    box-shadow: none !important;
}

button.fml-bubble-close:hover,
.fml-bubble-close:hover {
    opacity: 1;
    background: none !important;
    background-color: transparent !important;
    color: inherit !important;
    box-shadow: none !important;
}

/* Content */
.fml-bubble-content {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
}

.fml-bubble-content .fml-form-container {
    max-width: none;
    margin: 0;
}

.fml-bubble-content .fml-form-field {
    margin-bottom: 16px;
}

.fml-bubble-content .fml-form-actions {
    margin-top: 20px;
}

/* ── Theme isolation: force dark text inside chatbox regardless of Elementor/theme ── */
.fml-bubble-chatbox .fml-bubble-content,
.fml-bubble-chatbox .fml-bubble-content * {
    color: #333 !important;
}

.fml-bubble-chatbox .fml-bubble-content label,
.fml-bubble-chatbox .fml-form-field label {
    color: #333 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    display: block !important;
    margin-bottom: 5px !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.fml-bubble-chatbox .fml-bubble-content .fml-required {
    color: #d63638 !important;
}

.fml-bubble-chatbox .fml-bubble-content .fml-input,
.fml-bubble-chatbox .fml-bubble-content .fml-textarea,
.fml-bubble-chatbox .fml-bubble-content .fml-select {
    color: #333 !important;
    background-color: #fff !important;
    border: 1px solid #ddd !important;
}

.fml-bubble-chatbox .fml-bubble-content .fml-input::placeholder,
.fml-bubble-chatbox .fml-bubble-content .fml-textarea::placeholder {
    color: #999 !important;
}

.fml-bubble-chatbox .fml-bubble-content .fml-checkbox-label,
.fml-bubble-chatbox .fml-bubble-content .fml-checkbox-label span,
.fml-bubble-chatbox .fml-bubble-content .fml-radio-label {
    color: #333 !important;
    font-size: 13px !important;
}

.fml-bubble-chatbox .fml-bubble-content a {
    color: #0073aa !important;
}

.fml-bubble-chatbox .fml-bubble-content .fml-field-error {
    color: #d63638 !important;
}

.fml-bubble-chatbox .fml-bubble-content .fml-success-text {
    color: #333 !important;
}

/* Inner elements radius — auto-adjusted from outer chatbox radius */
.fml-bubble-content .fml-input,
.fml-bubble-content .fml-textarea,
.fml-bubble-content .fml-select {
    border-radius: var(--fml-bubble-radius-inner, 4px);
}

/* Submit button inside bubble — high specificity to override Elementor */
.fml-bubble-content button.fml-submit-button,
.fml-bubble-content .fml-submit-button {
    width: 100% !important;
    background-color: #0073aa !important;
    color: white !important;
    padding: 12px 24px !important;
    border: none !important;
    border-radius: var(--fml-bubble-radius-submit, 4px) !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    min-height: 0 !important;
    box-shadow: none !important;
}

.fml-bubble-content button.fml-submit-button:hover,
.fml-bubble-content .fml-submit-button:hover {
    background-color: #005a87 !important;
    color: white !important;
}

.fml-bubble-content button.fml-submit-button:disabled,
.fml-bubble-content .fml-submit-button:disabled {
    background-color: #ccc !important;
    color: white !important;
    cursor: not-allowed;
}

/* Body scroll lock */
body.fml-bubble-open {
    overflow: hidden;
}

/* ── Mobile: fullscreen popup ── */
@media (max-width: 768px) {
    .fml-bubble-chatbox.active {
        width: 100% !important;
        height: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        border-radius: 0;
    }

    .fml-bubble-content {
        max-height: calc(100vh - 60px);
    }

    button.fml-bubble-toggle,
    .fml-bubble-toggle {
        padding: 12px 16px !important;
    }
}