body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f8;
    margin: 0;
    padding: 20px;
}

/* Resetuje dziedziczone style z zewnętrznej strony gdy widget działa jako Shadow DOM */
:host {
    all: initial;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #1a1a1a;
}

/* --- Przycisk otwierania czatu --- */
.chat-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #790026;
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease-in-out;
    z-index: 1000;
}

.chat-toggle-button:hover {
    transform: scale(1.1);
}

/* --- Wskaźnik nieprzeczytanej wiadomości --- */
.dw-unread-badge {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 22px;
    height: 22px;
    background-color: #007bff;
    border-radius: 50%;
    display: none;
    box-sizing: border-box;
}

.chat-toggle-button.has-unread .dw-unread-badge {
    display: block;
    animation: dwBadgePulse 1.5s ease-in-out infinite;
}

@keyframes dwBadgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* --- Kontener czatu --- */
.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 90%;
    max-width: 400px;
    height: 80vh;
    max-height: 600px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 1001;

    /* Animacja pojawiania się */
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0.3s;
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Klasa ukrywająca czat */
.chat-container.hidden {
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Ważne: żeby nie dało się klikać jak jest ukryty */
}

/* --- Header --- */
header {
    padding: 12px 16px;
    background-color: #790026;
    color: white;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.1rem;
    flex-grow: 1;
    text-align: center;
}

#close-chat-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0 5px;
}

/* --- Okno wiadomości --- */
.chat-window {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 85%;
    line-height: 1.4;
    width: fit-content;
    word-wrap: break-word;
}

.user-message {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.bot-message {
    background-color: #e9e9eb;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Markdown styling inside bot messages */
.bot-message h1, .bot-message h2, .bot-message h3 { margin: .25rem 0 .5rem; font-weight: 700; font-size: 1.1em; }
.bot-message p { margin: .25rem 0 .5rem; }
.bot-message ul, .bot-message ol { margin: .25rem 0 .5rem 1.25rem; padding-left: 1rem; }
.bot-message code { font-family: monospace; padding: .1rem .25rem; border-radius: .25rem; background: rgba(0,0,0,.08); }

.typing-indicator {
    color: #888;
    font-style: italic;
    background: none !important;
    padding-left: 0;
}

/* --- Karty Produktów (Scalone i poprawione) --- */
.bot-message.product-card {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    padding: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    width: 85%; /* Szerokość karty */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-image {
    width: 100%;
    max-height: 220px;
    aspect-ratio: 3 / 4; /* Utrzymuje proporcje */
    object-fit: contain;
    border-radius: 4px;
    background: #fff;
    margin: 0 auto;
    display: block;
}

.product-title { margin: 0; font-size: 1rem; }
.product-title a { text-decoration: none; color: #0056b3; }
.product-title a:hover { text-decoration: underline; }

.product-price { font-size: 0.95rem; margin: 0; }
.product-price .price-old { text-decoration: line-through; opacity: 0.6; margin-right: 8px; font-size: 0.9em; }
.product-price .price-promo { font-weight: bold; color: #790026; }

.product-description {
    font-size: 0.85rem;
    color: #555;
    margin: 0;
}

/* --- Footer & Input --- */
footer { border-top: 1px solid #ddd; }
.chat-form { display: flex; padding: 16px; gap: 10px; }

#message-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 1rem;
}

#send-button {
    border: none;
    background-color: #790026;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s, opacity 0.2s;
}

#send-button:disabled {
    background-color: #b5788a;
    opacity: 0.65;
    cursor: not-allowed;
}

/* Ukrywanie inputu przy blokadzie */
.hidden-footer { display: none !important; }

/* --- Formularz Inline (Kontakt) --- */
.bot-message.form-container {
    background-color: #f8f9fa;
    border: 1px solid #dae0e5;
    width: 85%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.inline-lead-form input,
.inline-lead-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
    margin-bottom: 5px;
    font-family: inherit;
}

.inline-lead-form textarea { resize: vertical; min-height: 60px; }

.inline-lead-form button {
    background-color: #790026;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
}

.inline-lead-form button:hover { background-color: #5a001c; }
.inline-lead-form button:disabled { background-color: #ccc; cursor: not-allowed; }

.form-success-message {
    color: #2e7d32;
    font-weight: bold;
    text-align: center;
    padding: 10px;
}
/* style.css - dodaj na końcu */

/* Kontener dla kropek */
.typing-indicator-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 0; /* Trochę oddechu */
    min-width: 40px;
}

/* Styl pojedynczej kropki */
.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #790026; /* Twój kolor firmowy */
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

/* Opóźnienia animacji dla efektu fali */
.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}
.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Sama animacja pulsowania */
@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Nadpisanie starego stylu indicatora, żeby wyglądał jak dymek */
.typing-indicator {
    font-style: normal !important; /* Kasujemy kursywę */
    color: inherit !important;
    display: flex;
    align-items: center;
}
/* Wyróżniona karta szczegółów */
.product-details-highlight {
    border: 2px solid #790026; /* Bordowa ramka */
    background-color: #fff5f5; /* Bardzo jasne tło */
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.product-details-highlight .product-image {
    max-height: 250px; /* Większe zdjęcie niż na liście */
    width: auto;
    margin: 0 auto 15px auto;
    display: block;
}
/* Stylizacja przycisków w nagłówku */
.header-icon-btn {
    background: none;
    border: none;
    color: white; /* Kolor ikony dopasowany do nagłówka */
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    font-size: 1.2rem; /* Dla krzyżyka zamykania */
}

.header-icon-btn:hover {
    opacity: 0.8;
}

/* Kontener selektora języka */
.language-selector {
    position: relative;
    margin-right: 10px; /* Odstęp od przycisku zamykania */
}

/* Rozwijane menu */
.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    overflow: hidden;
    min-width: 120px;
    z-index: 1000;
    border: 1px solid #eee;

    /* Animacja */
    transform-origin: top right;
    transition: all 0.2s ease-in-out;
    opacity: 1;
    transform: scale(1);
}

/* Stan ukryty */
.lang-dropdown.hidden {
    display: none; /* Proste ukrywanie, można zmienić na opacity/visibility dla animacji */
}

/* Opcje w menu */
.lang-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 15px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9em;
    color: #333;
    transition: background 0.2s;
}

.lang-option:hover {
    background-color: #f5f5f5;
}

/* Wyróżnienie aktywnego języka */
.lang-option.active {
    font-weight: bold;
    color: #800020; /* Kolor wina */
    background-color: #fff0f0;
}

/* === Kafelki podpowiedzi (suggestion chips) === */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: flex-start;
    max-width: 85%;
    margin: 4px 0 2px;
}

.suggestion-chip {
    border: 1px solid #790026;
    background: #fff;
    color: #790026;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.suggestion-chip:hover {
    background: #790026;
    color: #fff;
}

.suggestion-chip:disabled {
    opacity: 0.7;
    cursor: default;
}

/* === Disclaimer prawny (nad inputem, znika po 1. wiadomości) === */
.chat-disclaimer {
    font-size: 0.72rem;
    color: #999;
    text-align: center;
    padding: 6px 16px 0;
    line-height: 1.3;
}

.chat-disclaimer.hidden-disclaimer {
    display: none;
}

/* === Poziom słodkości na karcie produktu === */
.product-sweetness {
    font-size: 0.85rem;
    color: #555;
    margin: 0;
}