* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f0f2f5;
    height: 100vh;
    overflow: hidden;
    color: #333;
}

.container {
    display: flex;
    height: 100vh;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Sidebar Styles */
.sidebar {
    width: 415px;
    background: white;
    border-right: 1px solid #e9edef;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px 20px;
    background: #0061a8e0;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.add-contact-btn {
    background: white;
    color: #0061a8e0;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
}

.add-contact-btn:hover {
    background: #f0f2f5;
    transform: rotate(90deg);
}

.sender-selector-container {
    padding: 15px 20px;
    background: #f0f2f5;
    border-bottom: 1px solid #e9edef;
}

.sender-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sender-selector label {
    font-weight: 500;
    font-size: 14px;
    color: #111b21;
}

.sender-selector select {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #7b7b7b;
    background: white;
    font-size: 14px;
    outline: none;
}

.sender-selector select:focus {
    border-color: #0061a8e0;
}

.search-container {
    padding: 10px 15px;
    background: white;
}

.search-box {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #e9edef;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    background: #f0f2f5;
    transition: all 0.3s ease;
}

.search-box:focus {
    background: white;
    border-color: #0061a8e0;
    box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.2);
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.contact-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f2f5;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.contact-item:hover {
    background: #f5f6f6;
}

.contact-item.active {
    background: #e7f3ff;
}

.contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #0061a8e0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 500;
    color: #111b21;
    font-size: 16px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

.contact-number {
    color: #667781;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.contact-item:hover .contact-actions {
    opacity: 1;
}

.edit-contact-btn, .delete-contact-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.edit-contact-btn {
    color: #0061a8e0;
}

.edit-contact-btn:hover {
    background: rgba(0, 168, 132, 0.1);
}

.delete-contact-btn {
    color: #dc3545;
}

.delete-contact-btn:hover {
    background: rgba(220, 53, 69, 0.1);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #efeae2;
}

.chat-header {
    padding: 15px 20px;
    background: #f0f2f5;
    border-bottom: 1px solid #e9edef;
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0061a8e0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
}

.chat-info h3 {
    color: #111b21;
    font-size: 16px;
    font-weight: 500;
}

.chat-info p {
    color: #667781;
    font-size: 13px;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-image: url("data:image/svg+xml,%3Csvg width='260' height='260' viewBox='0 0 260 260' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.02'%3E%3Cpath d='M24.37 16c.2.65.39 1.32.54 2H21.17l1.17-2h2.04zm-.24 4h-1.8l1.03-2h.77c0 .67-.04 1.34-.1 2zm.9-2h2.95l.9-2h-3.85v2zm0-4v2h-4.25l.5-2h3.75zm-2.48 6h-2.83c-.38-.6-.78-1.15-1.2-1.68l.8-2.32h3.23c0 1.34.07 2.67.2 4zm.49-6h-3.8l-.5-2h4.3v2zm-5.9-2c.2-.65.39-1.32.54-2h4.16l-.5 2H16.1zm7.8 8h-5.61c-.72-.92-1.5-1.8-2.33-2.63l.8-2.37H21.5c-.17 1-.34 2-.9 3z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-end;
}

.message.sent {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.message.sent .message-content {
    background: #d9fdd3;
    border-bottom-right-radius: 2px;
}

.message.received .message-content {
    background: white;
    border-bottom-left-radius: 2px;
}

.message-status {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 4px;
    font-size: 11px;
    color: #667781;
}

.message.received .message-status {
    justify-content: flex-start;
}

.message-time {
    font-size: 11px;
    color: #667781;
}

.message.received .message-time {
    text-align: left;
}

.message-input-container {
    padding: 15px 20px;
    background: #f0f2f5;
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-input {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    background: white;
    resize: none;
    max-height: 120px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-input:focus {
    box-shadow: inset 0 0 0 2px #0061a8e0, 0 1px 2px rgba(0, 0, 0, 0.1);
}

.send-btn {
    background: #00a884;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
}

.send-btn:hover {
    background: #008069;
    transform: scale(1.05);
}

.send-btn:disabled {
    background: #8696a0;
    cursor: not-allowed;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #667781;
    text-align: center;
    padding: 20px;
}

.welcome-screen i {
    font-size: 120px;
    margin-bottom: 30px;
    color: #d9d9d9;
}

.welcome-screen h2 {
    font-size: 32px;
    margin-bottom: 15px;
    color: #41525d;
}

.welcome-screen p {
    font-size: 18px;
    max-width: 500px;
    line-height: 1.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    margin-bottom: 20px;
    position: relative;
}

.modal-header h3 {
    color: #111b21;
    font-size: 20px;
    font-weight: 600;
}

.close-modal {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #667781;
    transition: color 0.2s ease;
}

.close-modal:hover {
    color: #0061a8e0;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #111b21;
}

.form-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e9edef;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.form-input:focus {
    border-color: #0061a8e0;
    box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.2);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #0061a8e0;
    color: white;
}

.btn-primary:hover {
    background: #0061a8e0;
}

.btn-secondary {
    background: #f0f2f5;
    color: #667781;
}

.btn-secondary:hover {
    background: #e9edef;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideInRight 0.3s ease;
}

.notification.success {
    background: #0061a8e0;
}

.notification.error {
    background: #dc3545;
}

.notification.info {
    background: #0084c7;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Loading state for send button */
.send-btn .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Unread badge styles */
.unread-badge {
    background-color: #00a884;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
}

.contact-item.unread {
    background-color: #f0f9ff;
    border-left: 3px solid #00a884;
}

.contact-item.unread .contact-name {
    font-weight: 600;
}

.error-message {
    color: #dc3545;
    font-size: 13px;
    margin-top: 5px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 50vh;
    }
    
    .chat-area {
        height: 50vh;
    }
}

.date-separator {
    text-align: center;
    margin: 15px 0;
    position: relative;
    color: #666;
    font-size: 12px;
}

.date-separator::before,
.date-separator::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background-color: #ddd;
}

.date-separator::before {
    left: 0;
}

.date-separator::after {
    right: 0;
}
.date-separator {
    text-align: center;
}

.contact-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;  /* Ensure text doesn't overflow */
}

.contact-last-message {
    color: #667781;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}


/* Add these new styles */
.contact-name {
    display: flex;
    align-items: center;
    gap: 6px;
}

.contact-count {
    color: #0061a8e0;
    font-weight: 600;
    font-size: 14px;
}

/* Adjust existing styles */
.contact-name {
    font-weight: 500;
    color: #111b21;
    font-size: 16px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
}

.contact-last-message {
    color: #667781;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}

.unread-badge {
    background-color: #00a884;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    margin-left: auto; /* Push to the right */
}