/**
 * Stilovi za AI chat bot widget.
 * Widget je fiksiran u donjem desnom uglu ekrana.
 * Premium tamna tema sa glassmorphism efektima i brend bojama.
 */

/* Glavni kontejner widgeta */
.chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', 'Poppins', sans-serif;
}

/* Dugme za otvaranje */
.chatbot-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c6168d 0%, #7d03ef 100%);
    color: #fff;
    border: none;
    box-shadow: 0 6px 24px rgba(198, 22, 141, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.chatbot-toggle:hover,
.chatbot-toggle:focus-visible {
    transform: scale(1.08) rotate(-3deg);
    box-shadow: 0 10px 32px rgba(198, 22, 141, 0.55);
}

.chatbot-toggle:focus-visible {
    outline: 3px solid #f0c;
    outline-offset: 3px;
}

.chatbot-toggle svg {
    width: 30px;
    height: 30px;
}

/* Prozor za chat */
.chatbot-window {
    position: absolute;
    bottom: 82px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: rgba(17, 17, 17, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transform: translateY(15px) scale(0.98);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.chatbot-window.is-open {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Zaglavlje */
.chatbot-header {
    background: linear-gradient(135deg, rgba(198, 22, 141, 0.95) 0%, rgba(125, 3, 239, 0.95) 100%);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 16px;
}

.chatbot-header-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-header-icon svg {
    width: 18px;
    height: 18px;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chatbot-close:hover,
.chatbot-close:focus-visible {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-close:focus-visible {
    outline: 3px solid #f0c;
    outline-offset: 3px;
}

.chatbot-close svg {
    width: 20px;
    height: 20px;
}

/* Tijelo poruka */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

/* Wrapper oko jedne bota poruke sa izvorima/feedback-om */
.chatbot-message-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Pojedinačna poruka */
.chatbot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}

.chatbot-message--bot {
    align-self: flex-start;
    background: rgba(26, 26, 26, 0.85);
    color: #f0f0f0;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.chatbot-message--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #c6168d 0%, #7d03ef 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.chatbot-message p {
    margin: 0 0 8px 0;
}

.chatbot-message p:last-child {
    margin-bottom: 0;
}

.chatbot-message ul,
.chatbot-message ol {
    margin: 0 0 8px 0;
    padding-left: 20px;
}

.chatbot-message li {
    margin-bottom: 4px;
}

.chatbot-message strong {
    color: #fff;
}

/* Greška */
.chatbot-message--error {
    background: rgba(42, 10, 10, 0.9);
    color: #ff8a8a;
    border: 1px solid rgba(255, 100, 100, 0.25);
}

/* Indikator kucanja */
.chatbot-typing {
    display: none;
    align-self: flex-start;
    background: rgba(26, 26, 26, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 16px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    margin-left: 18px;
    margin-bottom: 8px;
}

.chatbot-typing.is-visible {
    display: flex;
}

.chatbot-typing-dots {
    display: flex;
    gap: 6px;
}

.chatbot-typing-dots span {
    width: 8px;
    height: 8px;
    background: #c6168d;
    border-radius: 50%;
    animation: chatbotTyping 1.4s infinite ease-in-out both;
}

.chatbot-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes chatbotTyping {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Izvori — sakriveni u sklopivom <details> elementu (2026-09-11):
   lista izvora za svaki odgovor zauzimala je dobar deo ekrana, a
   krajnjem korisniku je retko potrebna; klik na "Izvor (n)" ih otvara.
   Održani su zbog poverenja i forenzike (koji izvor stoji iza odgovora). */
.chatbot-sources {
    margin: 6px 18px 0 18px;
    font-size: 12px;
    color: #aaa;
}

.chatbot-sources summary {
    cursor: pointer;
    list-style-position: inside;
    padding: 2px 0;
    font-weight: 600;
    color: #999;
    user-select: none;
}

.chatbot-sources summary:hover {
    color: #e728ba;
}

.chatbot-sources ul {
    margin: 8px 0 0 0;
    padding: 10px 14px 10px 28px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    list-style-type: disc;
}

.chatbot-sources li {
    margin-bottom: 3px;
}

.chatbot-sources a {
    color: #e728ba;
    text-decoration: none;
    transition: color 0.2s ease;
}

.chatbot-sources a:hover {
    color: #f560d5;
    text-decoration: underline;
}

/* Feedback */
.chatbot-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 18px 0 18px;
    font-size: 12px;
    color: #888;
}

.chatbot-feedback-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: background 0.2s ease, transform 0.15s ease;
}

.chatbot-feedback-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.chatbot-feedback-thanks {
    color: #aaa;
    font-style: italic;
}

/* Brza pitanja */
.chatbot-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 18px 0 18px;
    background: transparent;
}

.chatbot-quick-questions.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.chatbot-quick-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ddd;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.chatbot-quick-btn:hover {
    background: rgba(198, 22, 141, 0.2);
    border-color: rgba(198, 22, 141, 0.5);
    color: #fff;
}

/* Disclaimer */
.chatbot-disclaimer {
    padding: 8px 18px;
    font-size: 11px;
    color: #777;
    text-align: center;
    background: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Dno i unos */
.chatbot-footer {
    padding: 14px 18px;
    background: rgba(26, 26, 26, 0.7);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    box-sizing: border-box;
}

.chatbot-input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 26px;
    padding: 12px 18px;
    font-size: 14px;
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: none;
    max-height: 90px;
    font-family: inherit;
    background: rgba(17, 17, 17, 0.7);
    color: #fff;
    box-sizing: border-box;
}

.chatbot-input::placeholder {
    color: #888;
}

.chatbot-input:focus-visible {
    border-color: #c6168d;
    box-shadow: 0 0 0 3px rgba(198, 22, 141, 0.15);
    outline-color: #c6168d;
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c6168d 0%, #7d03ef 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
    flex-grow: 0;
    box-sizing: border-box;
}

.chatbot-send:hover,
.chatbot-send:focus-visible {
    opacity: 0.92;
    transform: scale(1.05);
}

.chatbot-send:focus-visible {
    outline: 3px solid #f0c;
    outline-offset: 3px;
}

.chatbot-send:disabled {
    background: #444;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
}

/* Responsivnost */
@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 16px;
        right: 16px;
    }

    .chatbot-window {
        width: calc(100vw - 32px);
        right: -4px;
        height: 72vh;
        max-height: 540px;
        bottom: 76px;
    }

    .chatbot-message {
        max-width: 90%;
    }
}
/* Reduced motion — accessibility */
@media (prefers-reduced-motion: reduce) {
    .chatbot-toggle,
    .chatbot-window,
    .chatbot-close,
    .chatbot-send,
    .chatbot-feedback-btn,
    .chatbot-quick-btn,
    .chatbot-sources a,
    .chatbot-input {
        transition: none !important;
        animation: none !important;
    }

    .chatbot-typing-dots span {
        animation: none !important;
    }
}
