/* MAHINESKA - Style dla systemu czatu */

/* Przycisk "Zapytaj o produkt" */
.btn-chat-product {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 10px;
}

.btn-chat-product:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.btn-chat-product svg {
    width: 20px;
    height: 20px;
}

/* Modal czatu dla użytkowników */
.chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    height: 80vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.chat-modal-title-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.chat-product-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    font-size: 14px;
    color: #666;
}

.chat-product-info img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.chat-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-modal-close:hover {
    background: #e0e0e0;
    color: #333;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f5f5f5;
}

.chat-loading,
.chat-empty {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 14px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-message.own {
    align-self: flex-end;
}

.chat-message.other {
    align-self: flex-start;
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.chat-message.own .chat-message-header {
    justify-content: flex-end;
}

.chat-message-sender {
    font-weight: 600;
    color: #666;
}

.chat-message-time {
    color: #999;
}

.chat-message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.own .chat-message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.other .chat-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.chat-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-attach-btn,
.messages-attach-btn {
    padding: 8px;
    background: #f0f0f0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    align-self: flex-start;
}

.chat-attach-btn:hover,
.messages-attach-btn:hover {
    background: #e0e0e0;
}

.chat-images-preview,
.messages-images-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.chat-image-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
}

.chat-image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-image-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.chat-image-remove:hover {
    background: rgba(0, 0, 0, 0.8);
}

.chat-message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-message-images img {
    max-width: 200px;
    max-height: 200px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    object-fit: contain;
    border: 1px solid #e0e0e0;
    transition: transform 0.2s;
    background: #f5f5f5;
}

.chat-message-images img:hover {
    transform: scale(1.05);
}

/* Responsywność dla obrazów w czacie na mobile */
@media (max-width: 768px) {
    .chat-message-images {
        gap: 6px;
    }
    
    .chat-message-images img {
        max-width: calc(100% - 20px);
        max-height: 250px;
        width: auto;
    }
    
    .chat-message.own .chat-message-images img {
        max-width: calc(75% - 20px);
    }
    
    .chat-message.other .chat-message-images img {
        max-width: calc(75% - 20px);
    }
}

.chat-image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.chat-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

.chat-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.5;
}

.chat-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.chat-send-btn {
    padding: 10px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 44px;
    height: 44px;
}

.chat-send-btn:hover:not(:disabled) {
    background: #0056b3;
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Panel czatów dla adminów */
.admin-chats-container {
    padding: 20px;
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

.admin-chats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.admin-chats-header h1 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.btn-refresh-chats {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-refresh-chats:hover {
    background: #0056b3;
}

.admin-chats-layout {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.admin-chats-list {
    width: 350px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chats-loading,
.chats-empty,
.chats-error {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.chats-error {
    color: #dc3545;
}

.admin-chat-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.admin-chat-item:hover {
    background: #f8f9fa;
}

.admin-chat-item.active {
    background: #e7f3ff;
    border-left: 4px solid #007bff;
}

.chat-item-image {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
}

.chat-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-product-image-placeholder {
    width: 100%;
    height: 100%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.chat-item-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.chat-item-title a {
    color: #007bff;
    text-decoration: none !important;
    transition: color 0.2s, text-decoration 0.2s;
}

.chat-item-title a:hover {
    color: #0056b3;
    text-decoration: underline !important;
}

.chat-unread-badge {
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.chat-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: #999;
}

.chat-item-user {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.chat-item-time {
    flex-shrink: 0;
}

.admin-chats-messages {
    flex: 1;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.messages-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    padding: 40px;
}

.messages-placeholder svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.messages-placeholder p {
    margin: 0;
    font-size: 16px;
}

.messages-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.messages-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.messages-header-info img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
}

.messages-header-info h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #333;
}

.messages-header-info h3 a {
    color: #007bff;
    text-decoration: none !important;
    transition: color 0.2s, text-decoration 0.2s;
}

.messages-header-info h3 a:hover {
    color: #0056b3;
    text-decoration: underline !important;
}

.messages-header-info p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.messages-empty,
.messages-error {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 14px;
}

.messages-error {
    color: #dc3545;
}

.admin-message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    animation: messageSlideIn 0.3s ease;
}

.admin-message.admin {
    align-self: flex-end;
}

.admin-message.user {
    align-self: flex-start;
}

.admin-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.admin-message.admin .admin-message-header {
    justify-content: flex-end;
}

.admin-message-sender {
    font-weight: 600;
    color: #666;
}

.admin-message-time {
    color: #999;
}

.admin-message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.admin-message.admin .admin-message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.admin-message.user .admin-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.messages-input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.messages-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.messages-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.5;
}

.messages-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.messages-send-btn {
    padding: 10px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 44px;
    height: 44px;
}

.messages-send-btn:hover:not(:disabled) {
    background: #0056b3;
}

.messages-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsywność */
@media (max-width: 768px) {
    .chat-modal-content {
        height: 90vh;
        max-height: none;
    }
    
    .admin-chats-layout {
        flex-direction: column;
    }
    
    .admin-chats-list {
        width: 100%;
        max-height: 300px;
    }
    
    .chat-message,
    .admin-message {
        max-width: 85%;
    }
}

