/**
 * Unified Chat Styles
 * Used by both frontend and admin chat
 */

/* ===== CHAT CONTAINER ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px;
}

/* ===== CHAT BUBBLES ===== */
.chat-bubble {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    word-break: break-word;
    position: relative;
}

/* Animation only for newly added messages */
.chat-bubble.new-message {
    animation: fadeIn 0.3s ease;
}

.chat-bubble.guest {
    background: #e9ecef;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-bubble.admin {
    background: #28a745;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-bubble.user {
    background: #007bff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* ===== MESSAGE META ===== */
.chat-bubble .meta {
    font-size: 0.7em;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    opacity: 0.8;
    gap: 8px;
}

.chat-bubble.admin .meta,
.chat-bubble.user .meta {
    color: rgba(255, 255, 255, 0.9);
}

.chat-bubble.guest .meta {
    color: rgba(0, 0, 0, 0.6);
}

/* ===== MESSAGE CONTENT ===== */
.chat-bubble .message {
    font-size: 0.95em;
    line-height: 1.4;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 10px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* ===== FRONTEND CHAT SPECIFIC ===== */
#chat-section {
    position: relative;
    z-index: 9999;
}

#chat-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #28a745;
    color: #fff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    text-align: center;
    font-size: 30px;
    line-height: 60px;
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#chat-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

#chat-icon.has-new::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #dc3545;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

#chat-box {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    max-height: 450px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    display: none;
    flex-direction: column;
    z-index: 9999;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

#chat-box.open {
    display: flex;
}

.chat-header {
    background: #28a745;
    color: white;
    padding: 12px 15px;
    border-radius: 10px 10px 0 0;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

#chat-status {
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 12px;
}

#chat-messages {
    padding: 12px;
    flex: 1;
    overflow-y: auto;
    height: 300px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Custom Scrollbar */
#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #28a745;
    border-radius: 4px;
}

#chat-form {
    display: flex;
    padding: 10px;
    background: white;
    border-top: 1px solid #eee;
    gap: 8px;
}

#chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 13px;
    transition: border 0.2s;
}

#chat-input:focus {
    border-color: #28a745;
}

#chat-send-btn {
    width: 36px;
    height: 36px;
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#chat-send-btn:hover {
    background: #218838;
}

#chat-send-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== ADMIN CHAT SPECIFIC ===== */
.admin-chat-box {
    max-height: 400px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

.admin-chat-box .chat-container {
    gap: 10px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 576px) {
    #chat-box {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
    }
    
    #chat-icon {
        width: 50px;
        height: 50px;
        font-size: 24px;
        line-height: 50px;
    }
}
