/* --- 1. TEMA DEĞİŞKENLERİ VE TEMEL AYARLAR --- */
:root {
    --transition-speed: 0.3s;
}

/* Gece Teması (Amoled) - Varsayılan */
body[data-theme="night"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #1e1e1e;
    --bg-light: #2c323a;
    --bg-input: #1e1e1e;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --text-primary: #e6e6e6;
    --text-secondary: #b0b8c4; /* İkon rengini biraz daha belirgin yapalım */
    --text-muted: #777;
    --border-color: #333;
    --accent-color: #5865f2;
    --sent-bubble-bg: var(--accent-color);
    --received-bubble-bg: var(--bg-tertiary);
    --icon-color: var(--text-secondary); /* Değişkeni kullanalım */
    --header-bg: var(--bg-secondary);
    --scroll-thumb: var(--bg-light);
    --profile-bg: #18191c;
    --profile-header: #333;
}

/* Gündüz Teması (Messenger) - Kontrastı Artırıldı */
body[data-theme="day"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #f0f2f5; /* Ana sohbet arka planı */
    --bg-tertiary: #FFFFFF;
    --bg-light: #FFFFFF;
    --bg-input: #e4e6eb; /* Metin giriş alanı */
    --bg-overlay: rgba(0, 0, 0, 0.4);
    --text-primary: #050505;
    --text-secondary: #65676B;
    --text-muted: #888;
    --border-color: #ddd;
    --accent-color: #0084FF;
    --sent-bubble-bg: linear-gradient(135deg, #00B2FF, #006AFF);
    --received-bubble-bg: #e4e6eb; /* Gelen mesaj balonu (daha görünür) */
    --icon-color: var(--text-secondary); /* Değişkeni kullanalım */
    --header-bg: var(--bg-light);
    --scroll-thumb: #ced0d4;
    --profile-bg: #FFFFFF;
    --profile-header: #eee;
}

* { box-sizing: border-box; }
body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    overflow: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* --- 2. GENEL CHAT ARAYÜZÜ --- */
.chat-container {
    width: 100vw; height: 100vh; max-width: 500px; max-height: 100vh; margin: auto;
    background-color: var(--bg-secondary);
    display: flex; flex-direction: column; overflow: hidden;
    transition: background-color var(--transition-speed);
}
@media (min-width: 520px) { .chat-container { border-radius: 12px; height: 95vh; max-height: 800px; } }

.chat-header {
    background-color: var(--header-bg);
    padding: 15px 20px;
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}
.header-info { display: flex; align-items: center; gap: 12px; }
.header-info h2 { margin: 0; font-size: 1.2em; font-weight: 700; color: var(--text-primary); }
.header-info i { color: var(--icon-color); }

/* Header Butonlarının Dizilimi Düzeltildi */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px; /* Butonlar arasına boşluk ekle */
}

.action-btn, .send-btn {
    background: none; border: none;
    color: var(--icon-color);
    font-size: 1.2rem; cursor: pointer; padding: 8px; border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
    display: flex; align-items: center; justify-content: center;
    width: 40px;
    height: 40px;
}
.action-btn:hover { background-color: var(--bg-input); }
.send-btn { color: var(--accent-color); font-size: 1.4rem; }

/* Tema İkonunun Görünürlüğü ve Boyutu Düzeltildi */
#themeIcon {
    width: 22px;
    height: 22px;
    transition: transform 0.3s ease, filter 0.3s ease;
    filter: brightness(0.8) contrast(1.2); /* Varsayılan görünürlük */
}
/* Gece modunda ikonu açık gri yap */
body[data-theme="night"] #themeIcon {
    filter: brightness(0) invert(0.8) contrast(1.2);
    transform: rotate(180deg);
}
/* Gündüz modunda ikonu biraz koyulaştır (eğer beyazsa) */
body[data-theme="day"] #themeIcon {
     transform: rotate(0deg);
     filter: brightness(0.5) contrast(1);
}

.message-list-wrapper { position: relative; flex-grow: 1; overflow: hidden; display: flex; }
.message-list {
    width: 100%; padding: 20px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 15px;
}
.message-list::-webkit-scrollbar { width: 6px; }
.message-list::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }

.message { display: flex; align-items: flex-end; gap: 10px; max-width: 80%; animation: fadeIn 0.4s; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background-color: var(--bg-light); color: var(--text-primary); display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; cursor: pointer; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.message-content { padding: 12px 16px; border-radius: 18px; }
.username { font-weight: 700; margin-bottom: 5px; font-size: 0.9em; cursor: pointer; }
.message-content .text { line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.message-content .image-preview { max-width: 250px; max-height: 200px; border-radius: 12px; margin-top: 5px; cursor: pointer; transition: opacity 0.2s; }
.message-content .image-preview:hover { opacity: 0.8; }
.timestamp { font-size: 0.75em; color: var(--text-secondary); margin-top: 6px; text-align: right; }

.message.sent { align-self: flex-end; flex-direction: row-reverse; }
.message.sent .message-content { background: var(--sent-bubble-bg); color: white; border-bottom-right-radius: 4px; }
.message.sent .timestamp { color: rgba(255,255,255,0.7); }
.message.received .message-content { background: var(--received-bubble-bg); border-bottom-left-radius: 4px; }

.message-input-area {
    display: flex; padding: 15px; gap: 10px; align-items: center;
    background-color: var(--header-bg);
    flex-shrink: 0; position: relative;
    border-top: 1px solid var(--border-color);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}
#messageInput {
    flex-grow: 1; border: none;
    background-color: var(--bg-input);
    color: var(--text-primary);
    padding: 12px 18px; border-radius: 22px; outline: none; font-size: 1em;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- 3. DİĞER PANELLER (Overlay, UserList, Search, Lightbox) --- */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-overlay);
    z-index: 100; opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}
.overlay.active { opacity: 1; pointer-events: auto; }

.user-list-panel {
    position: fixed; top: 0; right: 0; width: 80%; max-width: 300px; height: 100%;
    background-color: var(--bg-light);
    z-index: 101; transform: translateX(100%);
    transition: transform 0.3s ease-in-out, background-color var(--transition-speed);
    padding: 20px; box-shadow: -5px 0 15px rgba(0,0,0,0.2);
}
.user-list-panel.active { transform: translateX(0); }
.user-list-panel h3 { margin-top: 0; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; color: var(--text-primary); }
.user-list-panel ul { list-style: none; padding: 0; margin: 0; height: calc(100% - 60px); overflow-y: auto; }
.user-list-panel li { display: flex; align-items: center; padding: 12px 0; gap: 15px; font-size: 1.1em; }
.user-list-panel .status { width: 10px; height: 10px; background-color: #2ecc71; border-radius: 50%; }

.search-view {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-secondary);
    z-index: 20; display: flex; flex-direction: column;
    transform: translateY(-100%); transition: transform 0.3s ease-in-out;
}
.search-view.active { transform: translateY(0); }
.search-header {
    display: flex; align-items: center; padding: 10px 15px;
    background-color: var(--bg-light);
    flex-shrink: 0; gap: 10px; border-bottom: 1px solid var(--border-color);
}
#searchInput {
    flex-grow: 1; border: none; background-color: var(--bg-input);
    color: var(--text-primary); padding: 10px 15px; border-radius: 20px;
    outline: none; font-size: 1em;
}
.search-results { flex-grow: 1; overflow-y: auto; padding: 15px; }
.search-result-item { display: flex; gap: 12px; padding: 12px; border-radius: 8px; cursor: pointer; transition: background-color 0.2s; }
.search-result-item:hover { background-color: var(--bg-light); }
.search-result-item .avatar { flex-shrink: 0; width: 35px; height: 35px; font-size: 0.9em; }
.search-result-content { overflow: hidden; }
.search-result-header { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.8em; color: var(--text-secondary); }
.search-result-header strong { font-size: 1.1em; }
.search-result-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); margin-top: 4px; }

.lightbox {
    position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease;
}
.lightbox.active { opacity: 1; visibility: visible; }
.lightbox-content { max-width: 90%; max-height: 80%; transform: scale(0.8); transition: transform 0.3s ease; }
.lightbox.active .lightbox-content { transform: scale(1); }
.lightbox-close { position: absolute; top: 20px; right: 35px; color: #f1f1f1; font-size: 40px; font-weight: bold; cursor: pointer; transition: color 0.2s; }
.lightbox-close:hover { color: #ccc; }

emoji-picker {
    position: absolute; bottom: 80px; left: 15px; z-index: 10;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateY(10px); opacity: 0; pointer-events: none;
}
emoji-picker.visible { transform: translateY(0); opacity: 1; pointer-events: auto; }

.scroll-to-bottom-btn {
    position: absolute; bottom: 15px; right: 15px; z-index: 5;
    background-color: var(--bg-light); color: var(--text-primary);
    border: 1px solid var(--border-color); width: 40px; height: 40px;
    border-radius: 50%; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); opacity: 0;
    transform: translateY(10px); transition: all 0.2s; pointer-events: none;
}
.scroll-to-bottom-btn:not(.hidden) { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* --- 4. YENİ: MİNİ PROFİL PANELİ STİLLERİ --- */
.profile-panel {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 340px;
    z-index: 102;
    background-color: var(--profile-bg);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s, background-color var(--transition-speed);
}
.profile-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}
.profile-header {
    height: 120px;
    background-color: var(--profile-header);
    background-size: cover;
    background-position: center;
    position: relative;
    transition: background-color var(--transition-speed);
}
.profile-close {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
}
.profile-avatar-wrapper {
    margin-top: -48px;
    padding-left: 16px;
    position: relative;
}
#profileAvatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    border: 5px solid var(--profile-bg);
    object-fit: cover;
    background-color: var(--bg-light); /* Avatar yüklenmezse diye */
    transition: border-color var(--transition-speed), background-color var(--transition-speed);
}
.profile-body {
    padding: 16px;
}
#profileName {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary); /* Tema için renk buradan alır */
}
.profile-section {
    margin-top: 20px;
}
.profile-section h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 700;
    margin: 0 0 8px 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    transition: color var(--transition-speed), border-color var(--transition-speed);
}
#profileBio {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}
#musicSection {
    display: none; /* JS ile açılacak */
}
.music-player iframe {
    border-radius: 12px;
    border: none;
}
