/* Chat System Styles for PHP Auth System v1.0.0 */

/* Chat Container */
.chat-container {
    display: flex;
    height: calc(100vh - 200px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.chat-sidebar {
    width: 320px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Chat Header */
.chat-header {
    padding: 1rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
}

.chat-header-details h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-header-details small {
    color: #6c757d;
    font-size: 0.875rem;
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f1f3f4;
}

.conversation-item:hover,
.conversation-item.active {
    background: #e3f2fd;
}

.conversation-item.unread {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 0.75rem;
    position: relative;
}

.conversation-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #28a745;
    border: 2px solid white;
    border-radius: 50%;
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-last-message {
    color: #6c757d;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #adb5bd;
}

.conversation-unread {
    background: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #fafbfc;
}

.message-group {
    margin-bottom: 1.5rem;
}

.message-item {
    display: flex;
    margin-bottom: 0.5rem;
    align-items: flex-start;
    gap: 0.75rem;
}

.message-item.own {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.4;
}

.message-item.own .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.message-item:not(.own) .message-bubble {
    background: white;
    color: #333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-item.own .message-bubble::after {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 12px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #667eea;
}

.message-item:not(.own) .message-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 12px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: white;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #6c757d;
}

.message-item.own .message-meta {
    justify-content: flex-end;
}

.message-time {
    font-size: 0.75rem;
    color: #adb5bd;
}

.message-status {
    font-size: 0.75rem;
}

.message-status.sent {
    color: #28a745;
}

.message-status.delivered {
    color: #17a2b8;
}

.message-status.read {
    color: #007bff;
}

/* Message Reactions */
.message-reactions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.reaction-button {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.reaction-button:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.reaction-button.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.reaction-count {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* Message Attachments */
.message-attachment {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.02);
}

.attachment-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.attachment-image:hover {
    transform: scale(1.05);
}

.attachment-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
}

.attachment-icon {
    font-size: 1.5rem;
    color: #6c757d;
}

.attachment-info {
    flex: 1;
}

.attachment-name {
    font-weight: 500;
    margin-bottom: 0.125rem;
}

.attachment-size {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-style: italic;
    color: #6c757d;
    font-size: 0.875rem;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat Input Area */
.chat-input-area {
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.chat-input-container {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 0.75rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 22px;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input::placeholder {
    color: #adb5bd;
}

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-attach-btn,
.chat-emoji-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #f8f9fa;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-attach-btn:hover,
.chat-emoji-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 320px;
    max-height: 300px;
    overflow: hidden;
    display: none;
    z-index: 1000;
}

.emoji-picker.show {
    display: block;
}

.emoji-picker-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    gap: 0.5rem;
}

.emoji-category-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    background: none;
    color: #6c757d;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.emoji-category-btn.active,
.emoji-category-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

.emoji-grid {
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    max-height: 240px;
    overflow-y: auto;
}

.emoji-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    font-size: 1.2rem;
}

.emoji-item:hover {
    background: #f8f9fa;
}

/* User Presence */
.user-presence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.5rem;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.presence-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.presence-online {
    background: #28a745;
}

.presence-away {
    background: #ffc107;
}

.presence-busy {
    background: #dc3545;
}

.presence-offline {
    background: #6c757d;
}

.presence-text {
    font-size: 0.875rem;
    color: #495057;
}

/* Chat Modals */
.chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 1rem;
}

.chat-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
}

.chat-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.chat-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.chat-modal-close:hover {
    background: #f8f9fa;
}

.chat-modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.chat-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 150px);
        flex-direction: column;
    }

    .chat-sidebar {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }

    .conversations-list {
        display: flex;
        overflow-x: auto;
        padding: 0.5rem;
    }

    .conversation-item {
        min-width: 280px;
        margin-right: 0.5rem;
        border-bottom: none;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .chat-main {
        height: calc(100vh - 350px);
    }

    .message-bubble {
        max-width: 85%;
    }

    .chat-input-area {
        padding: 0.75rem 1rem;
    }

    .emoji-picker {
        width: calc(100vw - 2rem);
        max-width: 320px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 0.75rem 1rem;
    }

    .chat-avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .chat-messages {
        padding: 0.75rem;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .message-bubble {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .chat-input {
        min-height: 40px;
        padding: 0.5rem 0.75rem;
    }

    .chat-send-btn {
        width: 40px;
        height: 40px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .chat-container {
        background: #1a1a1a;
        color: #fff;
    }

    .chat-sidebar {
        background: #2d2d2d;
        border-right-color: #404040;
    }

    .chat-header {
        background: #2d2d2d;
        border-bottom-color: #404040;
        color: #fff;
    }

    .conversations-list {
        background: #2d2d2d;
    }

    .conversation-item:hover,
    .conversation-item.active {
        background: #404040;
    }

    .conversation-item.unread {
        background: #4d4d1a;
        border-left-color: #ffc107;
    }

    .chat-messages {
        background: #1a1a1a;
    }

    .message-item:not(.own) .message-bubble {
        background: #2d2d2d;
        color: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .message-item:not(.own) .message-bubble::before {
        border-right-color: #2d2d2d;
    }

    .chat-input-area {
        background: #2d2d2d;
        border-top-color: #404040;
    }

    .chat-input {
        background: #404040;
        border-color: #555;
        color: #fff;
    }

    .chat-input:focus {
        border-color: #667eea;
    }

    .chat-attach-btn,
    .chat-emoji-btn {
        background: #404040;
        color: #ccc;
    }

    .chat-attach-btn:hover,
    .chat-emoji-btn:hover {
        background: #555;
        color: #fff;
    }

    .emoji-picker {
        background: #2d2d2d;
        border-color: #404040;
    }

    .emoji-category-btn {
        color: #ccc;
    }

    .emoji-category-btn.active,
    .emoji-category-btn:hover {
        background: #404040;
        color: #fff;
    }

    .emoji-item:hover {
        background: #404040;
    }
}

/* Print Styles */
@media print {
    .chat-container,
    .chat-sidebar,
    .chat-input-area {
        display: none !important;
    }

    .chat-messages {
        background: white !important;
        color: black !important;
    }

    .message-bubble {
        border: 1px solid #000 !important;
        background: white !important;
        color: black !important;
    }
}
