﻿/* RESET & BASE */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.chat-app {
    height: calc(100vh - 300px);
    background: #f0f2f5;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.chat-layout {
    display: flex;
    height: calc(100vh - 300px);
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* SIDEBAR */
.chat-sidebar {
    width: 380px;
    min-width: 380px;
    background: white;
    border-right: 1px solid #e4e6eb;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e4e6eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

    .sidebar-header h3 {
        margin: 0;
        font-size: 20px;
        font-weight: 700;
        color: #1a1a2e;
    }

.user-badge {
    background: #e4e6eb;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: #1a1a2e;
    font-weight: 500;
}

.user-search {
    padding: 12px 16px;
    border-bottom: 1px solid #e4e6eb;
}

    .user-search input {
        width: 100%;
        padding: 10px 14px;
        border: none;
        border-radius: 8px;
        background: #f0f2f5;
        font-size: 14px;
        outline: none;
        transition: all 0.2s;
    }

        .user-search input:focus {
            background: #e4e6eb;
        }

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
    position: relative;
}

    .user-item:hover {
        background: #f0f2f5;
    }

    .user-item.active {
        background: #e7f3ff;
        border-left-color: #0084ff;
    }

.avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
    margin-right: 14px;
}

    .avatar-circle.small {
        width: 40px;
        height: 40px;
        font-size: 15px;
        margin-right: 12px;
    }

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 15px;
    margin-bottom: 2px;
}

.user-last-message {
    font-size: 13px;
    color: #65676b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: #0084ff;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

/* MAIN CHAT */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    height: 100vh;
}

.no-chat-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #65676b;
    padding: 40px;
}

.empty-chat-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.no-chat-selected h4 {
    margin: 0 0 8px 0;
    color: #1a1a2e;
}

.no-chat-selected p {
    margin: 0;
    font-size: 14px;
}

/* Chat Header */
.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #e4e6eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.chat-contact {
    display: flex;
    align-items: center;
}

.contact-name {
    font-weight: 600;
    font-size: 16px;
    color: #1a1a2e;
}

.contact-status {
    font-size: 13px;
    color: #65676b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #31a24c;
    border-radius: 50%;
}

.btn-refresh {
    background: none;
    border: 1px solid #e4e6eb;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #1a1a2e;
    transition: all 0.2s;
}

    .btn-refresh:hover {
        background: #f0f2f5;
        border-color: #0084ff;
    }

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.no-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #65676b;
}

    .no-messages div {
        font-size: 48px;
        margin-bottom: 12px;
    }

.message-row {
    display: flex;
    animation: fadeIn 0.3s ease;
    margin-bottom: 4px;
}

    .message-row.sent {
        justify-content: flex-end;
    }

    .message-row.received {
        justify-content: flex-start;
    }

.message-bubble {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
}

.message-row.sent .message-bubble {
    background: #0084ff;
    color: white;
    border-bottom-right-radius: 4px;
}

.message-row.received .message-bubble {
    background: white;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-content {
    font-size: 15px;
    line-height: 1.4;
}

.message-timestamp {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message-row.received .message-timestamp {
    color: #65676b;
}

/* MESSAGE INPUT - CLEARLY VISIBLE */
.message-input-area {
    padding: 16px 24px;
    border-top: 1px solid #e4e6eb;
    background: white;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #f0f2f5;
    border-radius: 24px;
    padding: 4px 4px 4px 20px;
    transition: all 0.2s;
    border: 2px solid transparent;
}

    .input-wrapper:focus-within {
        background: white;
        border-color: #0084ff;
        box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.1);
    }

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 15px;
    outline: none;
    color: #1a1a2e;
    min-height: 48px;
}

    .message-input::placeholder {
        color: #8a8d91;
    }

.send-button {
    background: #0084ff;
    color: white;
    border: none;
    padding: 10px 28px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 90px;
    white-space: nowrap;
}

    .send-button:hover:not(:disabled) {
        background: #0073e6;
        transform: scale(1.02);
    }

    .send-button:active:not(:disabled) {
        transform: scale(0.98);
    }

    .send-button:disabled {
        background: #c0c0c0;
        cursor: not-allowed;
        opacity: 0.6;
    }

.input-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
    padding: 0 8px;
}

.char-count {
    font-size: 12px;
    color: #8a8d91;
}

/* LOADING & EMPTY STATES */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #65676b;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #65676b;
}

    .empty-state div {
        font-size: 48px;
        margin-bottom: 12px;
    }

/* ANIMATIONS */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* SCROLLBAR */
.user-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.user-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.user-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: #c1c7cd;
    border-radius: 3px;
}

    .user-list::-webkit-scrollbar-thumb:hover,
    .messages-container::-webkit-scrollbar-thumb:hover {
        background: #a0a6ad;
    }

/* RESPONSIVE */
@media (max-width: 768px) {
    .chat-sidebar {
        width: 280px;
        min-width: 280px;
    }

    .message-bubble {
        max-width: 85%;
    }

    .input-wrapper {
        padding: 4px 4px 4px 16px;
    }

    .send-button {
        padding: 8px 18px;
        min-width: 70px;
        font-size: 14px;
    }
}
