* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    background: #075e54;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.header-left h1 {
    font-size: 20px;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-size: 14px;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 60px);
}

/* Conversations Panel */
.conversations-panel {
    width: 350px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.conversations-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.conversations-header h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.search-box input {
    width: 100%;
    padding: 10px 10px 10px 40px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    gap: 12px;
}

.conversation-item:hover {
    background: #f5f5f5;
}

.conversation-item.active {
    background: #e8f5e9;
}

.conversation-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #075e54;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.conversation-details {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.conversation-name {
    font-weight: 600;
    font-size: 15px;
}

.conversation-time {
    font-size: 12px;
    color: #999;
}

.conversation-last-message {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-badge {
    background: #25d366;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
}

/* Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #e5ddd5;
}

.chat-header {
    background: #f0f0f0;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
}

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

.contact-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #075e54;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.contact-details h4 {
    font-size: 16px;
    margin-bottom: 2px;
}

.contact-details p {
    font-size: 13px;
    color: #666;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect fill="%23e5ddd5" width="100" height="100"/></svg>');
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
}

.empty-state i {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.message {
    margin-bottom: 10px;
    display: flex;
}

.message.sent {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
}

.message.received .message-bubble {
    background: white;
    border-radius: 0 8px 8px 8px;
}

.message.sent .message-bubble {
    background: #dcf8c6;
    border-radius: 8px 0 8px 8px;
}

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

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

.message-media {
    max-width: 100%;
    border-radius: 5px;
    margin-bottom: 5px;
}

.message-media img,
.message-media video {
    max-width: 100%;
    border-radius: 5px;
}

/* Chat Input */
.chat-input {
    background: #f0f0f0;
    padding: 10px 15px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.btn-attachment {
    background: none;
    border: none;
    color: #54656f;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

.btn-attachment:hover {
    color: #075e54;
}

#messageInput {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}

.btn-send {
    background: #075e54;
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.3s;
}

.btn-send:hover {
    background: #128c7e;
}

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: #999;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .conversations-panel {
        width: 100%;
        position: absolute;
        left: 0;
        top: 60px;
        height: calc(100vh - 60px);
        z-index: 10;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .conversations-panel.active {
        transform: translateX(0);
    }

    .chat-panel {
        width: 100%;
    }
}


/* Floating Contacts Button */
.floating-contacts-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #075e54;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 100;
    transition: transform 0.2s, background 0.2s;
}

.floating-contacts-btn:hover {
    background: #128c7e;
    transform: scale(1.1);
}

/* Contacts Panel */
.contacts-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
}

.contacts-panel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.contacts-panel-content {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 350px;
    max-width: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.contacts-panel-header {
    padding: 20px;
    background: #075e54;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contacts-panel-header h2 {
    font-size: 18px;
    font-weight: 500;
}

.close-panel-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.close-panel-btn:hover {
    opacity: 1;
}

.contacts-panel-search {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.contacts-panel-search i {
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.contacts-panel-search input {
    width: 100%;
    padding: 10px 10px 10px 35px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
}

.contacts-panel-search input:focus {
    outline: none;
    border-color: #075e54;
}

.contacts-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.contact-item:hover {
    background: #f5f5f5;
}

.contact-item .contact-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #075e54;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.contact-item .contact-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-item .contact-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
}

.contact-item .contact-phone {
    font-size: 13px;
    color: #666;
}

.no-contacts {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.contacts-loading {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* Responsive */
@media (max-width: 480px) {
    .contacts-panel-content {
        width: 100%;
    }
}
