:root {
    /* --- DARK THEME (DEFAULT) --- */
    --primary: #8e44ad;
    --primary-hover: #9b59b6;
    --secondary: #2980b9;
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --glass-panel: rgba(0, 0, 0, 0.75);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --text-color: #ffffff;
    --text-secondary: #bdc3c7;
    --received-msg: #34495e;
    --sent-msg: #8e44ad;
    --input-bg: rgba(255,255,255,0.08);
    --online-badge-bg: rgba(46, 204, 113, 0.2);
    --security-good: #27ae60;
    --security-bad: #c0392b;
}

/* --- LIGHT THEME OVERRIDE --- */
body.light-mode {
    --primary: #6c5ce7;
    --primary-hover: #5649c0;
    --secondary: #0984e3;
    --bg-gradient: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    --glass-panel: rgba(255, 255, 255, 0.95);
    --glass-border: 1px solid rgba(0, 0, 0, 0.1);
    --text-color: #2d3436;
    --text-secondary: #636e72;
    --received-msg: #dfe6e9;
    --sent-msg: #6c5ce7;
    --input-bg: rgba(0,0,0,0.05);
    --online-badge-bg: rgba(46, 204, 113, 0.2);
}

body.light-mode .message { color: #2d3436; } 
body.light-mode .sent .message { color: #ffffff; }

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    margin: 0;
    height: 100dvh; 
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative; 
}

/* PANIC BUTTON (Header Style) */
.panic-btn-header {
    background: rgba(192, 57, 43, 0.2) !important;
    border: 1px solid rgba(192, 57, 43, 0.5) !important;
    color: white !important;
    margin-right: 5px;
}
.panic-btn-header:hover {
    background: rgba(192, 57, 43, 0.6) !important;
    transform: scale(1.1);
}

/* --- MAIN CONTAINER --- */
.container {
    width: 100%; max-width: 480px; height: 95vh;
    background: var(--glass-panel);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-radius: 20px; border: var(--glass-border);
    display: flex; flex-direction: column;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
    z-index: 10;
}

@media (max-width: 600px) {
    .container {
        width: 100%; height: 100dvh; max-width: none;
        border-radius: 0; border: none;
    }
}

/* TOP BAR */
.top-bar {
    position: absolute; top: 15px; right: 15px; 
    z-index: 50;
    display: flex; gap: 8px;
}

.lang-select, .icon-btn-small {
    background: rgba(128,128,128,0.3); color: var(--text-color);
    border: 1px solid var(--glass-border); padding: 6px 10px;
    border-radius: 8px; font-size: 0.8rem; cursor: pointer; outline: none;
    backdrop-filter: blur(5px);
}
.icon-btn-small { padding: 6px; width: 34px; display: flex; justify-content: center; align-items: center; font-size: 1rem; }

select option { background-color: #2c3e50; color: #ffffff; }
body.light-mode select option { background-color: #ffffff; color: #2d3436; }

/* LOGIN SCREEN */
#login-screen { 
    padding: 20px; display: flex; flex-direction: column; 
    justify-content: center; height: 100%; overflow-y: auto; 
    position: relative; z-index: 20;
}

.logo-area { text-align: center; margin-bottom: 20px; }
.logo-area h1 { 
    margin: 0; font-weight: 600; font-size: 2.2rem; 
    background: linear-gradient(45deg, var(--primary), #00b894); 
    -webkit-background-clip: text; background-clip: text; 
    color: transparent; 
}
.beta-badge { 
    font-size: 0.8rem; background: var(--secondary); color: white; 
    padding: 2px 6px; border-radius: 4px; vertical-align: super; 
    -webkit-text-fill-color: initial; 
}

.online-badge {
    background: var(--online-badge-bg); color: #27ae60; padding: 4px 12px;
    border-radius: 20px; font-size: 0.75rem; margin-top: 8px;
    display: inline-block; border: 1px solid #27ae60; font-weight: 600;
}

/* TABS STYLE */
.mode-tabs {
    display: flex; gap: 10px; margin-bottom: 20px;
    background: rgba(0,0,0,0.2); padding: 5px; border-radius: 12px;
    position: relative; z-index: 25;
}
.tab-btn {
    flex: 1; background: transparent; border: none; padding: 10px;
    color: var(--text-secondary); cursor: pointer; border-radius: 8px;
    font-weight: 600; transition: 0.3s;
}
.tab-btn.active { background: var(--primary); color: white; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }

/* INPUTS */
.input-group { margin-bottom: 15px; position: relative; z-index: 25; }
.input-label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 6px; display: block; }

input, select {
    width: 100%; padding: 12px; border-radius: 10px;
    border: 1px solid var(--glass-border); background: var(--input-bg);
    color: var(--text-color); font-size: 1rem; font-family: inherit;
    position: relative; z-index: 30;
}
select { cursor: pointer; }

.start-btn {
    background: var(--primary); color: white; padding: 14px; border: none;
    border-radius: 12px; font-size: 1.1rem; font-weight: 600; cursor: pointer;
    margin-top: 10px; width: 100%; transition: transform 0.2s;
    position: relative; z-index: 30;
}
.start-btn:active { transform: scale(0.98); }
.start-btn.secondary { background: var(--secondary); }
.room-actions { display: flex; gap: 10px; }
.room-actions button { width: 50%; }

/* CHAT SCREEN */
#chat-screen { 
    display: none; flex-direction: column; height: 100%; width: 100%; 
    z-index: 20; 
}

#header { 
    padding: 10px 15px; background: rgba(0,0,0,0.05); 
    border-bottom: 1px solid var(--glass-border); display: flex; 
    justify-content: space-between; align-items: center; flex-shrink: 0; 
    position: relative; z-index: 25;
}
.partner-info { display: flex; align-items: center; gap: 10px; }
.avatar-circle {
    width: 38px; height: 38px; border-radius: 50%; background: #ddd;
    overflow: hidden; border: 2px solid var(--primary);
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
#partner-name { font-weight: 600; font-size: 1rem; display:block; }
.status-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; }
.status-badge.connecting { color: #f1c40f; background: rgba(241, 196, 15, 0.1); }
.status-badge.p2p { color: #2ecc71; background: rgba(46, 204, 113, 0.1); }
.status-badge.relay { color: #3498db; background: rgba(52, 152, 219, 0.1); }

.header-actions { display: flex; align-items: center; gap: 5px; }
.icon-btn {
    background: rgba(255,255,255,0.1); border: none; color: var(--text-color);
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
    display: inline-flex; justify-content: center; align-items: center; font-size: 0.9rem;
}
.close-btn { background: rgba(231, 76, 60, 0.2) !important; color: #e74c3c !important; }

/* TIMER SELECT */
.timer-select {
    width: auto; padding: 5px; font-size: 0.75rem; 
    border-radius: 8px; margin-right: 5px;
    background: rgba(0,0,0,0.2); border: 1px solid var(--glass-border);
}

/* MESSAGES */
#messages { 
    flex: 1; overflow-y: auto; padding: 15px; 
    display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; 
    z-index: 15;
}
.msg-row { display: flex; gap: 8px; align-items: flex-end; max-width: 85%; }
.msg-row.sent { align-self: flex-end; flex-direction: row-reverse; }

/* STYLE AVATAR DI CHAT */
.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 2px;
    flex-shrink: 0;
    align-self: flex-end; /* Supaya sejajar bawah bubble */
    border: 1px solid rgba(255,255,255,0.2);
    background: #ccc;
    object-fit: cover;
}

.message {
    padding: 10px 14px; border-radius: 16px; font-size: 0.95rem; line-height: 1.4;
    position: relative; word-wrap: break-word; color: white; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex; flex-direction: column; min-width: 100px;
}
.received .message { background: var(--received-msg); border-bottom-left-radius: 2px; color: var(--text-color); }
.sent .message { background: var(--sent-msg); border-bottom-right-radius: 2px; color: white; }

/* STYLE UNTUK ID DI PESAN */
.msg-id {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
    font-family: monospace;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 2px;
}
body.light-mode .msg-id { color: rgba(0, 0, 0, 0.6); border-bottom: 1px solid rgba(0,0,0,0.1); }

/* GAMBAR DI CHAT */
.chat-img-container { position: relative; max-width: 200px; border-radius: 12px; overflow: hidden; }
.chat-img { width: 100%; height: auto; display: block; }
.blur-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    display: flex; justify-content: center; align-items: center; cursor: pointer;
    background: rgba(0,0,0,0.3); transition: 0.3s;
}
.chat-img-container.revealed .blur-overlay { opacity: 0; pointer-events: none; }

.sys-msg { align-self: center; font-size: 0.7rem; background: rgba(128,128,128,0.2); padding: 4px 12px; border-radius: 20px; color: var(--text-secondary); margin: 8px 0; text-align: center; }

#status-bar { 
    padding: 4px 15px; font-size: 0.65rem; color: var(--text-secondary); 
    display:flex; justify-content:space-between; align-items:center; flex-shrink: 0;
}
.security-badge { display: flex; align-items: center; gap: 4px; }

/* CONTROLS */
#controls { 
    padding: 10px; background: rgba(0,0,0,0.15); border-top: 1px solid var(--glass-border); 
    display: flex; align-items: center; gap: 8px; flex-shrink: 0; 
    position: relative; z-index: 25;
}
.tool-btn { background: transparent; border: none; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; padding: 4px; }
#msg-input { 
    flex: 1; border-radius: 20px; padding: 10px 15px; background: var(--input-bg); 
    border: none; color: var(--text-color); min-height: 40px; 
}
.send-btn-round { background: var(--primary); border: none; width: 40px; height: 40px; border-radius: 50%; color: white; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 1.1rem; flex-shrink: 0; }

/* BAN SCREEN */
#ban-screen {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: rgba(0,0,0,0.95); z-index: 99999;
    display: none; flex-direction: column;
    justify-content: center; align-items: center; color: red;
    text-align: center; padding: 20px;
}

/* Badge Admin di Header */
#my-role-badge {
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    margin-bottom: 2px;
}

/* --- VOICE NOTE STYLES --- */

/* Animasi Titik Merah saat merekam */
.recording-dot {
    width: 12px; height: 12px;
    background-color: #e74c3c;
    border-radius: 50%;
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* Audio Player Customization */
audio {
    height: 36px;
    max-width: 220px;
    outline: none;
    border-radius: 18px;
}

/* Chrome specific styling untuk audio player agar lebih rapi */
audio::-webkit-media-controls-panel {
    background-color: rgba(255, 255, 255, 0.8);
}
body.light-mode audio::-webkit-media-controls-panel {
    background-color: #f1f2f6;
}