* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
}

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

.app-container {
    display: flex;
    height: 100vh;
    background-color: #f0f2f5;
}

/* Sidebar Styles */
.sidebar {
    width: 350px;
    background-color: #111b21;
    border-right: 1px solid #2a3942;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    background-color: #202c33;
    border-bottom: 1px solid #2a3942;
}

.sidebar-header h2 {
    color: #e9edef;
    font-size: 20px;
    margin-bottom: 15px;
    font-weight: 400;
}

.search-box input {
    width: 100%;
    padding: 10px 12px;
    background-color: #2a3942;
    border: 1px solid #3b4a54;
    border-radius: 8px;
    color: #e9edef;
    font-size: 14px;
    outline: none;
    transition: background-color 0.2s;
}

.search-box input:focus {
    background-color: #3b4a54;
    border-color: #54656f;
}

.search-box input::placeholder {
    color: #8696a0;
}

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

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #2a3942;
}

.contact-item:hover {
    background-color: #2a3942;
}

.contact-item.active {
    background-color: #2a3942;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #d1d1d1;
    background-image: url('user.png');
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    flex-shrink: 0;
}

.avatar-placeholder {
    font-size: 18px;
    font-weight: 600;
    color: #667781;
}

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

.contact-name {
    color: #e9edef;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.contact-time {
    color: #8696a0;
    font-size: 12px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Chat Area Styles */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #efeae2;
}

.chat-header {
    background-color: #f0f2f5;
    padding: 16px 20px;
    border-bottom: 1px solid #e9edef;
    display: flex;
    align-items: center;
}

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

.contact-info .contact-avatar {
    width: 40px;
    height: 40px;
    margin-right: 12px;
}

.contact-details h3 {
    color: #111b21;
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 2px;
}

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

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23efeae2"/><path d="M0 0L100 100M100 0L0 100" stroke="%23e9edef" stroke-width="0.5" opacity="0.3"/></svg>');
}

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

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: #111b21;
}

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

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

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

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    padding: 8px 12px;
    border-radius: 7.5px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    max-width: 65%;
}

.message.sent .message-bubble {
    max-width: 65%;
    margin-left: auto;
}

.message-text {
    word-wrap: break-word;
}

.message-image {
    max-width: 10%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 8px;
    display: block;
}

.message.sent .message-bubble {
    background-color: #dcf8c6;
    color: #111b21;
}

.message.received .message-bubble {
    background-color: #ffffff;
    color: #111b21;
}

.message-info {
    display: flex;
    align-items: center;
    margin-top: 4px;
    font-size: 11px;
    color: #667781;
}

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

.message-time {
    margin-right: 4px;
}

.message-status {
    opacity: 0.7;
}

.message.sent .message-bubble .message-status.blue {
    color: #53bdeb;
    opacity: 1;
}

/* Date separator */
.date-separator {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.date-separator span {
    background-color: #e9edef;
    color: #667781;
    padding: 6px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Message Input */
.message-input {
    display: none;
    background-color: #f0f2f5;
    padding: 16px 20px;
    border-top: 1px solid #e9edef;
    align-items: center;
    gap: 12px;
}

.message-input.active {
    display: flex;
}

.message-input input {
    flex: 1;
    padding: 10px 12px;
    background-color: #ffffff;
    border: 1px solid #e9edef;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.message-input input:focus {
    border-color: #8696a0;
}

.message-input button {
    padding: 10px 16px;
    background-color: #008069;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.message-input button:hover:not(:disabled) {
    background-color: #00695c;
}

.message-input button:disabled {
    background-color: #e9edef;
    color: #8696a0;
    cursor: not-allowed;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #667781;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9edef;
    border-top: 2px solid #008069;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    /* background: none; */
    border: none;
    font-size: 24px;
    color: #111b21;
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
}

.close-sidebar {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: #e9edef;
    border-radius: 4px;
    cursor: pointer;
    padding : 2px;
    margin-bottom: 4px;
}

.sidebar-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
    }
    
    .sidebar {
        /* position: static; */
        width: 100%;
        height: 100vh;
        z-index: 1;
        /* background: #f0f2f5; */
        border-right: none;
        border-bottom: none;
    }
    
    .sidebar-header {
        border-bottom: none;
    }
    
    .contact-item {
        border-bottom: none;
    }
    
    .sidebar.chat-hidden {
        display: none;
    }
    
    .chat-area {
        position: fixed;
        top: 0;
        left: 100%;
        width: 100%;
        height: 100vh;
        z-index: 1000;
        background: #efeae2;
        transition: left 0.3s ease;
        display: flex;
        flex-direction: column;
    }
    
    .chat-area.active {
        left: 0;
    }
    
    .chat-area:not(.active) {
        display: none;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .close-sidebar {
        display: none; /* Hide close button since sidebar is always visible */
    }
    
    .contact-info {
        display: flex;
        align-items: center;
    }
    
    .message-input {
        padding: 12px;
    }
    
    .message-input input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        border: none !important;
        box-shadow: none !important;
        outline: none !important;
    }
    
    .sidebar-header {
        border: none !important;
        box-shadow: none !important;
        outline: none !important;
    }
    
    .contact-item {
        border: none !important;
        box-shadow: none !important;
        outline: none !important;
    }
    
    .app-container {
        background-color: #111b21 !important;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .message-bubble {
        max-width: 80%;
    }
}
