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

body {
    font-family: "Segoe UI", Helvetica Neue, Helvetica, Lucida Grande, Arial, Ubuntu, Cantarell, Fira Sans, sans-serif;
    background-color: #111b21;
    color: #e9edef;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    max-width: 100%;
}

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

.sidebar-header {
    background-color: #202c33;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.username {
    font-size: 16px;
    font-weight: 400;
}

.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.header-icons {
    display: flex;
    gap: 20px;
}

.icon-btn {
    background: none;
    border: none;
    color: #aebac1;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: #e9edef;
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

/* Search Bar */
.search-container {
    padding: 7px 12px;
    background-color: #111b21;
}

.search-wrapper {
    background-color: #202c33;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 10px;
}

.search-icon {
    color: #8696a0;
    flex-shrink: 0;
}

.search-input {
    background: none;
    border: none;
    outline: none;
    color: #e9edef;
    font-size: 14px;
    width: 100%;
}

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

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    background-color: #111b21;
    border-bottom: 1px solid #2a3942;
}

.filter-tab {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 20px;
    transition: background-color 0.2s;
}

.filter-tab:hover {
    background-color: #202c33;
}

.filter-tab.active {
    background-color: #0b5845;
    color: #e9edef;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    background-color: #111b21;
}

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

.chat-list::-webkit-scrollbar-thumb {
    background-color: #3d4a52;
    border-radius: 3px;
}

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

.chat-item:hover {
    background-color: #202c33;
}

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

.chat-item-avatar {
    position: relative;
}

.chat-item .profile-pic {
    width: 50px;
    height: 50px;
}

.unread-badge {
    background-color: #00a884;
    color: #111b21;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    position: absolute;
    top: -5px;
    right: -5px;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-item-name {
    font-size: 16px;
    font-weight: 400;
    color: #e9edef;
}

.chat-item-time {
    font-size: 12px;
    color: #8696a0;
}

.chat-item-message {
    font-size: 14px;
    color: #8696a0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 5px;
}

.read-status {
    color: #53bdeb;
    flex-shrink: 0;
}

.read-status svg {
    width: 16px;
    height: 16px;
}

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

.chat-header {
    background-color: #202c33;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    border-left: 1px solid #2a3942;
}

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

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

.contact-name {
    font-size: 16px;
    font-weight: 400;
    color: #e9edef;
    margin-bottom: 2px;
}

.contact-status {
    font-size: 13px;
    color: #8696a0;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 60px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect fill="%230b141a" width="100" height="100"/><path d="M0 0L50 50L0 100" stroke="%23182229" stroke-width="0.5" fill="none"/><path d="M50 0L100 50L50 100" stroke="%23182229" stroke-width="0.5" fill="none"/></svg>');
    background-repeat: repeat;
}

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

.messages-area::-webkit-scrollbar-thumb {
    background-color: #3d4a52;
    border-radius: 3px;
}

.no-chat-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.welcome-message {
    text-align: center;
    color: #8696a0;
}

.welcome-message h1 {
    font-size: 32px;
    margin-bottom: 16px;
    color: #e9edef;
}

.welcome-message p {
    font-size: 14px;
}

.messages-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

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

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

.message-bubble {
    max-width: 65%;
    padding: 6px 10px 8px 10px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background-color: #005c4b;
    color: #e9edef;
}

.message.received .message-bubble {
    background-color: #202c33;
    color: #e9edef;
}

.message-text {
    font-size: 14px;
    line-height: 19px;
    margin-bottom: 4px;
    white-space: pre-wrap;
}

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

.message-time {
    font-size: 11px;
    color: #8696a0;
}

.message.sent .message-time {
    color: #99beb4;
}

.message-status {
    display: flex;
    align-items: center;
}

.message-status svg {
    width: 16px;
    height: 16px;
    color: #53bdeb;
}

.date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
}

.date-divider-content {
    background-color: #182229;
    color: #8696a0;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
}

/* Message Input */
.message-input-container {
    background-color: #202c33;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-input-wrapper {
    flex: 1;
    background-color: #2a3942;
    border-radius: 8px;
    padding: 10px 16px;
}

.message-input {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    color: #e9edef;
    font-size: 15px;
}

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

/* Toast Notification Styles */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    min-width: 300px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.toast.hiding {
    animation: slideOut 0.3s ease-out forwards;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.toast.success::before {
    background: #25D366;
}

.toast.error::before {
    background: #DC3545;
}

.toast.info::before {
    background: #128C7E;
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.toast.success .toast-icon {
    background: #25D366;
    color: white;
}

.toast.error .toast-icon {
    background: #DC3545;
    color: white;
}

.toast.info .toast-icon {
    background: #128C7E;
    color: white;
}

.toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    color: #111b21;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: #667781;
    line-height: 1.4;
}

.toast-close {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #667781;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    background: #f0f2f5;
    color: #111b21;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Responsive toast on mobile */
@media (max-width: 768px) {
    .toast-container {
        left: 10px;
        right: 10px;
        top: 10px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 350px;
    }

    .messages-area {
        padding: 20px 40px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
    }

    .main-chat {
        display: none;
    }

    .sidebar.chat-open {
        display: none;
    }

    .main-chat.chat-open {
        display: flex;
    }
}

/* Emoji Dropdown Styles */
.message-input-container {
    position: relative;
}

.emoji-dropdown {
    display: none;
    position: absolute;
    bottom: 60px;
    /* above input bar */
    left: 8px;
    /* will be adjusted in JS for button offset if needed */
    z-index: 900;
}

.emoji-dropdown.active {
    display: block;
}

.emoji-dropdown-content {
    background-color: #202c33;
    border: 1px solid #2a3942;
    border-radius: 8px;
    width: 360px;
    max-height: 320px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    padding: 12px;
    overflow-y: auto;
    max-height: 300px;
}

.emoji-grid::-webkit-scrollbar {
    width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: #111b21;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: #374248;
    border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb:hover {
    background: #495f6a;
}

.emoji-item {
    font-size: 28px;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    text-align: center;
    user-select: none;
}

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

.emoji-item:active {
    background-color: #374248;
}

/* Utility: hidden */
.hidden {
    display: none !important;
}