/* Form AI Widget Styles */

/* Reset i podstawowe style */
.form-ai-widget * {
    box-sizing: border-box;
}

/* Pozycjonowanie widgetu */
.form-ai-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.form-ai-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.form-ai-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.form-ai-position-top-right {
    top: 20px;
    right: 20px;
}

.form-ai-position-top-left {
    top: 20px;
    left: 20px;
}

/* Ikona agenta AI */
.form-ai-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
}

.form-ai-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.form-ai-icon-emoji {
    font-size: 24px;
    line-height: 1;
}

/* Chmurka z wiadomością */
.form-ai-bubble {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: white;
    border-radius: 20px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 200px;
    animation: form-ai-bubble-appear 0.3s ease;
}

.form-ai-position-bottom-left .form-ai-bubble {
    right: auto;
    left: 0;
}

.form-ai-position-top-right .form-ai-bubble {
    bottom: auto;
    top: 70px;
}

.form-ai-position-top-left .form-ai-bubble {
    bottom: auto;
    top: 70px;
    right: auto;
    left: 0;
}

.form-ai-bubble-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-ai-bubble-icon {
    font-size: 16px;
}

.form-ai-bubble-content p {
    margin: 0;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

.form-ai-bubble-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}

.form-ai-position-bottom-right .form-ai-bubble-arrow,
.form-ai-position-bottom-left .form-ai-bubble-arrow {
    bottom: -16px;
    border-top-color: white;
}

.form-ai-position-top-right .form-ai-bubble-arrow,
.form-ai-position-top-left .form-ai-bubble-arrow {
    top: -16px;
    border-bottom-color: white;
}

.form-ai-position-bottom-right .form-ai-bubble-arrow {
    right: 20px;
}

.form-ai-position-bottom-left .form-ai-bubble-arrow {
    left: 20px;
}

.form-ai-position-top-right .form-ai-bubble-arrow {
    right: 20px;
}

.form-ai-position-top-left .form-ai-bubble-arrow {
    left: 20px;
}

/* Okno czatu */
.form-ai-chat {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    max-height: 500px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: form-ai-chat-appear 0.3s ease;
}

.form-ai-position-bottom-left .form-ai-chat {
    right: auto;
    left: 0;
}

.form-ai-position-top-right .form-ai-chat {
    bottom: auto;
    top: 70px;
}

.form-ai-position-top-left .form-ai-chat {
    bottom: auto;
    top: 70px;
    right: auto;
    left: 0;
}

.form-ai-chat.show {
    display: flex;
}

/* Header czatu */
.form-ai-chat-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.form-ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.form-ai-avatar {
    font-size: 20px;
}

.form-ai-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.form-ai-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* Wiadomości */
.form-ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 200px;
}

.form-ai-message {
    margin-bottom: 15px;
}

.form-ai-message-bot .form-ai-message-content {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    color: #333;
    line-height: 1.4;
    max-width: 80%;
}

.form-ai-message-user .form-ai-message-content {
    background: #007cba;
    color: white;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    margin-left: auto;
    max-width: 80%;
    line-height: 1.4;
}

/* Formularz */
.form-ai-chat-form {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.form-ai-step {
    display: none !important;
}

.form-ai-step.active {
    display: block !important;
}

/* Ukryj formularz na starcie */
.form-ai-chat-form {
    display: none;
}

.form-ai-chat-form.show {
    display: block;
}

.step-title h3 {
    margin: 0 0 20px 0;
    font-weight: 600;
}

/* Rozmiary czcionek */
.form-ai-font-small {
    font-size: 12px !important;
}

.form-ai-font-medium {
    font-size: 14px !important;
}

.form-ai-font-large {
    font-size: 16px !important;
}

.form-ai-title-small {
    font-size: 14px !important;
}

.form-ai-title-medium {
    font-size: 16px !important;
}

.form-ai-title-large {
    font-size: 18px !important;
}

.form-ai-title-xlarge {
    font-size: 20px !important;
}

/* Wymuszenie kolorów tekstu - bardzo specyficzne selektory */
#form-ai-widget .form-ai-chat,
#form-ai-widget .form-ai-chat * {
    color: inherit !important;
}

#form-ai-widget .form-ai-chat .form-ai-message-content,
#form-ai-widget .form-ai-chat .step-title h3,
#form-ai-widget .form-ai-chat .form-ai-field label,
#form-ai-widget .form-ai-chat .form-ai-field input,
#form-ai-widget .form-ai-chat .form-ai-field textarea,
#form-ai-widget .form-ai-chat .form-ai-field select,
#form-ai-widget .form-ai-chat .radio-group label,
#form-ai-widget .form-ai-chat .checkbox-group label,
#form-ai-widget .form-ai-chat .form-ai-field input[type="text"],
#form-ai-widget .form-ai-chat .form-ai-field input[type="email"],
#form-ai-widget .form-ai-chat .form-ai-field input[type="tel"],
#form-ai-widget .form-ai-chat .form-ai-field textarea,
#form-ai-widget .form-ai-chat .form-ai-field select {
    color: inherit !important;
}

/* Wymuszenie kolorów dla nagłówka */
#form-ai-widget .form-ai-chat-header,
#form-ai-widget .form-ai-chat-header *,
#form-ai-widget .form-ai-chat-title,
#form-ai-widget .form-ai-chat-title *,
#form-ai-widget .form-ai-close {
    color: inherit !important;
}

/* Wymuszenie kolorów dla przycisków */
#form-ai-widget .form-ai-btn,
#form-ai-widget .form-ai-btn-primary,
#form-ai-widget .form-ai-btn-secondary {
    color: inherit !important;
}

.step-fields {
    margin-bottom: 20px;
}

/* Pola formularza */
.form-ai-field {
    margin-bottom: 15px;
}

.form-ai-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-ai-field .required {
    color: #e74c3c;
}

.form-ai-field input,
.form-ai-field textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.form-ai-field input:focus,
.form-ai-field textarea:focus {
    outline: none;
    border-color: #007cba;
}

.form-ai-field textarea {
    resize: vertical;
    min-height: 80px;
}

/* Grupy opcji */
.form-ai-radio-group,
.form-ai-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.form-ai-radio-option,
.form-ai-checkbox-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-ai-radio-option:hover,
.form-ai-checkbox-option:hover {
    border-color: #007cba;
    background: rgba(0, 124, 186, 0.05);
}

.form-ai-radio-option input[type="radio"],
.form-ai-checkbox-option input[type="checkbox"] {
    margin: 0 10px 0 0;
    width: auto;
}

.form-ai-radio-option input[type="radio"]:checked + .radio-text,
.form-ai-checkbox-option input[type="checkbox"]:checked + .checkbox-text {
    font-weight: 600;
    color: #007cba;
}

.form-ai-radio-option:has(input[type="radio"]:checked),
.form-ai-checkbox-option:has(input[type="checkbox"]:checked) {
    border-color: #007cba;
    background: rgba(0, 124, 186, 0.1);
}

/* Lista rozwijana */
.form-ai-field select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    font-family: inherit;
    background: white;
}

.form-ai-field select:focus {
    outline: none;
    border-color: #007cba;
}

/* Akcje po wypełnieniu */
.form-ai-success-actions {
    text-align: center;
    margin-top: 20px;
}

.form-ai-success-actions .form-ai-btn {
    display: inline-block;
    text-decoration: none;
}

/* Błędy */
.form-ai-error {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.form-ai-error.show {
    display: block;
}

/* Nawigacja */
.form-ai-navigation {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-ai-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
}

.form-ai-btn-primary {
    border: none;
    transition: all 0.2s ease;
}

.form-ai-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.form-ai-btn-secondary {
    border: 2px solid #e1e5e9;
    transition: all 0.2s ease;
}

.form-ai-btn-secondary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Overlay dla mobilnych */
.form-ai-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999998;
    display: none;
}

/* Animacje */
@keyframes form-ai-bubble-appear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes form-ai-chat-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Animacje agenta AI */
@keyframes form-ai-bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes form-ai-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes form-ai-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes form-ai-wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(5deg); }
    75% { transform: rotate(-5deg); }
}

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

@keyframes form-ai-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes form-ai-scale-in {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Klasy animacji */
.form-ai-animation-bounce { animation: form-ai-bounce 1s infinite; }
.form-ai-animation-pulse { animation: form-ai-pulse 2s infinite; }
.form-ai-animation-shake { animation: form-ai-shake 0.5s infinite; }
.form-ai-animation-wiggle { animation: form-ai-wiggle 1s infinite; }

/* Animacje okna czatu */
.form-ai-chat-animation-slide.show { animation: form-ai-slide-in 0.3s ease; }
.form-ai-chat-animation-fade.show { animation: form-ai-fade-in 0.3s ease; }
.form-ai-chat-animation-scale.show { animation: form-ai-scale-in 0.3s ease; }

/* Responsywność */
@media (max-width: 768px) {
    .form-ai-chat {
        width: calc(100vw - 40px);
        max-width: 350px;
        bottom: 80px;
        right: 20px;
        left: 20px;
        position: fixed;
    }
    
    .form-ai-position-bottom-left .form-ai-chat,
    .form-ai-position-top-left .form-ai-chat {
        right: 20px;
        left: 20px;
    }
    
    .form-ai-position-top-right .form-ai-chat,
    .form-ai-position-top-left .form-ai-chat {
        bottom: auto;
        top: 80px;
    }
    
    .form-ai-widget {
        bottom: 20px;
        right: 20px;
        left: auto;
        top: auto;
    }
    
    .form-ai-position-bottom-left .form-ai-widget {
        left: 20px;
        right: auto;
    }
    
    .form-ai-position-top-right .form-ai-widget {
        top: 20px;
        bottom: auto;
    }
    
    .form-ai-position-top-left .form-ai-widget {
        top: 20px;
        left: 20px;
        right: auto;
        bottom: auto;
    }
    
    .form-ai-bubble {
        max-width: calc(100vw - 100px);
    }
}

@media (max-width: 480px) {
    .form-ai-chat {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
    }
    
    .form-ai-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .form-ai-position-bottom-left .form-ai-widget {
        left: 15px;
        right: auto;
    }
    
    .form-ai-icon {
        width: 50px;
        height: 50px;
    }
    
    .form-ai-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* Ukryj na bardzo małych ekranach */
@media (max-width: 320px) {
    .form-ai-chat {
        width: calc(100vw - 10px);
        right: 5px;
        left: 5px;
    }
}

/* Dostępność */
.form-ai-widget:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.form-ai-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Tryb ciemny (opcjonalny) */
@media (prefers-color-scheme: dark) {
    .form-ai-bubble {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .form-ai-bubble-arrow {
        border-top-color: #2d3748;
    }
    
    .form-ai-chat-header {
        background: rgba(255, 255, 255, 0.05);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .form-ai-chat-title {
        color: #e2e8f0;
    }
    
    .form-ai-close {
        color: #a0aec0;
    }
    
    .form-ai-close:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #e2e8f0;
    }
    
    .form-ai-message-bot .form-ai-message-content {
        background: rgba(255, 255, 255, 0.05);
        color: #e2e8f0;
    }
    
    .form-ai-step p {
        color: #e2e8f0;
    }
    
    .form-ai-field label {
        color: #e2e8f0;
    }
    
    .form-ai-field input,
    .form-ai-field textarea {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: #e2e8f0;
    }
    
    .form-ai-field input:focus,
    .form-ai-field textarea:focus {
        border-color: #007cba;
    }
    
    .form-ai-product-option {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: #e2e8f0;
    }
    
    .form-ai-product-option:hover {
        background: rgba(0, 124, 186, 0.1);
    }
    
    .form-ai-btn-secondary {
        background: rgba(255, 255, 255, 0.05);
        color: #e2e8f0;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .form-ai-btn-secondary:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}
