:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --accent: #4895ef;
    --light: #f8f9fa;
    --dark: #212529;
    --success: #4cc9f0;
    --text: #2b2d42;
    --online: #4ade80;
    --offline: #94a3b8;
    --sent: #4361ee;
    --received: #f1f5f9;
    --chat-bg: #f0f4f8;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --element-shadow: 0 3px 10px rgba(67, 97, 238, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

/* Authentication Styles */
.auth-container {
    width: 100%;
    max-width: 500px;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    margin: 0 auto;
    transition: transform 0.3s ease;
}

.auth-container:active {
    transform: scale(0.98);
}

.auth-header {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    text-align: center;
    padding: 35px 20px;
    position: relative;
    overflow: hidden;
}

.auth-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 70%);
    transform: rotate(30deg);
}

.auth-header h1 {
    font-size: 2.1rem;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.auth-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.auth-form {
    padding: 35px 25px;
}

.input-group {
    position: relative;
    margin-bottom: 25px;
}

.input-group i {
    position: absolute;
    top: 16px;
    right: 20px;
    color: var(--accent);
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.input-group input {
    width: 100%;
    padding: 16px 60px 16px 20px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.15);
    outline: none;
    background: white;
}

.input-group input:focus + i {
    transform: scale(1.2);
}

.btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--element-shadow);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.auth-footer {
    text-align: center;
    padding: 20px;
    color: var(--text);
    font-size: 1.05rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

.auth-footer a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--secondary);
    transition: width 0.3s ease;
}

.auth-footer a:hover {
    color: var(--secondary);
}

.auth-footer a:hover::after {
    width: 100%;
}

.error-message {
    background: #fee2e2;
    color: #ef4444;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: shake 0.5s ease;
}

.success-message {
    background: #dcfce7;
    color: #22c55e;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.5s ease;
}

.password-toggle {
    position: absolute;
    top: 16px;
    left: 20px;
    color: var(--accent);
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.password-toggle:hover {
    transform: scale(1.2);
}

/* Chat Styles */
.chat-container {
    display: flex;
    height: 95vh;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    box-shadow: var(--card-shadow);
    background: white;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.sidebar {
    width: 380px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
}

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

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.3rem;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.user-avatar:hover {
    transform: scale(1.05);
}

.user-info h3 {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.user-info p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
}

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

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.search-container {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 12px 50px 12px 20px;
    border-radius: 25px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
    background: white;
}

.search-box i {
    position: absolute;
    top: 14px;
    left: 20px;
    color: var(--accent);
    transition: transform 0.3s ease;
}

.search-box input:focus + i {
    transform: scale(1.2);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    background: #f8fafc;
}

.chat-item {
    display: flex;
    gap: 15px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
    overflow: hidden;
}

.chat-item:hover {
    background: #f8fafc;
    transform: translateY(-2px);
}

.chat-item:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
}

.chat-avatar {
    position: relative;
    flex-shrink: 0;
}

.avatar-img {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.3rem;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.chat-item:hover .avatar-img {
    transform: scale(1.05);
}

.status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-online {
    background: var(--online);
    animation: pulse 1.5s infinite;
}

.status-offline {
    background: var(--offline);
}

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

.chat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.chat-header h4 {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.chat-time {
    color: #94a3b8;
    font-size: 0.85rem;
}

.chat-preview {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-preview p {
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}

.unread-count {
    background: var(--primary);
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
    animation: bounce 1s ease;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23f1f5f9" opacity="0.1"/><path d="M20 20 L50 50 L20 80" stroke="%23e2e8f0" stroke-width="2" fill="none"/></svg>');
    background-size: 400px;
}

.chat-area-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

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

.chat-area-info h3 {
    font-size: 1.3rem;
    margin-bottom: 5px;
    color: var(--text);
}

.chat-area-info p {
    color: var(--online);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.typing-indicator {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: typing 1.5s infinite;
}

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

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

.chat-messages {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    max-width: 70%;
    padding: 15px;
    border-radius: 18px;
    position: relative;
    animation: messageAppear 0.3s ease-out;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease;
}

.message:hover {
    transform: translateY(-2px);
}

.sent {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.received {
    background: white;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-content {
    font-size: 1.05rem;
    line-height: 1.5;
}

.message-time {
    font-size: 0.8rem;
    margin-top: 8px;
    text-align: right;
    opacity: 0.8;
}

.received .message-time {
    color: #64748b;
}

.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 15px;
}

.message-input {
    flex: 1;
    position: relative;
}

.message-input textarea {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border-radius: 25px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    resize: none;
    font-size: 1.05rem;
    max-height: 150px;
    transition: all 0.3s ease;
}

.message-input textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
    background: white;
}

.input-actions {
    position: absolute;
    top: 14px;
    left: 20px;
    display: flex;
    gap: 10px;
}

.input-action-btn {
    color: var(--accent);
    cursor: pointer;
    font-size: 1.3rem;
    transition: all 0.3s ease;
}

.input-action-btn:hover {
    color: var(--secondary);
    transform: scale(1.1);
}

.send-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: var(--element-shadow);
    position: relative;
    overflow: hidden;
}

.send-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 70%);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.send-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.4);
}

.send-btn:hover::after {
    opacity: 1;
}

.send-btn:active {
    transform: translateY(0);
}

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

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes typing {
    0% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        width: 320px;
    }
}

@media (max-width: 768px) {
    body {
        background: white;
        padding: 0;
    }
    
    .auth-container {
        border-radius: 0;
        margin: 0;
        height: 100vh;
        max-width: 100%;
        box-shadow: none;
    }
    
    .auth-header {
        padding: 30px 20px;
    }
    
    .auth-header h1 {
        font-size: 1.8rem;
    }
    
    .auth-header p {
        font-size: 1rem;
    }
    
    .auth-form {
        padding: 25px 20px;
    }
    
    .input-group input {
        padding: 14px 50px 14px 15px;
        font-size: 1rem;
    }
    
    .btn {
        padding: 14px;
        font-size: 1rem;
    }
    
    /* Chat adjustments */
    .chat-container {
        flex-direction: column;
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        height: 100%;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .overlay.active {
        display: block;
    }
    
    .mobile-menu-btn {
        display: block !important;
    }
    
    .chat-area {
        min-height: 100vh;
    }
    
    .sidebar-header {
        padding: 15px;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .user-info h3 {
        font-size: 1.1rem;
    }
    
    .avatar-img {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .chat-item {
        padding: 12px 15px;
    }
    
    .chat-area-header {
        padding: 15px;
    }
    
    .chat-messages {
        padding: 20px;
        gap: 15px;
    }
    
    .message {
        max-width: 85%;
        padding: 12px;
    }
    
    .message-content {
        font-size: 1rem;
    }
    
    .message-input-area {
        padding: 15px;
    }
    
    .send-btn {
        width: 45px;
        height: 45px;
    }
    
    /* Back to contacts button */
    .back-to-contacts {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-right: 15px;
        color: var(--primary);
        cursor: pointer;
        transition: color 0.3s ease;
    }
    
    .back-to-contacts:hover {
        color: var(--secondary);
    }
    
    /* No chat selected state */
    .no-chat-selected {
        padding: 20px;
    }
    
    .no-chat-selected i {
        font-size: 3.5rem;
    }
    
    .no-chat-selected p {
        font-size: 1rem;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .auth-container {
        margin: 0;
        border-radius: 0;
    }
    
    .auth-header {
        padding: 25px 15px;
    }
    
    .auth-header h1 {
        font-size: 1.5rem;
    }
    
    .input-group input {
        padding: 12px 45px 12px 12px;
        font-size: 0.95rem;
    }
    
    .message {
        max-width: 90%;
        padding: 10px;
    }
    
    .message-content {
        font-size: 0.95rem;
    }
    
    .message-input textarea {
        padding: 12px 45px 12px 12px;
        font-size: 1rem;
    }
    
    .input-actions {
        left: 10px;
    }
    
    .chat-area-header h3 {
        font-size: 1.1rem;
    }
}

/* New classes */
.back-to-contacts {
    display: none;
}

@media (max-width: 768px) {
    .back-to-contacts {
        display: flex;
    }
}

/* Loading state */
.loading-users {
    text-align: center;
    padding: 30px;
    color: #94a3b8;
}

.loading-users i {
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No chat selected state */
.no-chat-selected {
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #94a3b8;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.no-chat-selected i {
    font-size: 4rem;
    margin-bottom: 15px;
    color: #cbd5e1;
    opacity: 0.7;
}

.no-chat-selected p {
    font-size: 1.1rem;
    margin: 8px 0;
    color: #64748b;
}

/* Avatar placeholder */
.avatar-placeholder {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 1.5rem;
}

/* Swipe to close for mobile */
.sidebar {
    touch-action: pan-y;
}
/* أضف هذه التنسيقات في نهاية الملف */

.chat-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    margin-top: 5px;
    display: block;
}

.message.sent .chat-image {
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.message.received .chat-image {
    border: 2px solid rgba(0, 0, 0, 0.05);
}

.message .message-content img {
    max-width: 100%;
    border-radius: 10px;
}
/* إصلاح عرض الصور */
.chat-image {
    max-width: 100% !important;
    height: auto !important;
    max-height: 300px !important;
}

@media (max-width: 768px) {
    .chat-image {
        max-height: 200px !important;
    }
}
.shield-warning {
    background-color: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: 5px;
    margin: 10px 0;
    border-left: 4px solid #ffc107;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.5s ease;
}