/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f5f5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Main Container */
.chat-container {
    display: flex;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: 35%;
    border-right: 1px solid #eaeaea;
    display: flex;
    flex-direction: column;
    background-color: #f9f9f9;
    transition: all 0.3s ease;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f0f0f0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.sidebar-actions {
    display: flex;
    gap: 15px;
}

.search-bar {
    position: relative;
    padding: 10px 15px;
}

.search-bar input {
    width: 100%;
    padding: 10px 15px 10px 35px;
    border: none;
    border-radius: 20px;
    background-color: #eaeaea;
    font-size: 14px;
}

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

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

.chat-item {
    display: flex;
    align-items: center;
    padding: 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
    position: relative;
}

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

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

.chat-item-info {
    margin-left: 15px;
    flex: 1;
}

.chat-item-info h3 {
    font-size: 16px;
    margin-bottom: 5px;
}

.chat-item-info p {
    font-size: 14px;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.unread-badge {
    background-color: #4CAF50;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    position: absolute;
    right: 15px;
    top: 15px;
}

.online-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #4CAF50;
    border-radius: 50%;
    border: 2px solid #f9f9f9;
    bottom: 12px;
    left: 45px;
}

/* Chat Area Styles */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #eaeaea;
    background-color: #f0f0f0;
}

.chat-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.user-info h3 {
    font-size: 16px;
}

.user-info p {
    font-size: 12px;
    color: #4CAF50;
}

.chat-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path fill="%23e5e5e5" fill-opacity="0.2" d="M30 30 L70 30 L70 70 L30 70 Z"/></svg>');
    background-size: 50px 50px;
}

.message {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.received {
    background-color: white;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message.sent {
    background-color: #DCF8C6;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

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

.message-img {
    max-width: 100%;
    border-radius: 10px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-img:hover {
    transform: scale(1.02);
}

.message-video {
    max-width: 100%;
    border-radius: 10px;
    margin-bottom: 5px;
    cursor: pointer;
}

.message-sender {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 12px;
    color: #555;
}

.message-input {
    display: flex;
    align-items: center;
    padding: 15px;
    background-color: #f0f0f0;
    gap: 10px;
}

.message-input input {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
}

.input-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    color: #555;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background-color: #e0e0e0;
}

.send-btn {
    background-color: #4CAF50;
    color: white;
}

.send-btn:hover {
    background-color: #45a049;
}

/* Call Screen Styles */
.call-screen, .video-call-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.call-screen.active, .video-call-screen.active {
    opacity: 1;
    pointer-events: all;
}

.call-background, .video-call-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0.3;
    z-index: -1;
}

.call-content, .video-call-content {
    text-align: center;
    color: white;
    z-index: 1;
}

.caller-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    border: 3px solid white;
}

.call-actions, .video-call-actions {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 40px;
}

.call-action-btn, .video-call-action-btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
    background-color: rgba(255,255,255,0.1);
    color: white;
}

.call-action-btn:hover, .video-call-action-btn:hover {
    background-color: rgba(255,255,255,0.2);
}

.decline-btn {
    background-color: #f44336;
}

.decline-btn:hover {
    background-color: #d32f2f;
}

.accept-btn {
    background-color: #4CAF50;
}

.accept-btn:hover {
    background-color: #388E3C;
}

.end-btn {
    background-color: #f44336;
}

.end-btn:hover {
    background-color: #d32f2f;
}

/* Video Call Specific Styles */
.video-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#remote-video {
    width: 100%;
    height: 100%;
    background-color: #000;
    object-fit: cover;
}

.local-video {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 160px;
    background-color: #333;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid white;
}

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

.video-call-info {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    text-align: left;
}

.video-call-info h3 {
    font-size: 18px;
    margin-bottom: 5px;
}

.video-call-info p {
    font-size: 14px;
    color: #ccc;
}

/* Modal Styles */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background-color: white;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #eaeaea;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-body {
    padding: 15px;
    max-height: 60vh;
    overflow-y: auto;
}

.contact-list {
    margin-top: 15px;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    border-radius: 5px;
}

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

.contact-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
}

.contact-item-info h4 {
    font-size: 15px;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 70px;
    right: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    width: 200px;
    overflow: hidden;
}

.dropdown-menu.active {
    opacity: 1;
    pointer-events: all;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
}

.dropdown-item i {
    margin-right: 10px;
    color: #555;
    width: 20px;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .sidebar:not(.active) {
        display: none;
    }
    
    .chat-area:not(.active) {
        display: none;
    }
    
    .mobile-back-btn {
        display: flex !important;
    }
}

.mobile-back-btn {
    display: none;
    margin-right: 10px;
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    animation: fadeIn 0.3s ease-out;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    align-self: flex-start;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #888;
    border-radius: 50%;
    margin: 0 2px;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Image modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.image-modal.active {
    opacity: 1;
    pointer-events: all;
}

.image-modal-content {
    max-width: 90%;
    max-height: 90%;
}

.image-modal-content img, .image-modal-content video {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 5px;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 30px;
    cursor: pointer;
}