@font-face {
        font-family: 'MyCustomFont';
        src: url('fonts/YekanBakh-Bold.ttf') format('truetype');
        font-weight: normal;
        font-style: normal;
    }
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'MyCustomFont', sans-serif;
}

body {
    background: #f0f2f5;
    direction: rtl;
    overflow: hidden;
    transition: background 0.3s;
}

body.dark {
    background: #1a1a1a;
    color: #fff;
}

/* Authentication Pages */
.auth-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #ff9a9e, #fad0c4);
}

.auth-container {
    background: #fff;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.5s ease-in;
}

.auth-container h2 {
    margin-bottom: 20px;
    color: #333;
}

.auth-container input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.auth-container button {
    width: 100%;
    padding: 12px;
    background: #0084ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-container button:hover {
    background: #0073e6;
}

.auth-container p {
    margin-top: 15px;
}

.auth-container a {
    color: #0084ff;
    text-decoration: none;
}

/* Chat Layout */
.container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    width: 300px;
    background: #fff;
    padding: 20px;
    border-left: 1px solid #ddd;
    overflow-y: auto;
    transition: transform 0.3s ease;
    position: fixed;
    top: 0;
    right: -300px;
    height: 100%;
    z-index: 10;
}

.sidebar.open {
    right: 0;
}

body.dark .sidebar {
    background: #2c2c2c;
    border-left: 1px solid #444;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.sidebar h2 {
    font-size: 18px;
    color: #333;
}

body.dark .sidebar h2 {
    color: #fff;
}

.close-sidebar-btn {
    background: #ff4444;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.close-sidebar-btn:hover {
    transform: scale(1.1);
}

#chat-list {
    list-style: none;
}

#chat-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: #f9f9f9;
    margin-bottom: 5px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

body.dark #chat-list li {
    background: #3c3c3c;
}

#chat-list li:hover {
    background: #e0e0e0;
}

body.dark #chat-list li:hover {
    background: #4c4c4c;
}

#chat-list li button {
    background: #ff4444;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
}

.chat-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 5;
}

body.dark .chat-header {
    background: #2c2c2c;
    border-bottom: 1px solid #444;
}

.menu-btn {
    padding: 10px;
    background: #0084ff;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.menu-btn:hover {
    transform: scale(1.1);
}

.profile-section {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-left: 10px;
}

.new-chat-btn, .theme-toggle {
    padding: 8px 15px;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
}

.theme-toggle {
    background: #ff9800;
}

.new-chat-btn:hover, .theme-toggle:hover {
    transform: scale(1.05);
    background: #45a049;
}

.theme-toggle:hover {
    background: #e68900;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fff;
    margin-top: 80px; /* Increased to avoid overlap with header */
    margin-bottom: 80px; /* Increased to avoid overlap with input */
}

body.dark .chat-messages {
    background: #1a1a1a;
}

.message {
    margin-bottom: 15px;
    padding: 12px 18px;
    border-radius: 15px;
    max-width: 70%;
    animation: slideIn 0.3s ease-in;
}

.user-message {
    background: #0084ff;
    color: #fff;
    margin-left: auto;
    text-align: right;
}

body.dark .user-message {
    background: #0066cc;
}

.elsa-message {
    background: #e9ecef;
    margin-right: auto;
    text-align: left;
}

body.dark .elsa-message {
    background: #3c3c3c;
}

.image-message {
    padding: 10px;
    background: #e9ecef;
    border-radius: 15px;
    cursor: pointer;
    transition: transform 0.2s;
}

body.dark .image-message {
    background: #3c3c3c;
}

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

.image-message img {
    max-width: 100%;
    border-radius: 10px;
}

.chat-input {
    display: flex;
    padding: 15px;
    background: #fff;
    border-top: 1px solid #ddd;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 5;
}

body.dark .chat-input {
    background: #2c2c2c;
    border-top: 1px solid #444;
}

.emoji-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease, border 0.3s ease;
    background-color: #ff9800;
}

.emoji-container.selected {
    background: #e68900;
    border: 2px solid #4CAF50;
    animation: jelly 0.6s ease;
}

.emoji {
    font-size: 24px;
    pointer-events: none;
}

@keyframes jelly {
    from { transform: scale(1, 1); }
    30% { transform: scale(1.25, 0.75); }
    40% { transform: scale(0.75, 1.25); }
    50% { transform: scale(1.15, 0.85); }
    65% { transform: scale(0.95, 1.05); }
    75% { transform: scale(1.05, 0.95); }
    to { transform: scale(1, 1); }
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 25px;
    margin: 0 10px;
    resize: none;
    font-size: 16px;
}

body.dark #message-input {
    border: 1px solid #444;
    background: #3c3c3c;
    color: #fff;
}

.send-btn {
    padding: 10px 20px;
    background: #0084ff;
    color: #fff;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
}

.send-btn:hover {
    transform: scale(1.05);
    background: #0073e6;
}

.profile-popup, .image-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
}

.popup-content, .image-popup-content {
    background: #fff;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    max-width: 90%;
    position: relative;
    animation: slideIn 0.3s ease-in;
}

body.dark .popup-content, body.dark .image-popup-content {
    background: #2c2c2c;
}

.popup-pic {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 15px;
}

.close-btn {
    background: #ff4444;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    position: absolute;
    top: 10px;
    right: 10px;
}

.close-btn:hover {
    transform: scale(1.1);
}

#popup-image {
    max-width: 100%;
    border-radius: 10px;
}

.download-btn {
    margin-top: 15px;
    padding: 10px 20px;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s;
}

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

#delete-notice {
    margin-top: 10px;
    color: #ff4444;
    font-size: 14px;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 70%;
        right: -70%;
    }
    .sidebar.open {
        right: 0;
    }
    .chat-messages {
        margin-top: 70px;
        margin-bottom: 70px;
    }
    .profile-pic {
        width: 35px;
        height: 35px;
    }
    .new-chat-btn, .theme-toggle {
        padding: 6px 12px;
        font-size: 14px;
    }
    .chat-input {
        padding: 10px;
    }
    .emoji-container {
        width: 35px;
        height: 35px;
    }
    .emoji {
        font-size: 20px;
    }
    .send-btn {
        padding: 8px 15px;
        font-size: 14px;
    }
}

@media (min-width: 769px) {
    .sidebar {
        position: static;
        width: 300px;
        right: 0;
    }
    .menu-btn, .close-sidebar-btn {
        display: none;
    }
    .chat-container {
        width: calc(100% - 300px);
    }
}