/**
 * Chat System Styles
 * WhatsApp/Messenger-inspired design
 * Updated: Dark theme with bg-gray-850 (#1a1d24) and border-gray-800 (#1f2937)
 */

.chat-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.chat-header {
    background: #2d3748; /* Solid dark gray - simple and clean */
    color: white;
    padding: 12px 15px; /* Reduced from 20px */
    border-radius: 12px 12px 0 0;
    box-shadow: none; /* Removed shadow for minimalist look */
    border-bottom: 1px solid #374151; /* Subtle separator */
}

.chat-header h1 {
    margin: 0;
    font-size: 18px; /* Reduced from 24px */
    font-weight: 600;
}

.chat-header p {
    margin: 4px 0 0 0; /* Reduced from 5px */
    opacity: 0.85; /* Slightly reduced from 0.9 */
    font-size: 12px; /* Reduced from 14px */
}

.chat-stats {
    display: flex;
    align-items: center;
    gap: 10px; /* Reduced from 15px */
    margin-top: 6px; /* Reduced from 10px */
    font-size: 11px; /* Reduced from 14px */
    opacity: 0.8; /* Added to make it less prominent */
}

.chat-stats i {
    margin-right: 4px; /* Reduced from 5px */
    font-size: 10px; /* Smaller icons */
}

.chat-body {
    background: #1a1d24; /* bg-gray-850 */
    border-left: 1px solid #1f2937; /* border-gray-800 */
    border-right: 1px solid #1f2937; /* border-gray-800 */
    min-height: 500px;
    max-height: 600px;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

.chat-messages-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Empty state */
.chat-empty {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280; /* Lighter gray for dark background */
}

.chat-empty i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
    color: #9ca3af;
}

.chat-empty p {
    font-size: 16px;
    margin: 0;
}

/* Loading indicator */
.chat-loading {
    text-align: center;
    padding: 10px;
    color: #9ca3af; /* Lighter gray for dark background */
    font-size: 14px;
}

.chat-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Message bubble */
.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start; /* Align items to top */
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.own {
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    align-self: center; /* Center avatar vertically */
}

.message-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.message-body {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 75%;
}

.chat-message.own .message-body {
    flex-direction: row-reverse;
}

.message-content {
    min-width: 120px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.message-user {
    color: #60a5fa; /* Lighter blue for dark background */
    font-weight: 600;
}

.chat-message.own .message-user {
    color: #3b82f6; /* Lighter blue for dark background */
}

.message-text {
    background: #2d3748; /* Dark gray for message bubbles */
    color: #e5e7eb; /* Light text color */
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    word-wrap: break-word;
    line-height: 1.5;
}

.chat-message.own .message-text {
    background: linear-gradient(135deg, #4280FF 0%, #007bff 100%);
    color: white;
}

.message-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}

.chat-message.own .message-footer {
    justify-content: flex-start;
}

.message-time {
    color: #9ca3af; /* Lighter gray for dark background */
    font-size: 11px;
    font-style: italic;
}

/* Chat footer (form) */
.chat-footer {
    background: #1a1d24; /* bg-gray-850 */
    padding: 20px;
    border-radius: 0 0 12px 12px;
    border: 1px solid #1f2937; /* border-gray-800 */
    border-top: none;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding: 12px;
    background: #2d3748; /* Darker gray for user info */
    border-radius: 8px;
    border: 1px solid #374151;
}

.chat-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-user-details {
    flex: 1;
}

.chat-user-name {
    display: block;
    font-weight: 600;
    color: #f3f4f6; /* Light text for dark background */
    font-size: 14px;
}

.chat-user-email {
    display: block;
    color: #9ca3af; /* Lighter gray for dark background */
    font-size: 12px;
}

.chat-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.chat-form .reply-bar {
    width: 100%;
    order: -1;
    margin-bottom: 0;
}

.chat-form .chat-input-wrapper {
    flex: 1;
    min-width: 0;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #374151; /* Darker border for dark theme */
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #2d3748; /* Dark input background */
    color: #f3f4f6; /* Light text color */
}

.chat-input:focus {
    outline: none;
    border-color: #4280FF;
    background: #374151; /* Slightly lighter on focus */
}

.chat-input::placeholder {
    color: #6b7280; /* Lighter placeholder for dark background */
}

.chat-send-btn {
    background: linear-gradient(135deg, #4280FF 0%, #007bff 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    min-width: 100px;
}

.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 128, 255, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send-btn i {
    margin-right: 6px;
}

.chat-cooldown {
    text-align: center;
    color: #f59e0b;
    font-size: 13px;
    margin-top: 8px;
    display: none;
}

.chat-cooldown i {
    margin-right: 5px;
}

/* Login prompt */
.chat-login-prompt {
    text-align: center;
    padding: 30px;
    background: #2d3748; /* Dark background for login prompt */
    border-radius: 8px;
    border: 1px solid #374151;
}

.chat-login-prompt i {
    font-size: 48px;
    color: #60a5fa; /* Lighter blue for dark background */
    margin-bottom: 15px;
}

.chat-login-prompt p {
    margin: 0 0 20px 0;
    color: #d1d5db; /* Light gray text */
    font-size: 16px;
}

.chat-login-btn {
    background: #374151; /* Dark button background */
    color: #f3f4f6; /* Light text */
    border: 2px solid #4b5563;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.chat-login-btn:hover {
    border-color: #4280FF;
    background: #4b5563;
    color: #60a5fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 128, 255, 0.3);
}

.chat-login-btn img {
    width: 20px;
    height: 20px;
}

/* Refresh button */
.chat-refresh-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-refresh-btn:hover {
    background: rgba(255,255,255,0.3);
}

.chat-refresh-btn i {
    margin-right: 5px;
}

/* Message Actions Menu */
.message-actions {
    position: relative;
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.message-body:hover .message-actions {
    opacity: 1;
}

.message-actions-btn {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 14px;
}

.message-actions-btn:hover {
    background: rgba(107, 114, 128, 0.2);
    color: #e5e7eb;
}

.message-actions-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px) scale(0.95);
    margin-top: 5px;
    background: #2d3748;
    border: 1px solid #374151;
    border-radius: 12px;
    padding: 8px 0;
    min-width: 140px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
}

.message-actions-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}



.message-actions-menu .action-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: #e5e7eb;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.message-actions-menu .action-item:hover {
    background: #374151;
}

.message-actions-menu .action-item.active {
    color: #60a5fa;
}

.message-actions-menu .action-item i {
    width: 16px;
    text-align: center;
}

/* Reaction Picker */
.reaction-picker {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid #374151;
}

.reaction-picker .reaction-item {
    padding: 6px 10px;
    border-radius: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reaction-picker .reaction-item:hover {
    background: #374151;
    transform: scale(1.2);
}

.reaction-picker .reaction-item.active {
    background: rgba(66, 128, 255, 0.3);
}

.reaction-picker .reaction-emoji {
    font-size: 18px;
}

.message-actions-menu .reply-item {
    border-top: 1px solid #374151;
}

/* Reactions */
.message-reactions {
    display: flex;
    gap: 8px;
    margin-right: 10px;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reaction-badge.like {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}
.reaction-badge.like:hover, .reaction-badge.like.active {
    background: rgba(59, 130, 246, 0.4);
}

.reaction-badge.heart {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}
.reaction-badge.heart:hover, .reaction-badge.heart.active {
    background: rgba(239, 68, 68, 0.4);
}

.reaction-badge.dislike {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
}
.reaction-badge.dislike:hover, .reaction-badge.dislike.active {
    background: rgba(156, 163, 175, 0.4);
}

.reaction-badge.angry {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
}
.reaction-badge.angry:hover, .reaction-badge.angry.active {
    background: rgba(249, 115, 22, 0.4);
}

.reaction-badge i {
    font-size: 11px;
}

/* Reply Preview in Message */
.reply-preview {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.reply-preview:hover {
    background: rgba(255,255,255,0.1);
}

.reply-indicator {
    width: 3px;
    background: #4280FF;
    border-radius: 2px;
    flex-shrink: 0;
}

.reply-content {
    overflow: hidden;
    min-width: 0;
}

.reply-user {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #60a5fa;
    margin-bottom: 2px;
}

.reply-text {
    display: block;
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Reply Bar (compact, inside input area) */
.reply-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(66, 128, 255, 0.15) 0%, rgba(66, 128, 255, 0.08) 100%);
    border-left: 3px solid #4280FF;
    border-radius: 0 8px 8px 0;
    margin-bottom: 8px;
    animation: slideDown 0.15s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.reply-bar-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #e5e7eb;
    font-size: 12px;
}

.reply-bar-content i {
    color: #4280FF;
    font-size: 11px;
    flex-shrink: 0;
}

.reply-bar-content span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-bar-content strong {
    color: #60a5fa;
}

.reply-bar-close {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    font-size: 12px;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}

.reply-bar-close:hover {
    color: #f87171;
}

/* Message Highlight (when scrolling to replied message) */
.chat-message.highlight {
    animation: highlightPulse 2s ease;
}

@keyframes highlightPulse {
    0%, 100% { background: transparent; }
    25%, 75% { background: rgba(66, 128, 255, 0.15); }
}

/* Reactors Modal */
.reactors-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reactors-modal.show {
    opacity: 1;
}

.reactors-modal-content {
    background: #2d3748;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.reactors-modal.show .reactors-modal-content {
    transform: scale(1);
}

.reactors-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #374151;
}

.reactors-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #f3f4f6;
}

.reactors-modal-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
}

.reactors-modal-close:hover {
    color: #f87171;
}

.reactors-modal-body {
    padding: 16px 20px;
    max-height: 400px;
    overflow-y: auto;
}

.reactor-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #374151;
}

.reactor-item:last-child {
    border-bottom: none;
}

.reactor-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.reactor-name {
    flex: 1;
    color: #e5e7eb;
    font-weight: 500;
}

.reactor-time {
    color: #9ca3af;
    font-size: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        padding: 10px;
    }

    .chat-header {
        padding: 10px 12px;
        border-radius: 8px 8px 0 0;
    }

    .chat-header h1 {
        font-size: 16px;
    }

    .chat-header p {
        font-size: 11px;
    }

    .chat-stats {
        font-size: 10px;
        gap: 8px;
        margin-top: 4px;
    }

    .chat-body {
        min-height: 400px;
        max-height: 500px;
        padding: 15px;
    }

    .message-content {
        max-width: 80%;
    }

    .message-avatar img {
        width: 32px;
        height: 32px;
    }

    .chat-footer {
        padding: 12px;
    }

    .chat-send-btn {
        padding: 10px 16px;
        min-width: auto;
        font-size: 13px;
    }

    .chat-send-btn span {
        display: none;
    }

    .message-actions {
        opacity: 1;
    }

    .message-actions-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }

    /* Reply bar mobile optimization */
    .reply-bar {
        padding: 5px 10px;
        margin-bottom: 6px;
        border-radius: 0 6px 6px 0;
    }

    .reply-bar-content {
        font-size: 11px;
        gap: 6px;
    }

    .reply-bar-content i {
        font-size: 10px;
    }

    .reply-bar-close {
        padding: 3px;
        font-size: 11px;
    }

    /* Input optimization on mobile */
    .chat-input {
        padding: 10px 14px;
        font-size: 14px;
        min-height: 42px;
    }

    .chat-form {
        gap: 8px;
    }
}

