#caa-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
}

/* =========================================================
   GUMB KAD JE CHAT ZATVOREN — PRIKAZUJE KOVERTU
   ========================================================= */
#caa-chat-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--caa-envelope-bg, #0d9488);
    color: var(--caa-envelope-icon, #ffffff);
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    padding: 0;
}
#caa-chat-button:hover {
    transform: scale(1.07);
    box-shadow: 0 14px 32px rgba(0,0,0,0.22);
}
#caa-chat-button:focus-visible {
    outline: 3px solid var(--caa-primary, #0d9488);
    outline-offset: 3px;
}
#caa-envelope-btn {
    width: 28px;
    height: 28px;
    display: block;
    color: var(--caa-envelope-icon, #ffffff);
}

/* =========================================================
   PROZOR CHATA
   ========================================================= */
#caa-chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--caa-chat-bg, #ffffff);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.15);
    border: 1px solid var(--caa-border, #e2e8f0);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: caa-window-in 0.22s ease;
}

@keyframes caa-window-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================================
   HEADER
   ========================================================= */
#caa-chat-header {
    background: linear-gradient(135deg, var(--caa-primary, #0d9488), var(--caa-primary-dark, #0b7a70));
    color: var(--caa-header-text, #ffffff);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#caa-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.75);
    flex-shrink: 0;
}
#caa-header-text {
    min-width: 0;
}
#caa-chat-header strong {
    display: block;
    font-size: 14.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#caa-header-subtitle {
    font-size: 11.5px;
    opacity: 0.9;
}

#caa-close-btn,
#caa-history-btn,
#caa-restart-header-btn {
    background: none;
    border: none;
    color: var(--caa-header-text, #ffffff);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
}
#caa-history-btn {
    margin-left: auto;
}
#caa-close-btn:hover,
#caa-history-btn:hover,
#caa-restart-header-btn:hover {
    background: rgba(255,255,255,0.18);
}
#caa-restart-header-btn:hover {
    transform: rotate(-50deg);
}
#caa-close-btn:focus-visible,
#caa-history-btn:focus-visible,
#caa-restart-header-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* =========================================================
   SELEKTOR JEZIKA
   ========================================================= */
#caa-lang-selector {
    display: flex;
    gap: 4px;
    padding: 8px 14px;
    background: var(--caa-chat-bg, #ffffff);
    border-bottom: 1px solid var(--caa-border, #e2e8f0);
    flex-wrap: wrap;
    flex-shrink: 0;
}
#caa-lang-selector:empty {
    display: none;
}
.caa-lang-btn {
    padding: 4px 11px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.15s ease;
}
.caa-lang-btn:hover {
    background: #f1f5f9;
}
.caa-lang-btn.active {
    background: var(--caa-primary, #0d9488);
    color: var(--caa-header-text, #ffffff);
}
.caa-lang-btn:focus-visible {
    outline: 2px solid var(--caa-primary, #0d9488);
    outline-offset: 1px;
}

/* =========================================================
   PORUKE
   ========================================================= */
#caa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--caa-chat-bg, #ffffff);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.caa-msg {
    max-width: 88%;
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    animation: caa-msg-in 0.18s ease;
}
@keyframes caa-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.caa-bot {
    background: var(--caa-bot-bubble-bg, #f1f5f9);
    color: var(--caa-bot-bubble-text, #1e293b);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.caa-user {
    background: var(--caa-user-bubble-bg, #0d9488);
    color: var(--caa-user-bubble-text, #ffffff);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Feedback thumbs (👍/👎) */
.caa-feedback {
    align-self: flex-start;
    display: flex;
    gap: 6px;
    margin-left: 4px;
    margin-top: -4px;
}
.caa-feedback button {
    background: transparent;
    border: 1px solid var(--caa-border, #e2e8f0);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    padding: 0;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    color: #64748b;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.caa-feedback button:hover {
    background: #f1f5f9;
}
.caa-feedback button.active {
    background: var(--caa-primary, #0d9488);
    color: #ffffff;
    border-color: var(--caa-primary, #0d9488);
}
.caa-feedback button:disabled {
    opacity: 0.6;
    cursor: default;
}
.caa-feedback button:focus-visible {
    outline: 2px solid var(--caa-primary, #0d9488);
    outline-offset: 1px;
}

/* =========================================================
   IZBORNIK (Q&A)
   ========================================================= */
.caa-menu {
    align-self: flex-start;
    max-width: 92%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: caa-msg-in 0.18s ease;
}
.caa-menu button {
    text-align: left;
    background: var(--caa-chat-bg, #ffffff);
    border: 1px solid var(--caa-border, #e2e8f0);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    color: var(--caa-bot-bubble-text, #1e293b);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.caa-menu button:hover {
    border-color: var(--caa-primary, #0d9488);
    background: #f0fdfa;
    transform: translateX(2px);
}
.caa-menu button:focus-visible {
    outline: 2px solid var(--caa-primary, #0d9488);
    outline-offset: 1px;
}
.caa-menu button.caa-menu-back {
    color: var(--caa-primary, #0d9488);
    font-weight: 600;
}

/* =========================================================
   KARTICA LOKACIJE (Google Maps)
   ========================================================= */
.caa-map-card {
    align-self: flex-start;
    max-width: 92%;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--caa-border, #e2e8f0);
    animation: caa-msg-in 0.18s ease;
}
.caa-map-card iframe {
    display: block;
    width: 100%;
    height: 160px;
    border: 0;
}
.caa-map-card .caa-map-info {
    padding: 8px 12px;
    font-size: 12.5px;
    background: #f8fafc;
    border-top: 1px solid var(--caa-border, #e2e8f0);
    color: #475569;
    white-space: pre-line;
    line-height: 1.5;
}
.caa-map-card a {
    display: block;
    padding: 8px 12px;
    font-size: 12.5px;
    color: var(--caa-primary, #0d9488);
    text-decoration: none;
    border-top: 1px solid var(--caa-border, #e2e8f0);
}
.caa-map-card a:hover {
    text-decoration: underline;
}

/* =========================================================
   PANEL ZA KONTAKT / TERMIN
   ========================================================= */
#caa-contact-panel {
    background: #f8fafc;
    border-top: 1px solid var(--caa-border, #e2e8f0);
    padding: 14px;
    max-height: 70%;
    overflow-y: auto;
    flex-shrink: 0;
    animation: caa-msg-in 0.18s ease;
}
.caa-contact-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 10px;
}
.caa-field {
    margin-bottom: 9px;
}
.caa-field label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 3px;
}
.caa-field input[type="text"],
.caa-field input[type="email"],
.caa-field input[type="tel"],
.caa-field select,
.caa-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--caa-border, #e2e8f0);
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 13.5px;
    background: #ffffff;
    outline: none;
    transition: border-color 0.15s ease;
    font-family: inherit;
    color: #1e293b;
}
.caa-field input:focus,
.caa-field select:focus,
.caa-field textarea:focus {
    border-color: var(--caa-primary, #0d9488);
}
.caa-field textarea {
    resize: vertical;
    min-height: 48px;
}
.caa-field-row {
    display: flex;
    gap: 8px;
}
.caa-field-row .caa-field {
    flex: 1;
    min-width: 0;
}

/* Honeypot — vizualno i za pomoćne tehnologije skriveno */
.caa-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.caa-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 11.5px;
    color: #475569;
    line-height: 1.4;
    margin: 10px 0;
}
.caa-consent input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}
.caa-consent a {
    color: var(--caa-primary, #0d9488);
    text-decoration: underline;
}

.caa-contact-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.caa-contact-actions button {
    flex: 1;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--caa-border, #e2e8f0);
    transition: opacity 0.15s ease;
    font-family: inherit;
}
.caa-btn-primary {
    background: var(--caa-primary, #0d9488);
    color: #ffffff;
    border-color: var(--caa-primary, #0d9488);
}
.caa-btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}
.caa-btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}
.caa-btn-secondary {
    background: #ffffff;
    color: #334155;
}
.caa-btn-secondary:hover {
    background: #f1f5f9;
}
.caa-contact-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 6px;
}

/* =========================================================
   INPUT POLJE
   ========================================================= */
#caa-input-area {
    padding: 12px;
    display: flex;
    gap: 8px;
    background: var(--caa-chat-bg, #ffffff);
    border-top: 1px solid var(--caa-border, #e2e8f0);
    flex-shrink: 0;
}
#caa-user-input {
    flex: 1;
    border: 1px solid var(--caa-border, #e2e8f0);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    background: var(--caa-input-bg, #ffffff);
    color: var(--caa-input-text, #1e293b);
    min-width: 0;
    transition: border-color 0.15s ease;
    font-family: inherit;
}
#caa-user-input:focus {
    border-color: var(--caa-primary, #0d9488);
}
#caa-user-input:disabled {
    opacity: 0.6;
}
#caa-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--caa-primary, #0d9488);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.12s ease, opacity 0.15s ease;
}
#caa-send-btn:hover:not(:disabled) {
    transform: scale(1.06);
}
#caa-send-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
#caa-send-btn:focus-visible {
    outline: 2px solid var(--caa-primary, #0d9488);
    outline-offset: 2px;
}

/* =========================================================
   RESTART BAR
   ========================================================= */
#caa-restart-bar {
    padding: 12px;
    background: var(--caa-chat-bg, #ffffff);
    border-top: 1px solid var(--caa-border, #e2e8f0);
    flex-shrink: 0;
}
#caa-restart-btn {
    width: 100%;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--caa-border, #e2e8f0);
    background: #f8fafc;
    color: #1e293b;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
}
#caa-restart-btn:hover {
    background: #f1f5f9;
}
#caa-restart-btn:focus-visible {
    outline: 2px solid var(--caa-primary, #0d9488);
    outline-offset: 2px;
}

/* =========================================================
   HISTORY PANEL ("Vaši razgovori")
   ========================================================= */
#caa-history-panel {
    position: absolute;
    inset: 0;
    top: 0;
    background: var(--caa-chat-bg, #ffffff);
    z-index: 5;
    display: flex;
    flex-direction: column;
}
#caa-history-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--caa-border, #e2e8f0);
    flex-shrink: 0;
}
#caa-history-back-btn {
    background: none;
    border: none;
    color: var(--caa-primary, #0d9488);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-family: inherit;
}
#caa-history-back-btn:hover {
    background: #f0fdfa;
}
#caa-history-title {
    font-size: 14px;
    color: #1e293b;
}
#caa-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.caa-history-item {
    display: block;
    width: 100%;
    text-align: left;
    background: #f8fafc;
    border: 1px solid var(--caa-border, #e2e8f0);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    font-family: inherit;
}
.caa-history-item:hover {
    border-color: var(--caa-primary, #0d9488);
    background: #f0fdfa;
}
.caa-history-item.caa-history-active {
    border-color: var(--caa-primary, #0d9488);
    background: #f0fdfa;
}
.caa-history-item-date {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 3px;
}
.caa-history-item-preview {
    font-size: 13px;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#caa-history-empty {
    padding: 24px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

/* =========================================================
   PRIVACY FOOTER
   ========================================================= */
#caa-privacy-footer {
    padding: 6px 14px 8px;
    background: var(--caa-chat-bg, #ffffff);
    flex-shrink: 0;
    text-align: center;
}
#caa-privacy-text {
    font-size: 10.5px;
    line-height: 1.4;
    color: #94a3b8;
}
#caa-privacy-text a {
    color: #94a3b8;
    text-decoration: underline;
}
#caa-privacy-text a:hover {
    color: var(--caa-primary, #0d9488);
}

/* =========================================================
   INDIKATOR TIPKANJA
   ========================================================= */
.caa-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    align-self: flex-start;
}
.caa-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: caa-typing-bounce 1.1s infinite ease-in-out;
}
.caa-typing span:nth-child(2) { animation-delay: 0.15s; }
.caa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes caa-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* =========================================================
   MOBITEL — CHAT PREKO CIJELOG EKRANA
   ========================================================= */
@media (max-width: 480px) {
    #caa-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    #caa-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        animation: caa-window-in-mobile 0.2s ease;
    }
    @keyframes caa-window-in-mobile {
        from { opacity: 0; transform: translateY(16px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .caa-field-row {
        flex-direction: column;
    }
}

/* =========================================================
   PRISTUPAČNOST — SMANJENA ANIMACIJA
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    #caa-chat-window,
    .caa-msg,
    .caa-typing span,
    #caa-contact-panel,
    .caa-menu,
    #caa-chat-button {
        animation: none !important;
        transition: none !important;
    }
}