/* style.css */
:root {
    --bg-color: #0b141a; /* خلفية داكنة جداً */
    --header-bg: #1f2c34;
    --msg-in: #1f2c34;
    --msg-out: #005c4b; /* لون واتساب الداكن أو أزرق Sata */
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --accent: #00a884;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-primary); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

/* Login Screen */
#login-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color); z-index: 1000;
    display: flex; justify-content: center; align-items: center; flex-direction: column;
}
.login-box input {
    padding: 15px; border-radius: 30px; border: none; background: var(--header-bg);
    color: white; text-align: center; font-size: 18px; outline: none; width: 250px;
    border: 2px solid var(--accent);
}

/* Chat Header */
header {
    background: var(--header-bg); padding: 10px 15px;
    display: flex; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.avatar { width: 40px; height: 40px; background: #555; border-radius: 50%; margin-right: 10px; }
.user-info h4 { font-size: 16px; }
.user-info p { font-size: 12px; color: var(--text-secondary); }
.status-dot { width: 10px; height: 10px; background: lime; border-radius: 50%; display: inline-block; margin-left: 5px; opacity: 0; transition: 0.3s; }
.status-dot.online { opacity: 1; }

/* Chat Area */
#chat-container {
    flex: 1; overflow-y: auto; padding: 20px;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png'); /* خلفية واتساب داكنة */
    background-opacity: 0.1;
}

.message {
    max-width: 75%; margin-bottom: 10px; padding: 8px 12px; border-radius: 10px;
    font-size: 14px; position: relative; word-wrap: break-word; clear: both;
}
.message.sent { background: var(--msg-out); float: right; border-radius: 10px 0 10px 10px; }
.message.received { background: var(--msg-in); float: left; border-radius: 0 10px 10px 10px; }
.message img { max-width: 100%; border-radius: 8px; margin-top: 5px; cursor: pointer; }
.meta { font-size: 10px; color: rgba(255,255,255,0.6); text-align: right; margin-top: 4px; }

/* Input Area */
.input-area {
    background: var(--header-bg); padding: 10px; display: flex; align-items: center;
    gap: 10px;
}
.input-area input {
    flex: 1; padding: 12px; border-radius: 20px; border: none;
    background: #2a3942; color: white; outline: none;
}
.btn-icon {
    background: none; border: none; color: var(--text-secondary);
    font-size: 20px; cursor: pointer; padding: 5px;
}
.btn-icon:hover { color: var(--text-primary); }

/* Lightbox */
#lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 2000; display: none;
    justify-content: center; align-items: center; flex-direction: column;
}
#lightbox img { max-width: 90%; max-height: 80%; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
.dl-btn {
    margin-top: 20px; padding: 10px 20px; background: var(--accent);
    color: white; text-decoration: none; border-radius: 5px;
}

/* --- Media Sidebar (المعرض الجانبي) --- */
.media-sidebar {
    position: fixed; top: 0; right: -100%; /* مخفية خارج الشاشة */
    width: 100%; max-width: 400px; height: 100%;
    background: #0b141a; z-index: 1500;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
    display: flex; flex-direction: column;
}
.media-sidebar.active { right: 0; }

.sidebar-header {
    padding: 15px; background: #1f2c34;
    display: flex; align-items: center; gap: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-title { font-weight: bold; font-size: 16px; color: #e9edef; }
.close-sidebar { cursor: pointer; color: #8696a0; font-size: 20px; padding: 5px; }

.media-grid {
    flex: 1; overflow-y: auto; padding: 5px;
    display: grid; grid-template-columns: repeat(3, 1fr); /* 3 صور في الصف */
    gap: 5px; align-content: start;
}

.media-item {
    position: relative; aspect-ratio: 1/1; /* مربع تماماً */
    overflow: hidden; cursor: pointer; background: #1f2c34;
}
.media-item img {
    width: 100%; height: 100%; object-fit: cover; /* تغطية المربع بالكامل */
    transition: transform 0.2s;
}
.media-item:hover img { transform: scale(1.05); }

/* --- Lightbox Navigation (أسهم التنقل) --- */
.lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1); color: white;
    padding: 15px; cursor: pointer; border-radius: 50%;
    font-size: 24px; transition: 0.2s; user-select: none;
}
.lb-nav:hover { background: rgba(255, 255, 255, 0.3); }
.lb-prev { left: 20px; }
.lb-next { right: 20px; }