/**
 * FITWOR Community Chat - Stilovi
 * 
 * @since 1.0.0
 */

/* ============================================
   SAKRIJ CHAT NA LOGIN/LOGOUT STRANICAMA
   ============================================ */

/* WordPress login page */
body.login .fitwor-chat-fab,
body.login .fitwor-chat-container,
body.login .fitwor-chat-overlay,
/* Logged out state */
body:not(.logged-in) .fitwor-chat-fab,
body:not(.logged-in) .fitwor-chat-container,
body:not(.logged-in) .fitwor-chat-overlay,
/* Theme My Login pages */
body.page-template-login .fitwor-chat-fab,
body.page-template-login .fitwor-chat-container,
body.page-template-login .fitwor-chat-overlay,
/* Common login page slugs */
body.page-prijava .fitwor-chat-fab,
body.page-prijava .fitwor-chat-container,
body.page-prijava .fitwor-chat-overlay,
body.page-login .fitwor-chat-fab,
body.page-login .fitwor-chat-container,
body.page-login .fitwor-chat-overlay,
body.page-registracija .fitwor-chat-fab,
body.page-registracija .fitwor-chat-container,
body.page-registracija .fitwor-chat-overlay {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ============================================
   FLOATING BUTTON (Mobile & Desktop)
   ============================================ */

.fitwor-chat-fab {
    position: fixed;
    bottom: 80px; /* Iznad mobile navigation */
    right: 20px;
    width: 56px;
    height: 56px;
    background: #3e8f04;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(62, 143, 4, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9998;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fitwor-chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(62, 143, 4, 0.5);
}

.fitwor-chat-fab svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.fitwor-chat-fab-badge,
.fitwor-chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Desktop - viši položaj */
@media (min-width: 769px) {
    .fitwor-chat-fab {
        bottom: 30px;
        right: 30px;
        width: 60px;
        height: 60px;
    }
    
    .fitwor-chat-fab svg {
        width: 30px;
        height: 30px;
    }
}


/* ============================================
   CHAT CONTAINER (Fullscreen Modal)
   ============================================ */

.fitwor-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.fitwor-chat-overlay.active {
    opacity: 1;
    visibility: visible;
}

.fitwor-chat-container {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 450px;
    height: 100%;
    background: #fff;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    overscroll-behavior: contain;
}

.fitwor-chat-container.active {
    right: 0;
}

/* Mobile - full width */
@media (max-width: 768px) {
    .fitwor-chat-container {
        max-width: 100%;
    }
    
    /* Mobile input area fix */
    .fitwor-chat-input-row {
        display: flex !important;
        align-items: flex-end !important; /* Dugmad ostaju na dnu */
        flex-wrap: nowrap !important;
        gap: 8px !important;
    }
    
    .fitwor-chat-input-area {
        padding: 12px 16px !important;
    }
    
    .fitwor-chat-image-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        max-width: 44px !important;
        max-height: 44px !important;
        flex: 0 0 44px !important;
        margin: 0 !important;
    }
    
    .fitwor-chat-image-btn svg {
        width: 22px !important;
        height: 22px !important;
    }
    
    .fitwor-chat-input-wrapper {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
    
    .fitwor-chat-input {
        min-height: 44px !important;
        max-height: 150px !important; /* ~6 redova na mobilnom */
        padding: 10px 14px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        line-height: 22px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow-y: hidden !important;
        scrollbar-width: none !important; /* Firefox */
        -ms-overflow-style: none !important; /* IE/Edge */
    }
    
    .fitwor-chat-input::-webkit-scrollbar {
        display: none !important; /* Chrome, Safari */
    }
    
    .fitwor-chat-input.has-scroll {
        overflow-y: auto !important;
    }
    
    .fitwor-chat-send-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        max-width: 44px !important;
        max-height: 44px !important;
        flex: 0 0 44px !important;
        margin: 0 !important;
    }
    
    .fitwor-chat-send-btn svg {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* Mobile: Add reaction dugme veće */
    .fitwor-chat-add-reaction {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }
    
    .fitwor-chat-add-reaction svg {
        width: 18px !important;
        height: 18px !important;
        pointer-events: none !important;
    }
    
    /* Mobile: Menu uvek vidljiv */
    .fitwor-chat-message-menu {
        opacity: 1 !important;
    }
    
    .fitwor-chat-menu-dropdown {
        min-width: 140px;
    }
    
    .fitwor-chat-menu-item {
        padding: 10px 16px !important;
        font-size: 14px !important;
    }
}


/* ============================================
   CHAT HEADER
   ============================================ */

.fitwor-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #3e8f04, #2c6c02);
    color: #fff;
}

.fitwor-chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fitwor-chat-header-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.fitwor-chat-header-title svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.fitwor-chat-close {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    flex: 0 0 36px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    padding: 0 !important;
    box-sizing: border-box;
    aspect-ratio: 1 / 1;
}

.fitwor-chat-close:hover {
    background: rgba(255, 255, 255, 0.5);
}

.fitwor-chat-close svg {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    flex-shrink: 0;
    fill: #fff;
}


/* ============================================
   PINNED MESSAGE
   ============================================ */

.fitwor-chat-pinned-container {
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
    border-bottom: 1px solid #f0e6cc;
}

.fitwor-chat-pinned {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.fitwor-chat-pinned:hover {
    background: rgba(255, 255, 255, 0.5);
}

.fitwor-chat-pinned-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.fitwor-chat-pinned-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.fitwor-chat-pinned-author {
    font-size: 12px;
    font-weight: 600;
    color: #5cb85c;
    margin-bottom: 2px;
}

.fitwor-chat-pinned-text {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fitwor-chat-pinned-close {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    max-width: 28px;
    max-height: 28px;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
}

.fitwor-chat-pinned-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #e74c3c;
}

.fitwor-chat-pinned-close:active {
    background: rgba(0, 0, 0, 0.15);
}

/* Message highlight kada se skroluje do nje */
.fitwor-chat-message.highlight {
    animation: messageHighlight 2s ease;
}

@keyframes messageHighlight {
    0%, 100% {
        background: transparent;
    }
    20%, 80% {
        background: rgba(92, 184, 92, 0.15);
        border-radius: 12px;
    }
}


/* ============================================
   MESSAGES AREA
   ============================================ */

.fitwor-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.fitwor-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.fitwor-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.fitwor-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* Mobile - manje margine levo/desno */
@media (max-width: 768px) {
    .fitwor-chat-messages {
        padding: 20px 12px;
    }
}

.fitwor-chat-loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

.fitwor-chat-empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.fitwor-chat-empty svg {
    width: 60px;
    height: 60px;
    fill: #ddd;
    margin-bottom: 15px;
}


/* ============================================
   MESSAGE BUBBLE
   ============================================ */

.fitwor-chat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Highlight efekat za poruku kada se skroluje do nje (push notifikacija) */
.fitwor-chat-message-highlight {
    animation: messageHighlight 3s ease;
}

@keyframes messageHighlight {
    0% {
        background-color: rgba(255, 236, 179, 0.6);
        box-shadow: 0 0 8px rgba(255, 223, 128, 0.4);
    }
    70% {
        background-color: rgba(255, 243, 204, 0.4);
        box-shadow: 0 0 4px rgba(255, 223, 128, 0.2);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.fitwor-chat-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.fitwor-chat-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Avatar klikabilan samo za admine */
.fitwor-chat-container.admin-view .fitwor-chat-message-avatar {
    cursor: pointer;
}

.fitwor-chat-container.admin-view .fitwor-chat-message-avatar:hover {
    opacity: 0.8;
}

/* Avatar placeholder za korisnike bez slike */
.fitwor-chat-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fitwor-chat-avatar-placeholder span {
    font-size: 16px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
}

.fitwor-chat-avatar-placeholder.small {
    width: 32px;
    height: 32px;
}

.fitwor-chat-avatar-placeholder.small span {
    font-size: 14px;
}

/* Date separator */
.fitwor-chat-date-separator {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px 20px !important;
    position: relative !important;
}

.fitwor-chat-date-separator span {
    background: #e8e8e8 !important;
    color: #666 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 6px 14px !important;
    border-radius: 16px !important;
    text-transform: none !important;
    letter-spacing: 0.3px !important;
    display: inline-block !important;
}

.fitwor-chat-message-content {
    flex: 1;
    min-width: 0;
}

.fitwor-chat-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.fitwor-chat-message-author {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

/* Special users */
.fitwor-chat-message-author.special-green {
    color: #5cb85c;
}

.fitwor-chat-message-author.special-purple {
    color: #9b59b6;
}

.fitwor-chat-message-time {
    font-size: 12px;
    color: #999;
}

.fitwor-chat-message-bubble {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    padding: 12px 16px;
    border-radius: 12px;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    word-wrap: break-word;
}

/* Own message */
.fitwor-chat-message.own {
    flex-direction: row-reverse;
}

.fitwor-chat-message.own .fitwor-chat-message-bubble {
    background: #fff;
    color: #333;
    border-radius: 12px;
    border-top-right-radius: 4px;
}

.fitwor-chat-message.own .fitwor-chat-message-header {
    justify-content: flex-end;
}

/* Reply indicator */
.fitwor-chat-message-reply {
    background: rgba(0, 0, 0, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #666;
    border-left: 3px solid #5cb85c;
}

.fitwor-chat-message-reply-author {
    font-weight: 600;
    color: #333;
}

/* Image in message */
.fitwor-chat-message-image {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 280px;
}

.fitwor-chat-message-image img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}

/* Mention highlight */
.fitwor-chat-mention {
    background: rgba(92, 184, 92, 0.2);
    color: #5cb85c;
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 500;
}

/* Mention u sopstvenoj poruci (pastelna pozadina) */
.fitwor-chat-message.own .fitwor-chat-mention {
    background: rgba(124, 58, 237, 0.15);
    color: #7c3aed;
    font-weight: 600;
}

/* Bold text formatting */
.fitwor-chat-bold {
    font-weight: 700; /* 400=normal, 500=medium, 600=semi-bold, 700=bold, 800=extra-bold */
}

/* Italic text formatting */
.fitwor-chat-italic,
.fitwor-chat-message-content em {
    font-style: italic !important;
    /* Fallback ako font nema italic varijantu */
    font-synthesis: style;
}

/* Edit message styles */
.fitwor-chat-edit-container {
    width: 100%;
}

.fitwor-chat-edit-input {
    width: 100%;
    min-height: 60px;
    max-height: 150px;
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.fitwor-chat-edit-input:focus {
    border-color: #7c3aed;
    background: #fff;
}

.fitwor-chat-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.fitwor-chat-edit-cancel,
.fitwor-chat-edit-save {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fitwor-chat-edit-cancel {
    background: #f0f0f0;
    color: #666;
    border: 1px solid #ddd;
}

.fitwor-chat-edit-cancel:hover {
    background: #e5e5e5;
}

.fitwor-chat-edit-save {
    background: #7c3aed;
    color: #fff;
    font-weight: 600;
}

.fitwor-chat-edit-save:hover {
    background: #6d28d9;
}

/* Edited label */
.fitwor-chat-edited-label {
    font-size: 11px;
    color: #999;
    margin-left: 6px;
    font-style: italic;
}

.fitwor-chat-message.own .fitwor-chat-edited-label {
    color: #888;
}

/* Mobile edit buttons */
@media (max-width: 768px) {
    .fitwor-chat-edit-container {
        max-width: 100% !important;
    }
    
    .fitwor-chat-edit-actions {
        gap: 4px !important;
        justify-content: flex-end !important;
    }
    
    .fitwor-chat-edit-cancel,
    .fitwor-chat-edit-save {
        padding: 5px 10px !important;
        font-size: 12px !important;
        flex-shrink: 0 !important;
        min-width: auto !important;
    }
    
    .fitwor-chat-edit-input {
        min-height: 40px !important;
        padding: 5px 6px !important;
        font-size: 13px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
}


/* ============================================
   REACTIONS
   ============================================ */

.fitwor-chat-message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.fitwor-chat-reaction {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fitwor-chat-reaction:hover {
    border-color: #5cb85c;
    background: #f0fff0;
}

.fitwor-chat-reaction.active {
    border-color: #5cb85c;
    background: #e8f5e9;
}

.fitwor-chat-reaction-count {
    font-size: 12px;
    color: #666;
}

/* Add reaction button */
.fitwor-chat-add-reaction {
    width: 28px;
    height: 28px;
    background: #fff;
    border: 1px dashed #ccc;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fitwor-chat-add-reaction:hover {
    border-color: #5cb85c;
    background: #f0fff0;
}

.fitwor-chat-add-reaction svg {
    width: 14px;
    height: 14px;
    fill: #999;
    pointer-events: none;
}


/* ============================================
   MESSAGE MENU (Three-dot dropdown)
   ============================================ */

.fitwor-chat-message-menu {
    position: relative;
    display: flex;
    align-items: center;
    align-self: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fitwor-chat-message:hover .fitwor-chat-message-menu,
.fitwor-chat-message.show-menu .fitwor-chat-message-menu {
    opacity: 1;
}

.fitwor-chat-menu-btn {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.fitwor-chat-menu-btn:hover {
    background: #e8e8e8;
    color: #666;
}

.fitwor-chat-menu-dropdown {
    position: absolute;
    top: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    min-width: 130px;
    z-index: 100;
    display: none;
}

/* Dropdown pozicija - za tuđe poruke (desno od dugmeta) */
.fitwor-chat-message .fitwor-chat-menu-dropdown {
    left: auto;
    right: 0;
}

/* Dropdown pozicija - za moje poruke (levo od dugmeta) */
.fitwor-chat-message.own .fitwor-chat-menu-dropdown {
    left: 0;
    right: auto;
}

.fitwor-chat-message-menu.active .fitwor-chat-menu-dropdown {
    display: block;
}

.fitwor-chat-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.fitwor-chat-menu-item:hover {
    background: #f5f5f5;
}

.fitwor-chat-menu-item.fitwor-chat-action-delete:hover {
    background: #fff0f0;
    color: #e74c3c;
}

/* Stari actions - sakrij (za kompatibilnost ako postoji) */
.fitwor-chat-message-actions {
    display: none !important;
}


/* ============================================
   INPUT AREA
   ============================================ */

.fitwor-chat-input-area {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #e8e8e8;
}

/* Reply preview */
.fitwor-chat-reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f0f0f0;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
}

.fitwor-chat-reply-preview-text {
    color: #666;
}

.fitwor-chat-reply-preview-text strong {
    color: #333;
}

.fitwor-chat-reply-cancel {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #999;
}

.fitwor-chat-reply-cancel:hover {
    color: #e74c3c;
}

/* Image preview */
.fitwor-chat-image-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 10px;
}

.fitwor-chat-image-preview img {
    max-width: 120px;
    max-height: 80px;
    border-radius: 8px;
}

.fitwor-chat-image-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px !important;
    height: 24px !important;
    aspect-ratio: 1 / 1;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 50% !important;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

/* Mobile - manji krug za uklanjanje slike */
@media (max-width: 768px) {
    .fitwor-chat-image-preview-remove {
        width: 18px !important;
        height: 18px !important;
        font-size: 11px;
        top: -6px;
        right: -6px;
    }
}

/* Input row */
.fitwor-chat-input-row {
    display: flex !important;
    align-items: flex-end !important; /* Dugmad ostaju na dnu kada se textarea širi */
    gap: 10px !important;
    flex-wrap: nowrap !important;
}

.fitwor-chat-image-btn {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    background: #f0f0f0 !important;
    border: none !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    transition: background 0.2s ease;
    flex: 0 0 48px !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    align-self: flex-end !important;
    margin-bottom: 0 !important;
}

.fitwor-chat-image-btn:hover {
    background: #e0e0e0 !important;
}

.fitwor-chat-image-btn svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    fill: #666 !important;
    flex-shrink: 0 !important;
}

.fitwor-chat-input-wrapper {
    flex: 1 !important;
    position: relative;
    align-self: flex-end !important;
}

.fitwor-chat-input {
    width: 100%;
    min-height: 48px;
    height: 48px;
    max-height: 156px; /* ~6 redova (6 * 21px line-height + 24px padding) */
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    line-height: 21px;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease, height 0.1s ease;
    font-family: inherit;
    box-sizing: border-box !important;
    margin: 0 !important;
    vertical-align: middle !important;
    overflow-y: hidden; /* Sakrij scrollbar dok nije max */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.fitwor-chat-input::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.fitwor-chat-input.has-scroll {
    overflow-y: auto; /* Prikaži scroll kada dostigne max */
}

.fitwor-chat-input:focus {
    border-color: #5cb85c;
}

.fitwor-chat-input::placeholder {
    color: #999;
}

.fitwor-chat-send-btn {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    background: linear-gradient(135deg, #5cb85c 0%, #4a9f4a 100%) !important;
    border: none !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex: 0 0 48px !important;
    box-shadow: 0 2px 6px rgba(92, 184, 92, 0.3);
    box-sizing: border-box !important;
    padding: 0 !important;
    align-self: flex-end !important;
    margin-bottom: 0 !important;
}

.fitwor-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(92, 184, 92, 0.5);
}

.fitwor-chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.fitwor-chat-send-btn svg {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    fill: #fff;
    margin-left: 2px;
}


/* ============================================
   EMOJI PICKER
   ============================================ */

.fitwor-chat-emoji-picker {
    position: fixed;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 12px;
    display: none;
    z-index: 99999;
    min-width: 240px;
    pointer-events: auto;
}

.fitwor-chat-emoji-picker.active {
    display: block !important;
}

.fitwor-chat-emoji-picker * {
    pointer-events: auto;
}

.fitwor-chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.fitwor-chat-emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(92, 184, 92, 0.3);
    touch-action: manipulation;
    position: relative;
    z-index: 1;
}

.fitwor-chat-emoji-item:hover,
.fitwor-chat-emoji-item:active {
    background: #e8f5e9;
}

/* Mobile: ista veličina kao desktop */
@media (max-width: 768px) {
    .fitwor-chat-emoji-grid {
        gap: 4px;
    }
}


/* ============================================
   MENTIONS AUTOCOMPLETE
   ============================================ */

.fitwor-chat-input-wrapper {
    position: relative;
}

.fitwor-chat-mentions-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 9999;
}

.fitwor-chat-mentions-dropdown.active {
    display: block !important;
}

.fitwor-chat-mention-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.fitwor-chat-mention-item:hover,
.fitwor-chat-mention-item.selected {
    background: #f0fff0;
}

.fitwor-chat-mention-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.fitwor-chat-mention-item-name {
    font-weight: 500;
    color: #333;
}

.fitwor-chat-mention-item-name.special {
    color: #5cb85c;
}

/* @FITWOR tag styling u dropdown-u */
.fitwor-chat-mention-item.fitwor-tag {
    background: linear-gradient(135deg, #f0fff0 0%, #e8f5e9 100%);
    border-bottom: 1px solid #c8e6c9;
}

.fitwor-chat-mention-item.fitwor-tag:hover {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

.fitwor-chat-fitwor-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5cb85c 0%, #4a9f4a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.fitwor-chat-mention-item-name.fitwor-tag {
    color: #5cb85c;
    font-weight: 700;
}

.fitwor-chat-mention-item-desc {
    font-size: 11px;
    color: #888;
    margin-left: auto;
}

/* @FITWOR u poruci - poseban stil */
.fitwor-chat-mention-fitwor {
    background: linear-gradient(135deg, #5cb85c 0%, #4a9f4a 100%);
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
}

.fitwor-chat-message.own .fitwor-chat-mention-fitwor {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: #fff;
}


/* ============================================
   IMAGE LIGHTBOX
   ============================================ */

.fitwor-chat-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.fitwor-chat-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.fitwor-chat-lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.fitwor-chat-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fitwor-chat-lightbox-close svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* Desktop lightbox close button - bigger */
@media (min-width: 769px) {
    .fitwor-chat-lightbox-close {
        width: 56px;
        height: 56px;
        background: rgba(255, 255, 255, 0.3);
    }
    
    .fitwor-chat-lightbox-close svg {
        width: 32px;
        height: 32px;
    }
}


/* ============================================
   TYPING INDICATOR
   ============================================ */

.fitwor-chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    color: #888;
    font-size: 13px;
}

.fitwor-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.fitwor-chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: #aaa;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.fitwor-chat-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.fitwor-chat-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}


/* ============================================
   DATE SEPARATOR
   ============================================ */

.fitwor-chat-date-separator {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.fitwor-chat-date-separator::before,
.fitwor-chat-date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

.fitwor-chat-date-separator span {
    font-size: 12px;
    color: #888;
    background: #f8f9fa;
    padding: 4px 12px;
    border-radius: 12px;
}


/* ============================================
   CUSTOM MODAL/POPUP
   ============================================ */

.fitwor-chat-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    padding: 20px;
}

.fitwor-chat-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.fitwor-chat-modal {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

.fitwor-chat-modal-overlay.active .fitwor-chat-modal {
    transform: scale(1);
}

.fitwor-chat-modal-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.fitwor-chat-modal-icon.confirm {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
}

.fitwor-chat-modal-icon.success {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

.fitwor-chat-modal-icon.error {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
}

.fitwor-chat-modal-icon.info {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}

.fitwor-chat-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.fitwor-chat-modal-message {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 24px;
}

.fitwor-chat-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.fitwor-chat-modal-btn {
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    min-width: 100px;
}

.fitwor-chat-modal-btn.primary {
    background: linear-gradient(135deg, #5cb85c 0%, #4a9f4a 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(92, 184, 92, 0.3);
}

.fitwor-chat-modal-btn.primary:hover {
    box-shadow: 0 4px 12px rgba(92, 184, 92, 0.5);
    transform: translateY(-1px);
}

.fitwor-chat-modal-btn.secondary {
    background: #f0f0f0;
    color: #666;
}

.fitwor-chat-modal-btn.secondary:hover {
    background: #e0e0e0;
}

.fitwor-chat-modal-btn.danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.fitwor-chat-modal-btn.danger:hover {
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.5);
    transform: translateY(-1px);
}

/* ==================== ATTACH MENU (Admin +) ==================== */

.fitwor-chat-attach-wrapper {
    position: relative;
}

.fitwor-chat-attach-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border: none !important;
    background: #f0f2f5 !important;
    border-radius: 50% !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.fitwor-chat-attach-btn:hover {
    background: #e4e6e9 !important;
}

.fitwor-chat-attach-btn svg {
    width: 28px !important;
    height: 28px !important;
    fill: #5cb85c !important;
}

.fitwor-chat-attach-menu {
    position: absolute;
    bottom: 50px;
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    min-width: 140px;
    z-index: 1000;
}

.fitwor-chat-attach-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.2s ease;
}

.fitwor-chat-attach-option:hover {
    background: #f5f5f5;
}

.fitwor-chat-attach-option svg {
    width: 20px;
    height: 20px;
    fill: #666;
}

.fitwor-chat-attach-option[data-action="poll"] svg {
    fill: #5cb85c;
}

.fitwor-chat-attach-option[data-action="image"] svg {
    fill: #3498db;
}

/* ==================== POLL/ANKETA DISPLAY ==================== */

.fitwor-chat-poll {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
    border: 1px solid #e9ecef;
}

.fitwor-chat-poll-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: #5cb85c;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.fitwor-chat-poll-header svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.fitwor-chat-poll-question {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
}

.fitwor-chat-poll-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Pre glasanja - klikabilne opcije */
.fitwor-chat-poll-option-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.fitwor-chat-poll-option-btn:hover {
    border-color: #5cb85c;
    background: #f0fff0;
}

/* Posle glasanja - rezultati */
.fitwor-chat-poll-result {
    position: relative;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    overflow: hidden;
    box-sizing: border-box;
}

.fitwor-chat-poll-result.voted {
    border-color: #5cb85c;
}

.fitwor-chat-poll-result-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(92, 184, 92, 0.15), rgba(92, 184, 92, 0.05));
    transition: width 0.5s ease;
}

.fitwor-chat-poll-result-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fitwor-chat-poll-result-text {
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fitwor-chat-poll-result-check {
    color: #5cb85c;
    font-weight: bold;
}

.fitwor-chat-poll-result-votes {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
}

.fitwor-chat-poll-result-votes .admin-view-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.fitwor-chat-poll-result-votes .admin-view-btn:hover {
    color: #5cb85c;
}

.fitwor-chat-poll-result-votes .admin-view-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.fitwor-chat-poll-total {
    margin-top: 12px;
    font-size: 12px;
    color: #999;
    text-align: center;
}

/* ==================== POLL CREATE MODAL ==================== */

.fitwor-chat-poll-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.fitwor-chat-poll-modal.active {
    display: flex;
}

.fitwor-chat-poll-modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.fitwor-chat-poll-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fitwor-chat-poll-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fitwor-chat-poll-modal-header h3 svg {
    width: 20px;
    height: 20px;
    fill: #5cb85c;
}

.fitwor-chat-poll-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.fitwor-chat-poll-modal-close:hover {
    background: #e0e0e0;
}

.fitwor-chat-poll-modal-body {
    padding: 20px;
}

.fitwor-chat-poll-field {
    margin-bottom: 20px;
}

.fitwor-chat-poll-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
}

.fitwor-chat-poll-field input,
.fitwor-chat-poll-field textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.fitwor-chat-poll-field input:focus,
.fitwor-chat-poll-field textarea:focus {
    outline: none;
    border-color: #5cb85c;
}

.fitwor-chat-poll-options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fitwor-chat-poll-option-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.fitwor-chat-poll-option-input input {
    flex: 1;
}

.fitwor-chat-poll-option-remove {
    width: 32px;
    height: 32px;
    border: none;
    background: #fee;
    border-radius: 8px;
    cursor: pointer;
    color: #e74c3c;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.fitwor-chat-poll-option-remove:hover {
    background: #fdd;
}

.fitwor-chat-poll-add-option {
    margin-top: 8px;
    padding: 10px;
    border: 2px dashed #ddd;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    font-size: 14px;
    width: 100%;
    transition: all 0.2s ease;
}

.fitwor-chat-poll-add-option:hover {
    border-color: #5cb85c;
    color: #5cb85c;
}

.fitwor-chat-poll-modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ==================== VOTERS POPUP ==================== */

.fitwor-chat-voters-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 100002;
    width: 280px;
    max-height: 300px;
    display: none;
}

.fitwor-chat-voters-popup.active {
    display: block;
}

.fitwor-chat-voters-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fitwor-chat-voters-header h4 {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.fitwor-chat-voters-close {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 18px;
    color: #999;
}

.fitwor-chat-voters-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 8px 0;
}

.fitwor-chat-voter-item {
    padding: 10px 16px;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fitwor-chat-voter-item::before {
    content: "•";
    color: #5cb85c;
}

.fitwor-chat-voters-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 100001;
    display: none;
}

.fitwor-chat-voters-overlay.active {
    display: block;
}

/* ==================== MOBILE OVERRIDES FOR POLLS ==================== */
@media (max-width: 768px) {
    /* + button - ensure perfect circle on mobile */
    .fitwor-chat-attach-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        max-width: 40px !important;
        max-height: 40px !important;
        border-radius: 50% !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
        aspect-ratio: 1 / 1 !important;
    }
    
    .fitwor-chat-attach-btn svg {
        width: 28px !important;
        height: 28px !important;
    }
    
    /* Smanji gap između broja i oka na mobilnom */
    .fitwor-chat-poll-result-votes {
        gap: 2px !important;
    }
}
