@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
/* =========================================
   1. ZMIENNE I KONFIGURACJA KOLORÓW
   ========================================= */
:root {
    /* Główne kolory marki */
    --primary-color: #4a52f2;
    --primary-gradient: linear-gradient(135deg, #4a5ef2 0%, #18136d 100%);
    --primary-light-bg: #e9eefd; 
    
    /* Cienie */
    --primary-shadow: rgba(74, 105, 242, 0.3);
    --primary-shadow-hover: rgba(74, 130, 242, 0.5);
     
    /* Tła i ogólne */
    --bg-body: #eef2f3;      
    --bg-light: #f8f9fa;     
    --bg-carousel: #f0f0f0;  
    --white: #ffffff;
    --overlay-color: rgba(0, 0, 0, 0.4);
    
    /* Teksty */
    --text-dark: #333333;
    --text-gray: #666666;
    --text-loader: #555555;
    
    /* Obramowania */
    --border-light: #eeeeee;
    --border-input: #dddddd;
    
    /* Inne cienie */
    --shadow-modal: rgba(0, 0, 0, 0.2);
    --shadow-card: rgba(0, 0, 0, 0.08);
    --shadow-msg: rgba(0, 0, 0, 0.05);
}

/* =========================================
   2. ANIMACJE
   ========================================= */
@keyframes slideFromCorner {
    from { opacity: 0; transform: translate(20%, 20%) scale(0); transform-origin: bottom right; }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); transform-origin: bottom right; }
}

@keyframes slideOutToRight {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0; transform: translate(20%, -30%) scale(0.5) rotate(5deg); }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 10px 20px var(--primary-shadow); }
    50% { transform: scale(1.1); box-shadow: 0 15px 25px var(--primary-shadow-hover); }
    100% { transform: scale(1); box-shadow: 0 10px 20px var(--primary-shadow); }
}

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
#chat-dropdown[style*="display: none"] {
        display: none !important;
    }
#chat-content.expanded {
        width: 800px !important; /* Szerokość po powiększeniu */
        
        max-width: 95vw !important;
    }

    @media (max-width: 850px) {
        #chat-content.expanded {
            width: 95vw !important;
            
        }
    }
/* =========================================
   3. GŁÓWNY KONTENER I RESET
   ========================================= */
#wiewior-widget-root {
    font-family: 'Inter', sans-serif !important;
    font-family: inherit;
}

/* Linki wewnątrz wiadomości */
#chat-box a { color: var(--primary-color); text-decoration: none; }

.knowledge-link:hover {
    background-color: var(--primary-light-bg) !important;
    border-color: var(--primary-color) !important;
}

.links-container {
    animation: fadeInUp 0.4s ease-out;
    margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px;
}

.link-chip {
    background: var(--bg-carousel); 
    border: 1px solid var(--border-light); 
    border-radius: 15px; 
    padding: 5px 12px; 
    font-size: 12px; 
    color: var(--text-dark); 
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.link-chip:hover {
    background: var(--primary-light-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.message ul {
    padding: 5px 15px;
}
.message p {
    margin-bottom: 0px !important;
}
.voice-btn {
    background: var(--primary-gradient);
  color: var(--white);
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.3s;
}
.voice-btn svg {
    color: white;
    transition: color 0.2s;
}
.voice-btn:hover { transform: scale(1.05); opacity: 0.9; }
.voice-btn.recording svg {
    color: #e74c3c; /* czerwony gdy nagrywa */
}
 
/* =========================================
   4. PRZYCISK OTWIERAJĄCY (TRIGGER)
   ========================================= */
.button_open_chat_ai {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 24px;
    
    /* Nowoczesny kształt: lekko zaokrąglony prostokąt */
    border-radius: 18px; 
    /* Detal: zaostrzony prawy dolny róg - robi efekt dymka */
    border-bottom-right-radius: 6px; 
    
    background: var(--primary-gradient);
    color: var(--white);
    border: none;
    cursor: pointer;
    z-index: 1000;
    
    display: flex;
    align-items: center;
    gap: 12px;
    
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
    font-family: inherit;
    /* Głęboki, profesjonalny cień */
    box-shadow: 0 10px 25px -5px rgba(24, 19, 109, 0.4);
    
    animation: fadeInUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.button-mute:hover {
    background-color: white;
}
.button-mute { 
    background: rgba(255,255,255,0.2);
  border: none;
  cursor: pointer;
  font-size: 20px;
  position: absolute;
  top: 10px;
  right: 10px;
  border-radius: 100%;
  padding: 10px;
  border: 2px solid white;
}
/* Styl dla przycisku wyciszania */
#mute-btn {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    z-index: 9999 !important; /* Musi być nad canvasem 3D */
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    padding: 8px !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Kontener mobilny musi mieć określoną wysokość, żeby avatar nie był płaski */
#chat-mob-av {
    width: 100%;
    background: #1a1a1a; /* Ciemne tło dla lepszego kontrastu avatara */
    overflow: hidden;
    border-bottom: 1px solid var(--border-light);
}
.button_open_chat_ai::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 100%);
    border-radius: 18px 18px 0 0;
    pointer-events: none;
}

.button_open_chat_ai:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 35px -8px rgba(24, 19, 109, 0.5);
}

.button_open_chat_ai:active {
    transform: translateY(-2px);
}

.message ol {
    padding: 15px;
}
.chat-icon {
    width: 24px;
    height: 24px;
   
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Przy najechaniu tylko ikona delikatnie się obraca - mega detal */
.button_open_chat_ai:hover .chat-icon {
    transform: scale(1.15) rotate(-10deg);
}




.button_open_chat_ai_round {
  position: fixed;
  bottom: 30px;
  right: 30px;
  /* Ustawiamy stałe wymiary, aby uzyskać koło */
  width: 60px;
  height: 60px;
  border-radius: 50%; /* To klucz do okrągłego kształtu */
  
  background: var(--primary-gradient);
  color: var(--white);
  border: none;
  cursor: pointer;
  z-index: 1000;
  
  /* Centrowanie ikony wewnątrz koła */
  display: flex;
  align-items: center;
  justify-content: center;
  
  box-shadow: 0 10px 25px -5px rgba(24, 19, 109, 0.4);
}

.button_open_chat_ai_round:hover {
  transform: scale(1.1); /* Delikatne powiększenie przy najechaniu */
  box-shadow: 0 15px 30px -5px rgba(24, 19, 109, 0.5);
}

.button_open_chat_ai_round>.chat-icon {
    width: 36px;
    height: 36px;
   
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Przy najechaniu tylko ikona delikatnie się obraca - mega detal */
.button_open_chat_ai_round:hover .chat-icon {
    transform: scale(1.15) rotate(-10deg);
}


/* =========================================
   5. OKNO MODALNE
   ========================================= */
#chat-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--overlay-color);
    backdrop-filter: blur(5px);
    z-index: 9999;
}

/* Kontener główny okna - teraz jako Flexbox */
#chat-content {
    display: flex !important;
    flex-direction: row; /* Układ poziomy */
    width: 90vw;       /* Szersze okno, by pomieścić obie kolumny */
    max-width: 1000px;
    height: 90vh;
    background: var(--white);
    border-radius: 20px;
    overflow: hidden;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 20px 40px var(--shadow-modal);
}

/* Lewa kolumna - Miejsce na bota */
.chat-left {
    flex: 0 0 350px; /* Stała szerokość lewej strony */
    background: var(--bg-light); /* Możesz tu dać gradient lub grafikę tła */
    display: flex;
    align-items: center;
    justify-content: center;
   
    position: relative;
}

/* Prawa kolumna - Czat */
.chat-right {
    flex: 1; /* Zajmuje resztę miejsca */
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 50%;
}


/* Kontener awatara - robimy z niego "portal" */
.chat-left {
    background:  var(--primary-gradient);
    background-size: 400% 400%;
    animation: blueWave 15s ease infinite;
   
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5); /* Efekt głębi */
}


/* Animacja płynących kolorów */
@keyframes blueWave {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Animacja obracającej się poświaty */
@keyframes rotateMist {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
/* Responsywność - na komórkach ukrywamy bota po lewej, by czat był czytelny */
@media (max-width: 768px) {
    .chat-left {
        display: none;
    }
    .chat-right {
        width: 100%;
    }
    #chat-content {
        width: 95%;
        flex-direction: column;
    }
}

.modal-animate { animation: slideFromCorner 0.4s ease-out forwards; }
.modal-exit { animation: slideOutToRight 0.3s ease-in forwards; }

.chat-header {
    background: var(--primary-gradient);
    padding: 20px;
    color: var(--white);
    display: flex; justify-content: space-between; align-items: center;
}

.chat-header h3 { margin: 0; font-size: 18px; font-weight: 600; }
.close-btn { cursor: pointer; font-size: 24px; opacity: 0.8; transition: 0.2s; }
.close-btn:hover { opacity: 1; transform: scale(1.1); }

/* Menu Opcji w Headerze */
.header-controls { display: flex; align-items: center; }
.chat-options { position: relative; margin-right: 10px; cursor: pointer; }
.options-dots { font-size: 20px; color: var(--white); padding: 0 5px; }

.options-dropdown { 
    display: none; position: absolute; right: 0; top: 25px; 
    background: var(--white); border-radius: 8px; 
    box-shadow: 0 4px 12px var(--shadow-modal);
    z-index: 1000; min-width: 140px; overflow: hidden;
    border: 1px solid var(--border-light);
}

.options-dropdown div { 
    padding: 10px 15px; color: var(--text-dark); font-size: 13px;
    transition: background 0.2s; border-bottom: 1px solid var(--border-light);
}
.options-dropdown div:hover { background: var(--bg-light); }
.options-dropdown div:last-child { border-bottom: none; }

/* =========================================
   6. OBSZAR WIADOMOŚCI
   ========================================= */
#chat-box {
    flex-grow: 1; padding: 20px; overflow-y: auto;
    background: var(--bg-light);
    display: flex; flex-direction: column; gap: 15px;
}
.message-time {
    font-size: 0.8rem;
  margin-top: 5px;
  opacity: 0.7;
}

.message-row.user .message-time {
    text-align: right;
    margin-right: 5px; /* odrobina oddechu od krawędzi */
}
.message-row { display: flex; align-items: flex-end; gap: 10px; }
.message {  padding: 12px 16px; border-radius: 15px; font-size: 14px; line-height: 1.5; }

.message-row.user { justify-content: flex-end; }
.user-msg {
    background: var(--primary-gradient);
    color: var(--white);
    border-bottom-right-radius: 2px;
}
.message.cons-msg {
    background: #ffffff;
    border: 2px solid #4a52f2; /* Kolor primary */
    color: var(--text-dark);
    border-bottom-left-radius: 2px;
    box-shadow: 0 4px 12px rgba(74, 82, 242, 0.15);
    position: relative;
    font-weight: 500;
    margin-top: 10px;
}

/* Dodatkowy wskaźnik "Konsultant" nad wiadomością */
.message.cons-msg::before {
    content: "Konsultant";
    position: absolute;
    top: -18px;
    left: 0;
    font-size: 10px;
    text-transform: uppercase;
    
    color: #4a52f2;
    font-weight: 700;
    letter-spacing: 0.5px;
}
/* Styl dla kontenera mobilnego awatara */
#chat-mob-av {
    width: 100%;
    height: 100%;
    background: transparent;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Upewnij się, że avatar-box dopasowuje się do rodzica */
#avatar-box canvas {
    width: 100% !important;
    height: 100% !important;
}

.offmod {
    max-width: 500px !important;
}
/* Ukryj lewy panel na bardzo małych ekranach, jeśli awatar jest w trybie mobilnym */
@media (max-width: 768px) {
    
    .chat-left {
        display: none; /* Ukrywa panel boczny na mobile */
    }
    .chat-content.expanded .chat-left {
        display: none; /* Nawet po powiększeniu na mobile nie chcemy dwóch awatarów */
    }
    #chat-content {
        flex-direction: column;
    }
}
/* Wyróżnienie avatara konsultanta (opcjonalnie) */
.message-row.bot img.consultant-avatar {
    border: 2px solid #4a52f2;
    padding: 1px;
    background: white;
}

/* Animacja dla wiadomości konsultanta, żeby "wskoczyła" wyraźniej */
.message.cons-msg {
    animation: bounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.message-row.bot { justify-content: flex-start; }
.bot-msg {
    background: var(--white);
    color: var(--text-dark);
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px var(--shadow-msg);
    border: 1px solid var(--border-light);
}

.bot-avatar { width: 40px; height: 40px; flex-shrink: 0;  }

/* Loader */
.typing-loader { display: flex; gap: 4px; padding: 5px 10px; }
.typing-loader span {
    width: 8px; height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

/* =========================================
   7. QUICK REPLIES & FOOTER
   ========================================= */
.quick-replies {
    padding: 10px 20px; background: var(--bg-light);
    min-height: 50px;
    display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
    border-top: 1px solid var(--border-light);
    overflow-y: hidden;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-btn {
    background: var(--primary-light-bg); /* Lekkie, kolorowe tło zamiast białego */
    border: 1px solid transparent;        /* Brak twardej ramki na starcie */
    color: var(--primary-color);
    padding: 8px 10px;                   /* Nieco więcej "oddechu" */
    border-radius: 12px;                 /* Nowoczesny, mniej "pigułkowaty" kształt */
    font-size: 11px;
    font-weight: 500;                    /* Medium, by tekst był czytelny */
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02); /* Prawie niewidoczny cień */
    font-family: inherit;  
}
.btn-icon {
    opacity: 0.8;
    flex-shrink: 0;
   
}
.user-msg a {
    color: var(--white) !important;
    text-decoration: underline;
}

.quick-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    
    box-shadow: 0 4px 12px var(--primary-shadow); /* Twoja zmienna cienia */
}

.quick-btn:active {
    transform: translateY(0);            /* Efekt kliknięcia */
}

/* Opcjonalnie: Styl dla kontenera, by przyciski nie dotykały krawędzi */
.quick-replies {
    padding: 12px 20px;
    gap: 10px;
    background: var(--bg-light);
    align-items: center;
}
.chat-footer {
    padding: 15px 20px; background: var(--white);
    align-items: center;
    display: flex; gap: 10px; border-top: 1px solid var(--border-light);
}
.chat-disclaimer {
    padding: 8px 20px 12px 20px;
    background: var(--white);
    color: var(--text-gray);
    font-size: 10px;
    text-align: center;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: none; /* Usuwamy zbędne kreski, jeśli footer już ją ma */
}

.chat-disclaimer span {
    opacity: 0.7;
    letter-spacing: 0.2px;
}

.disclaimer-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.disclaimer-link:hover {
    border-bottom: 1px solid var(--primary-color);
    opacity: 1;
}

/* Subtelny odstęp od stopki */
.chat-footer {
    padding-bottom: 4px !important;
}
#user-input {
    flex-grow: 1; padding: 12px 15px;
    border: 1px solid var(--border-input);
    background: var(--white);
    color: var(--text-dark);
    min-width: 100px;
    font-family: inherit;
    border-radius: 25px; outline: none;
}

.send-btn {
    background: var(--primary-gradient);
    color: var(--white);
    min-width: 45px;
    border: none; width: 45px; height: 45px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: 0.3s;
}
.send-btn:hover { transform: scale(1.05); opacity: 0.9; }

/* =========================================
   8. PRODUKTY (KARUZELA)
   ========================================= */
.product-carousel {
    display: flex; gap: 12px; overflow-x: auto;
    background: var(--bg-carousel);
    padding: 15px 10px; margin: 10px 0; border-radius: 10px;
    min-height: 270px;
}

.product-card {
    min-width: 170px; background: var(--white);
    border-radius: 12px; padding: 12px;
    display: flex; flex-direction: column;
    box-shadow: 0 4px 12px var(--shadow-card);
    border: 1px solid var(--border-light);
    transition: all 0.2s; text-decoration: none; color: inherit;
}

.product-card:hover { transform: translateY(-5px); border-color: var(--primary-color); }

.product-img { width: 100%; height: 100px; object-fit: contain; margin-bottom: 10px; }

.product-name {
    font-size: 13px; font-weight: 600; color: var(--text-dark);
    margin-bottom: 8px; line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price { font-size: 15px; font-weight: 700; color: var(--primary-color); }

.view-link {
    text-align: center; background: var(--primary-light-bg);
    color: var(--primary-color); padding: 8px; border-radius: 8px;
    font-size: 11px; font-weight: 700; margin-top: 10px; transition: 0.2s;
}
.view-link:hover { background: var(--primary-color); color: var(--white); }

/* W Twoim pliku style.css */
#chat-box {
    overflow-y: auto;
    overscroll-behavior: contain; /* To magiczna linia, która blokuje propagację scrolla */
}

/* Jeśli masz karuzelę produktów, tam też warto to dodać */
.product-carousel {
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}


/* =========================================
   9. MOBILE OPTIMIZATION & FIXES
   ========================================= */

@media (max-width: 480px) {
    /* Modal na cały ekran */
    #chat-content {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        border-radius: 0 !important;
    }

    /* Fix dla notch i dolnych pasków w nowych telefonach */
    .chat-header {
        padding-top: calc(env(safe-area-inset-top) + 15px) !important;
        border-radius: 0 !important;
    }

    .chat-footer {
        padding-bottom: calc(env(safe-area-inset-bottom) + 10px) !important;
    }

    /* Większe odstępy w wiadomościach na mobile */
    .message {
        font-size: 15px !important;
        max-width: 85% !important;
    }

    #chat-trigger {
        bottom: 20px !important;
        right: 20px !important;
        padding: 12px 20px !important;
    }
}



/* Fix przeciwko AUTO-ZOOM na iOS (musi być min. 16px) */
#user-input {
    -webkit-appearance: none;
}

/* Poprawa przewijania i interakcji dotykowych */
#chat-box {
    -webkit-overflow-scrolling: touch; /* Płynność na iOS */
    scroll-behavior: smooth;
}

/* Usunięcie szarego podświetlenia przy klikaniu na mobile */
#chat-trigger, .quick-btn, .send-btn, .close-btn {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Poprawa czytelności karuzeli na mobile */
.product-carousel {
    padding-bottom: 20px !important;
}