/* ===========================
   CHATBOT CONTAINER - PO PRAWEJ STRONIE
   =========================== */

#chatbot-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', Arial, sans-serif;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

#chatbot-container.active {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Speech bubble tail - Ogon chmurki wskazujący przycisk */
#chatbot-container::after {
    content: '';
    position: absolute;
    bottom: -12px;
    right: 30px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid #ffffff;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.1));
}

/* ===========================
   CHATBOT HEADER
   =========================== */

#chatbot-header {
    background: linear-gradient(135deg, #ff6600 0%, #ff8c00 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 2px 10px rgba(255, 102, 0, 0.2);
}

#chatbot-header span {
    font-weight: 600;
    font-size: 17px;
    letter-spacing: 0.3px;
}

#chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-weight: 300;
    line-height: 1;
}

#chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

#chatbot-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* ===========================
   MESSAGES CONTAINER
   =========================== */

#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Pojedyncza wiadomość */
#chatbot-messages > div {
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    max-width: 85%;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Wiadomość użytkownika - po prawej */
#chatbot-messages > div:has(strong:contains("Ty")) {
    background: linear-gradient(135deg, #ff6600 0%, #ff8c00 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(255, 102, 0, 0.2);
}

/* Wiadomość bota - po lewej */
#chatbot-messages > div:has(strong:contains("Bot")) {
    background: #ffffff;
    color: #333;
    align-self: flex-start;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Stylizacja nagłówków wiadomości */
#chatbot-messages strong {
    font-weight: 700;
    font-size: 12px;
    display: block;
    margin-bottom: 4px;
    opacity: 0.7;
}

/* ===========================
   INPUT CONTAINER
   =========================== */

#chatbot-input-container {
    display: flex;
    gap: 10px;
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #e8e8e8;
    border-radius: 0 0 16px 16px;
}

#chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    background: #fafafa;
}

#chatbot-input:focus {
    border-color: #ff6600;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 102, 0, 0.1);
}

#chatbot-input::placeholder {
    color: #aaa;
}

#chatbot-send {
    padding: 12px 24px;
    background: linear-gradient(135deg, #ff6600 0%, #ff8c00 100%);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(255, 102, 0, 0.25);
}

#chatbot-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 102, 0, 0.35);
}

#chatbot-send:active:not(:disabled) {
    transform: translateY(0);
}

#chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===========================
   TOGGLE BUTTON - PO PRAWEJ
   =========================== */

#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #ff6600 0%, #ff8c00 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 102, 0, 0.35);
    z-index: 999998;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

#chatbot-toggle::before {
    content: '💬';
    font-size: 20px;
}

#chatbot-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 102, 0, 0.45);
}

#chatbot-toggle:active {
    transform: translateY(-1px);
}

/* Ukrycie przycisku gdy chat jest otwarty */
#chatbot-toggle.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* ===========================
   SCROLLBAR STYLING
   =========================== */

#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #ff6600;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #ff8c00;
}

/* ===========================
   ANIMACJA PULSOWANIA
   =========================== */

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 6px 20px rgba(255, 102, 0, 0.35);
    }
    50% {
        box-shadow: 0 6px 30px rgba(255, 102, 0, 0.55);
    }
}

#chatbot-toggle {
    animation: pulse 2s infinite;
}

#chatbot-toggle:hover {
    animation: none;
}

/* ===========================
   MOBILE RESPONSIVENESS
   =========================== */

@media (max-width: 480px) {
    #chatbot-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 140px);
        bottom: 80px;
        right: 10px;
    }

    #chatbot-container::after {
        right: 20px;
    }

    #chatbot-toggle {
        padding: 14px 20px;
        font-size: 14px;
        bottom: 15px;
        right: 15px;
    }

    #chatbot-messages > div {
        max-width: 90%;
    }

    #chatbot-input-container {
        padding: 12px;
    }

    #chatbot-send {
        padding: 10px 18px;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    #chatbot-container {
        width: calc(100vw - 10px);
        right: 5px;
    }

    #chatbot-toggle {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* ===========================
   LOADING STATE (opcjonalne)
   =========================== */

.chatbot-loading {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff6600;
    animation: chatbotLoading 1.4s infinite ease-in-out both;
}

.chatbot-loading:nth-child(1) {
    animation-delay: -0.32s;
}

.chatbot-loading:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes chatbotLoading {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* ===========================
   ACCESSIBILITY
   =========================== */

#chatbot-toggle:focus,
#chatbot-send:focus,
#chatbot-input:focus,
#chatbot-close:focus {
    outline: 3px solid rgba(255, 102, 0, 0.4);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #chatbot-container {
        border: 2px solid #000;
    }

    #chatbot-input {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #chatbot-container,
    #chatbot-toggle,
    #chatbot-messages > div,
    #chatbot-close {
        animation: none;
        transition: none;
    }
}