/**
 * Chat Styles
 * Modern chat interface styling for real-time messaging
 */

/* Chat Container */
.chat-container {
    display: flex;
    height: calc(100vh - 180px);
    min-height: 500px;
    background: #f5f7fa;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Chat Sidebar */
.chat-sidebar {
    width: 320px;
    min-width: 280px;
    background: white;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
}

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

.chat-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-sidebar-header h3 i {
    color: var(--primary-color, #f70880);
}

.chat-refresh-btn {
    background: none;
    border: none;
    color: #8898aa;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.chat-refresh-btn:hover {
    background: #f6f9fc;
    color: var(--primary-color, #f70880);
}

/* Chat Search */
.chat-search {
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
}

.chat-search i {
    color: #adb5bd;
    font-size: 20px;
}

.chat-search input {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    color: #333;
    outline: none;
}

.chat-search input::placeholder {
    color: #adb5bd;
}

/* Chat Contacts List */
.chat-contacts {
    flex: 1;
    overflow-y: auto;
}

.chat-contacts::-webkit-scrollbar {
    width: 5px;
}

.chat-contacts::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.chat-no-contacts {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #8898aa;
    text-align: center;
}

.chat-no-contacts i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Contact Item */
.chat-contact-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

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

.chat-contact-item.active {
    background: linear-gradient(90deg, rgba(247, 8, 128, 0.08), transparent);
    border-left-color: var(--primary-color, #f70880);
}

.chat-contact-item.unread {
    background: rgba(247, 8, 128, 0.04);
}

.chat-contact-item.unread .contact-name {
    font-weight: 600;
}

/* Contact Avatar */
.contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color, #f70880), var(--accent-color, #ff8552));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    position: relative;
    flex-shrink: 0;
}

.contact-avatar.online::after,
.online-indicator {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #2dce89;
    border: 2px solid white;
    border-radius: 50%;
}

/* Contact Info */
.contact-info {
    flex: 1;
    min-width: 0;
    margin-left: 12px;
}

.contact-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.contact-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-preview {
    font-size: 13px;
    color: #8898aa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Contact Meta */
.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin-left: 8px;
}

.contact-time {
    font-size: 11px;
    color: #adb5bd;
}

.unread-badge {
    background: var(--primary-color, #f70880);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Role Badge */
.chat-role-badge {
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.chat-role-badge.admin {
    background: rgba(247, 8, 128, 0.15);
    color: #f70880;
}

.chat-role-badge.trainer {
    background: rgba(17, 205, 239, 0.15);
    color: #11cdef;
}

.chat-role-badge.student {
    background: rgba(45, 206, 137, 0.15);
    color: #2dce89;
}

/* Sidebar Footer */
.chat-sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.chat-connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #8898aa;
}

.chat-connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #adb5bd;
}

.chat-connection-status.connected .status-dot {
    background: #2dce89;
    animation: pulse 2s infinite;
}

.chat-connection-status.disconnected .status-dot {
    background: #f5365c;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
}

/* Empty State */
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    color: #8898aa;
}

.chat-empty-state .empty-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(247, 8, 128, 0.1), rgba(255, 133, 82, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.chat-empty-state .empty-icon i {
    font-size: 48px;
    color: var(--primary-color, #f70880);
}

.chat-empty-state h3 {
    margin: 0 0 8px;
    font-size: 20px;
    color: #333;
}

.chat-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* Chat Header */
.chat-header {
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color, #f70880), var(--accent-color, #ff8552));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 15px;
    position: relative;
}

.header-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #2dce89;
    border: 2px solid white;
    border-radius: 50%;
}

.header-details {
    display: flex;
    flex-direction: column;
}

.header-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-status {
    font-size: 12px;
    color: #8898aa;
}

.header-status.online {
    color: #2dce89;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.header-action-btn {
    background: #f6f9fc;
    border: none;
    padding: 8px;
    border-radius: 8px;
    color: #8898aa;
    cursor: pointer;
    transition: all 0.2s;
}

.header-action-btn:hover {
    background: var(--primary-color, #f70880);
    color: white;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.messages-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px;
    color: #8898aa;
}

.no-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #adb5bd;
    text-align: center;
}

.no-messages i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Message Date Divider */
.message-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
}

.message-date-divider span {
    background: #e9ecef;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    color: #8898aa;
    font-weight: 500;
}

/* Message Bubble */
.message {
    display: flex;
    max-width: 70%;
}

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

.message.received {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, var(--primary-color, #f70880), var(--accent-color, #ff8552));
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.message.pending .message-bubble {
    opacity: 0.7;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
}

.message-time {
    font-size: 10px;
    opacity: 0.7;
}

.message-status {
    font-size: 12px;
    opacity: 0.7;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    font-size: 13px;
    color: #8898aa;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #adb5bd;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Chat Input Area */
.chat-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f6f9fc;
    border-radius: 24px;
    padding: 4px 4px 4px 20px;
}

.chat-input-wrapper input {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    color: #333;
    outline: none;
    padding: 10px 0;
}

.chat-input-wrapper input::placeholder {
    color: #adb5bd;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary-color, #f70880), var(--accent-color, #ff8552));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(247, 8, 128, 0.3);
}

.send-btn i {
    font-size: 20px;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 140px);
    }

    .chat-sidebar {
        width: 100%;
        max-height: 200px;
    }

    .chat-contacts {
        display: flex;
        overflow-x: auto;
        padding: 8px;
        gap: 8px;
    }

    .chat-contact-item {
        flex-direction: column;
        min-width: 80px;
        padding: 10px;
        text-align: center;
        border-radius: 12px;
        border-left: none;
    }

    .chat-contact-item.active {
        background: linear-gradient(135deg, rgba(247, 8, 128, 0.15), rgba(255, 133, 82, 0.1));
        border-left: none;
    }

    .contact-info {
        margin-left: 0;
        margin-top: 8px;
    }

    .contact-preview,
    .contact-meta {
        display: none;
    }

    .message {
        max-width: 85%;
    }
}

/* Admin Sidebar Tabs */
.chat-admin-tabs {
    display: flex;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.chat-admin-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 8px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: #8898aa;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    position: relative;
}

.chat-admin-tab i {
    font-size: 16px;
}

.chat-admin-tab.active {
    color: var(--primary-color, #f70880);
    border-bottom-color: var(--primary-color, #f70880);
    background: white;
}

.chat-tab-badge {
    background: var(--primary-color, #f70880);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

/* Monitor mode avatar */
.monitor-avatar {
    background: linear-gradient(135deg, #5e72e4, #825ee4);
}

/* Admin monitor footer */
.chat-admin-monitor-footer {
    padding: 10px 16px;
    background: #fff8e1;
    border-top: 1px solid #ffe082;
    font-size: 12px;
    color: #5d4037;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-admin-monitor-footer i {
    font-size: 16px;
}

/* Admin edit area */
.chat-admin-edit-area {
    padding: 8px 16px;
    background: #e8f5e9;
    border-top: 1px solid #c8e6c9;
    align-items: center;
    gap: 8px;
}

.chat-admin-edit-area input {
    flex: 1;
    border: 1px solid #a5d6a7;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}

/* Message action buttons (admin CRUD) */
.message.monitor-msg {
    flex-direction: column;
    max-width: 80%;
}

.msg-sender-name {
    font-size: 11px;
    font-weight: 600;
    color: #5e72e4;
    margin-bottom: 3px;
    padding-left: 4px;
}

.message.monitor-msg.sent .msg-sender-name {
    text-align: right;
    color: var(--primary-color, #f70880);
    padding-right: 4px;
    padding-left: 0;
}

.msg-admin-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.message:hover .msg-admin-actions {
    opacity: 1;
}

.msg-action-btn {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 3px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.msg-action-btn i {
    font-size: 14px;
}

.msg-action-btn.edit-btn {
    color: #5e72e4;
}

.msg-action-btn.edit-btn:hover {
    background: #5e72e4;
    color: white;
    border-color: #5e72e4;
}

.msg-action-btn.delete-btn {
    color: #f5365c;
}

.msg-action-btn.delete-btn:hover {
    background: #f5365c;
    color: white;
    border-color: #f5365c;
}

/* Admin Chat Dashboard Styles */
.admin-chat-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.admin-chat-stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.admin-chat-stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.admin-chat-stat-card .stat-icon i {
    font-size: 24px;
    color: white;
}

.admin-chat-stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #333;
}

.admin-chat-stat-card .stat-label {
    font-size: 13px;
    color: #8898aa;
    margin-top: 4px;
}

/* Admin Conversations List */
.admin-conversations-list {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.admin-conversation-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

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

.admin-conversation-item:last-child {
    border-bottom: none;
}

.conversation-users {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.conversation-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.conversation-arrow {
    color: #adb5bd;
}

.conversation-stats {
    display: flex;
    gap: 16px;
    color: #8898aa;
    font-size: 13px;
}

.conversation-actions {
    margin-left: 16px;
}
