:root {
    --bg-dark: #0e1621;
    --side-bg: #17212b;
    --accent: #50a2e3;
    --msg-me: #2b5278; 
    --msg-other: #182533; 
    --text: #ffffff;
    --text-dim: #7f91a4;
}

body, html {
    margin: 0; padding: 0;
    height: 100%; width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: 
        url("telegramSK6.png") repeat 0 0 / 400px auto, 
        linear-gradient(45deg, rgba(89, 202, 255, 1) 0%, rgba(168, 110, 255, 1) 100%);
    background-blend-mode: overlay; 
    color: var(--text);
    overflow: hidden;
}

#loginScreen {
    height: 100vh;
    display: flex; justify-content: center; align-items: center;
    background: 
        url("telegramSK6.png") repeat 0 0 / 400px auto, 
        linear-gradient(45deg, rgba(89, 202, 255, 1) 0%, rgba(168, 110, 255, 1) 100%);
    background-blend-mode: overlay; 
}

.login-card {
    background: var(--side-bg);
    padding: 40px; border-radius: 24px;
    width: 340px; text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    animation: pop 0.3s ease-out;
}

.logo-area { font-size: 60px; margin-bottom: 20px; }
.login-card h1 { margin: 0 0 10px; font-size: 24px; }
.login-card p { color: var(--text-dim); font-size: 14px; margin-bottom: 30px; }

.input-wrapper {
    background: #242f3d;
    margin: 10px 0; padding: 12px 15px;
    border-radius: 12px; display: flex; align-items: center; gap: 10px;
    border: 1px solid transparent; transition: 0.2s;
}
.input-wrapper:focus-within { border-color: var(--accent); }
.input-wrapper input { background: transparent; border: none; color: white; outline: none; flex: 1; }

.main-btn {
    width: 100%; padding: 14px; border-radius: 12px;
    background: var(--accent); color: white; border: none;
    font-weight: bold; cursor: pointer; margin-top: 20px;
    transition: filter 0.2s;
}
.main-btn:hover { filter: brightness(1.1); }
.link-btn { background: transparent; border: none; color: var(--accent); margin-top: 15px; cursor: pointer; font-size: 14px; }

#mainApp { height: 100vh; display: flex; }
.sidebar { width: 320px; background: var(--side-bg); border-right: 1px solid #080c11; display: flex; flex-direction: column; z-index: 10; }
.sidebar-header { padding: 20px; display: flex; align-items: center; gap: 15px; cursor: pointer; transition: background 0.2s; }
.sidebar-header:hover { background: rgba(255,255,255,0.05); }

.avatar-img-small {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    background: #242f3d;
}

.avatar-container {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--accent);
}

.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-meta { flex: 1; }
.user-meta small { color: var(--accent); display: block; }

.nav-menu { padding: 10px; }
.nav-item { width: 100%; background: transparent; border: none; color: white; padding: 12px 15px; display: flex; align-items: center; gap: 15px; border-radius: 10px; cursor: pointer; position: relative; transition: 0.2s; }
.nav-item:hover { background: rgba(255,255,255,0.05); }
.nav-item i { color: var(--text-dim); width: 20px; }

.badge { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); background: #f53d3d; color: white; font-size: 11px; font-weight: bold; min-width: 18px; height: 18px; border-radius: 9px; display: none; align-items: center; justify-content: center; padding: 2px 6px; }
.contact-label { font-size: 12px; color: var(--text-dim); font-weight: bold; padding: 20px 20px 10px; }
.contact-list { flex: 1; overflow-y: auto; }
.contact-list .friend-item { 
    padding: 12px 20px; 
    cursor: pointer; 
    transition: 0.2s; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}
.contact-list .friend-item:hover { background: rgba(255,255,255,0.05); }

.chat-container { flex: 1; display: flex; flex-direction: column; background: #0e1621; position: relative; }
.chat-top-bar { background: var(--side-bg); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); z-index: 5; }

.messages-viewport {
    position: relative; 
    flex: 1; 
    overflow-y: auto; 
    padding: 20px;
    display: flex; 
    flex-direction: column;
    gap: 6px;
    z-index: 0;
}

.messages-viewport::before {
    content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url("telegramSK6.png"); background-repeat: repeat;
    background-position: center; background-size: 400px auto;
    opacity: 0.3; z-index: -1; pointer-events: none; 
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }

/* --- ZMENA: Všetky správy na ľavej strane --- */
.msg-wrapper { display: flex; flex-direction: column; margin-bottom: 2px; align-items: flex-start; }

.bubble { max-width: 75%; padding: 8px 12px; border-radius: 12px; position: relative; font-size: 15px; line-height: 1.4; box-shadow: 0 1px 2px rgba(0,0,0,0.2); color: #f0f0f0; border-bottom-left-radius: 4px; }
.bubble.me { background: var(--msg-me); }
.bubble.other { background: var(--msg-other); }

.msg-info { display: block; font-size: 10px; color: rgba(255,255,255,0.5); text-align: right; margin-top: 4px; }

.input-bar { padding: 15px 20px; display: flex; align-items: center; gap: 12px; background: var(--side-bg); }
.input-box { flex: 1; background: #242f3d; border-radius: 22px; padding: 10px 18px; display: flex; align-items: center; gap: 10px; }
.input-box input { background: transparent; border: none; color: white; outline: none; flex: 1; font-size: 15px; }
.input-box i { color: var(--text-dim); cursor: pointer; }

.circle-send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); border: none; color: white; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 20px; transition: transform 0.2s; }
.circle-send:hover { transform: scale(1.08); }

.jump-button { position: absolute; bottom: 85px; right: 25px; width: 42px; height: 42px; border-radius: 50%; background: var(--side-bg); color: var(--accent); border: 1px solid rgba(255,255,255,0.1); display: none; justify-content: center; align-items: center; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.4); transition: 0.2s; }
.empty-state { margin: auto; text-align: center; color: rgba(255,255,255,0.5); }
.empty-state i { font-size: 60px; margin-bottom: 15px; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(5px); }
.modal-content { background: var(--side-bg); width: 340px; border-radius: 20px; overflow: hidden; animation: pop 0.25s ease-out; }
.modal-head { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.05); }
.modal-inner { padding: 25px; }

.avatar-selector {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}
.avatar-option {
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s;
}
.avatar-option:hover { transform: scale(1.1); }
.avatar-option img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid transparent;
}
.avatar-option.selected img {
    border-color: var(--accent);
}

#toastContainer { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 9999; }
.toast { background: var(--accent); color: white; padding: 12px 24px; border-radius: 25px; font-size: 14px; margin-bottom: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.4); animation: slideUp 0.3s ease; }

@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }