:root {
    --sidebar-width: 280px;
    --header-height: 60px;
    --footer-height: 60px;
}

body {
    overflow: hidden;
    height: 100vh;
    font-family: Arial, sans-serif;
}

.chat-wrapper {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
}

.sidebar-header {
    height: var(--header-height);
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    padding: 0 15px;
    font-weight: bold;
    justify-content: space-between;
}

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

.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}

.status-indicator.online {
    background-color: #44b700;
    box-shadow: 0 0 0 2px #44b70040;
    animation: pulse 2s infinite;
}

.status-indicator.away {
    background-color: #ff9800;
}

.status-indicator.busy {
    background-color: #f44336;
}

.status-indicator.offline {
    background-color: #757575;
}

@keyframes pulse {
    0% { opacity: 0.7; box-shadow: 0 0 0 0 rgba(68, 183, 0, 0.4); }
    70% { opacity: 1; box-shadow: 0 0 0 5px rgba(68, 183, 0, 0); }
    100% { opacity: 0.7; }
}

.tab-nav {
    display: flex;
    border-bottom: 1px solid #ddd;
}

.tab-nav button {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.tab-nav button.active {
    border-bottom-color: #0d6efd;
    font-weight: bold;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
}

.search-bar {
    padding: 10px;
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 10;
}

.search-bar input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
}

.contacts-list, .conversations-list {
    display: none;
}

.contacts-list.active, .conversations-list.active {
    display: block;
}

.contact-item, .conversation-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.contact-item:hover, .conversation-item:hover {
    background-color: #e9ecef;
}

.contact-item.active, .conversation-item.active {
    background-color: #e7f1ff;
}

.contact-avatar, .conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #6c757d;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 10px;
}

.contact-info, .conversation-info {
    flex: 1;
    overflow: hidden;
}

.contact-name, .conversation-name {
    font-weight: bold;
    margin-bottom: 2px;
}

.contact-status, .conversation-preview {
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    font-size: 0.7rem;
    color: #6c757d;
    white-space: nowrap;
}

.unread-badge {
    background-color: #0d6efd;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    margin-left: 5px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    height: var(--header-height);
    border-bottom: 1px solid #ddd;
    padding: 0 15px;
    display: flex;
    align-items: center;
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8f9fa;
}

.messages {
    display: flex;
    flex-direction: column;
}

.message {
    margin-bottom: 10px;
    max-width: 80%;
    position: relative;
}

.message-incoming {
    align-self: flex-start;
}

.message-outgoing {
    align-self: flex-end;
}

.message-content {
    padding: 8px 12px;
    border-radius: 12px;
    position: relative;
}

.message-incoming .message-content {
    background-color: #e9ecef;
    border-bottom-left-radius: 2px;
}

.message-outgoing .message-content {
    background-color: #d1e7ff;
    border-bottom-right-radius: 2px;
}

.message-sender {
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

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

.message-time {
    font-size: 0.7rem;
    color: #6c757d;
    text-align: right;
    margin-top: 2px;
}

.typing-indicator {
    color: #6c757d;
    font-style: italic;
    padding: 5px 10px;
    margin-top: 5px;
    font-size: 0.8rem;
    background-color: #e9ecef;
    border-radius: 12px;
    display: inline-block;
    align-self: flex-start;
    animation: pulse 1.5s infinite;
}

.typing-indicator.hidden {
    display: none;
}

.chat-footer {
    height: var(--footer-height);
    border-top: 1px solid #ddd;
    padding: 10px 15px;
    display: flex;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    margin-right: 10px;
}

.send-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 20px;
    background-color: #0d6efd;
    color: white;
    cursor: pointer;
}

.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
    padding: 0 20px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #ddd;
    margin-top: auto;
}

#signout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
}

/* Mobile responsive styles */
/* Notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.notification {
    padding: 12px 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    color: white;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.error {
    background-color: #f44336;
}

.notification.success {
    background-color: #4caf50;
}

.notification.info {
    background-color: #2196f3;
}

/* Read status */
.message-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 2px;
}

.read-status {
    margin-left: 5px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    color: #6c757d;
}

.read-status.read {
    opacity: 1;
    color: #0d6efd;
    cursor: help;
}

/* Call container */
.call-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.call-container.hidden {
    display: none;
}

.call-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
}

.call-actions {
    display: flex;
    gap: 10px;
}

.video-container {
    flex: 1;
    position: relative;
}

.remote-video {
    width: 100%;
    height: 100%;
    position: relative;
}

.remote-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.local-video {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 150px;
    height: 100px;
    border: 2px solid white;
    border-radius: 8px;
    overflow: hidden;
}

.local-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Call controls in chat header */
.call-controls {
    display: flex;
}

/* When in a call */
.in-call #audio-call-btn,
.in-call #video-call-btn {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .chat-header {
        padding-left: 50px;
    }
    
    .mobile-toggle {
        position: absolute;
        left: 10px;
        top: 15px;
        z-index: 101;
        background: none;
        border: none;
        font-size: 20px;
    }
    
    /* Hide mobile-toggle when sidebar is open */
    .sidebar.show ~ .main-content .mobile-toggle {
        display: none;
    }
}
