/* --- VARIABLES & THEME (Midnight Luxury & Modern Academic Blue) --- */
:root {
    --uop-gold-gradient: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    --uop-gold-glow: rgba(245, 158, 11, 0.4);
    --uop-bg-dark: #0F172A;
    --uop-bg-glass: rgba(15, 23, 42, 0.98);
    --uop-bg-lighter: #1E293B;
    --uop-border: rgba(255, 255, 255, 0.08);
    --uop-text-main: #F8FAFC;
    --uop-text-muted: #94A3B8;
    --uop-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.6);
    --uop-font: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --uop-badge-gradient: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    --uop-badge-glow: rgba(239, 68, 68, 0.6);
    --uop-online-color: #10B981;

    /* Tema Edukasi Modern */
    --uop-edu-blue: #2563EB;
    --uop-edu-badge-bg: linear-gradient(135deg, #1D4ED8 0%, #2563EB 100%);
    --uop-edu-badge-border: rgba(147, 197, 253, 0.35);
    --uop-edu-badge-glow: rgba(37, 99, 235, 0.35);
}

/* Tombol Floating */
#uop-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: transparent;
    color: #25D366;
    padding: 0;
    border-radius: 0;
    border: none;
    cursor: pointer;
    z-index: 99999;
    font-family: var(--uop-font);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    box-shadow: none;
}

#uop-button svg {
    width: 50px;
    height: 50px;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.4)) drop-shadow(0 2px 4px rgba(37,211,102,0.3));
    transition: all 0.3s ease;
}

#uop-button:hover {
    transform: translateY(-5px) scale(1.1);
    color: #1EBE5D;
}

#uop-button.has-new-message svg {
    animation: uop-shake 1s cubic-bezier(.36,.07,.19,.97) both infinite;
}

#uop-total {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--uop-badge-gradient);
    color: white;
    padding: 2px 6px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    min-width: 20px;
    text-align: center;
    border: none;
    box-shadow: 0 2px 8px var(--uop-badge-glow);
    z-index: 2;
}

@keyframes uop-shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Jendela Popup */
#uop-popup {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 620px;
    max-height: 82vh;
    background: var(--uop-bg-glass);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--uop-border);
    border-radius: 24px;
    box-shadow: var(--uop-shadow);
    z-index: 99999;
    overflow: hidden;
    font-family: var(--uop-font);
    flex-direction: column;
    animation: uop-fade-up 0.3s ease-out;
}

@keyframes uop-fade-up {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header Popup Utama */
.uop-header {
    background: linear-gradient(to right, rgba(255,255,255,0.03), transparent);
    color: var(--uop-text-main);
    padding: 16px 20px;
    border-bottom: 1px solid var(--uop-border);
    position: relative;
    cursor: move;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uop-header-title-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 25px;
}

.uop-header-main-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--uop-text-main);
    line-height: 1.2;
}

.uop-header-sub-desc {
    font-size: 11px;
    color: var(--uop-text-muted);
    font-weight: 500;
    margin-top: 4px;
    line-height: 1.3;
}

#uop-close {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 26px;
    cursor: pointer;
    color: var(--uop-text-muted);
    transition: 0.2s;
    line-height: 1;
}
#uop-close:hover { color: #fff; transform: translateY(-50%) scale(1.1); }

#uop-content {
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    overflow: hidden; 
    flex: 1;
}

#uop-member-section {
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    overflow: hidden;
}

#uop-inbox-button {
    margin: 15px 15px 5px 15px;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    color: var(--uop-text-muted);
    border: 1px solid var(--uop-border);
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: 0.3s;
}
#uop-inbox-button:hover { 
    background: rgba(255,255,255,0.08); 
    color: white; 
    border-color: rgba(255,255,255,0.2); 
}

#uop-member-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

.uop-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    margin-bottom: 8px;
    border-radius: 16px;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.uop-user:hover { 
    background: rgba(255,255,255,0.04); 
    border-color: var(--uop-border); 
}

.uop-avatar-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.uop-user img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.1);
}

.uop-status-dot-online {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--uop-online-color);
    border-radius: 50%;
    border: 2px solid var(--uop-bg-dark);
    z-index: 2;
}

.uop-status-dot-online::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 100%; height: 100%;
    background: var(--uop-online-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: uop-ripple 2s infinite;
    z-index: 1;
}

@keyframes uop-ripple {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0; }
}

.uop-user-left {
    display: flex; 
    align-items: center; 
    gap: 14px; 
    flex-grow: 1; 
    min-width: 0; 
    margin-right: 10px;
}

.uop-user-name {
    color: var(--uop-text-main);
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
}

/* BADGE "GURU" (Biru Edukasi Modern) */
.uop-admin-badge {
    background: var(--uop-edu-badge-bg) !important;
    color: #FFFFFF !important;
    font-weight: 800 !important;
    font-size: 10px !important;
    padding: 2.5px 8px !important;
    border-radius: 6px !important;
    margin-left: 8px !important;
    box-shadow: 0 2px 8px var(--uop-edu-badge-glow) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.8px;
    border: 1px solid var(--uop-edu-badge-border) !important;
    text-transform: uppercase;
    line-height: 1.2;
    vertical-align: middle;
}

.uop-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--uop-badge-gradient);
    color: white;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    margin-left: 8px;
    box-shadow: 0 0 10px var(--uop-badge-glow);
    animation: uop-pulse-red 2s infinite;
    vertical-align: middle;
}

@keyframes uop-pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.uop-chat-open {
    background: rgba(255,255,255,0.08);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.uop-chat-open:hover { 
    background: var(--uop-gold-gradient); 
    box-shadow: 0 4px 12px var(--uop-gold-glow); 
}

.uop-delete-chat {
    background: rgba(220, 38, 38, 0.1);
    color: #F87171;
    border: none;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 5px;
}
.uop-delete-chat:hover { background: #DC2626; color: white; }

#uop-chat-section {
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    background: #0B101A; 
    position: relative;
}

/* HEADER OBROLAN */
#uop-chat-header {
    flex-shrink: 0; 
    padding: 12px 18px; 
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--uop-border);
    display: flex; 
    align-items: center; 
    color: white; 
    gap: 8px;
    backdrop-filter: blur(10px);
}

#uop-chat-back {
    background: none; 
    border: none; 
    font-size: 20px; 
    color: #60A5FA; 
    cursor: pointer; 
    padding: 4px 8px 4px 0;
    line-height: 1;
    transition: transform 0.2s;
}
#uop-chat-back:hover { transform: translateX(-3px); }

#uop-chat-profile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-grow: 1;
    min-width: 0;
}

.uop-profile-avatar-wrap {
    position: relative;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

#uop-header-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.25);
    display: block;
    background: #1E293B;
}

.uop-profile-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #0B101A;
    z-index: 2;
}

.uop-profile-dot.online {
    background: var(--uop-online-color);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
}

.uop-profile-dot.online::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 100%; height: 100%;
    background: var(--uop-online-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: uop-ripple 2s infinite;
    z-index: 1;
}

.uop-profile-dot.offline {
    background: #64748B;
    box-shadow: none;
}

.uop-profile-text-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

#uop-chat-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--uop-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

/* SUBTITLE STATUS (Hanya Teks, Titik Hijau Tunggal di Avatar) */
.uop-profile-sub {
    font-size: 11px;
    margin-top: 3px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.uop-profile-sub.online { 
    color: #10B981; 
}

.uop-profile-sub.offline { 
    color: var(--uop-text-muted); 
}

#uop-chat-export {
    background: none; 
    border: none; 
    color: #94A3B8; 
    cursor: pointer; 
    transition: 0.2s;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-shrink: 0;
    padding: 6px;
}
#uop-chat-export:hover { color: #60A5FA; transform: scale(1.1); }
#uop-chat-export svg { width: 20px; height: 20px; fill: currentColor; }

#uop-chat-messages {
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 20px;
    display: flex; 
    flex-direction: column; 
    gap: 12px;
    scroll-behavior: smooth;
    background-image: radial-gradient(circle at center, #131d33 0%, #0b101a 100%);
    padding-bottom: 40px;
}

#uop-typing-indicator {
    position: absolute;
    bottom: 80px;
    left: 20px;
    font-size: 11px;
    color: var(--uop-text-muted);
    font-style: italic;
    background: var(--uop-bg-glass);
    padding: 6px 14px;
    border-radius: 12px;
    border: 1px solid var(--uop-border);
    z-index: 10;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* BALON PESAN */
.uop-msg {
    max-width: 82%; 
    padding: 12px 16px; 
    border-radius: 18px; 
    font-size: 13.5px;
    line-height: 1.55; 
    position: relative; 
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: uop-msg-pop 0.25s ease-out;
}

@keyframes uop-msg-pop {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.uop-msg.mine {
    background: var(--uop-gold-gradient); 
    color: white; 
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.uop-msg.theirs {
    background: var(--uop-bg-lighter); 
    color: #E2E8F0; 
    align-self: flex-start;
    border-bottom-left-radius: 4px; 
    border: 1px solid var(--uop-border);
}

/* Balon Pesan Sambutan Khusus dari Guru */
.uop-msg.uop-welcome-bubble {
    background: linear-gradient(145deg, #1E293B 0%, #0F1D36 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
}

.uop-welcome-badge-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #60A5FA;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.uop-msg small {
    display: block; 
    font-size: 10px; 
    opacity: 0.75; 
    margin-top: 6px; 
    text-align: right;
}

/* AREA INPUT CHAT */
.uop-chat-input {
    flex-shrink: 0; 
    padding: 12px 15px; 
    background: var(--uop-bg-dark);
    border-top: 1px solid var(--uop-border);
    display: flex; 
    align-items: flex-end; 
    gap: 10px; 
    z-index: 50;
    position: relative;
}

#uop-chat-message {
    flex-grow: 1; 
    background: var(--uop-bg-lighter); 
    border: 1px solid var(--uop-border);
    color: white; 
    padding: 12px 16px; 
    border-radius: 20px; 
    resize: none;
    max-height: 100px; 
    min-height: 44px; 
    font-family: inherit; 
    font-size: 13px;
    line-height: 1.4;
}
#uop-chat-message:focus { outline: none; border-color: #3B82F6; }

#uop-chat-message::placeholder {
    color: #64748B;
    font-size: 12.5px;
}

#uop-emoji-btn, #uop-chat-send {
    height: 44px; 
    width: 44px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    border-radius: 50%; 
    cursor: pointer; 
    border: none; 
    flex-shrink: 0; 
    transition: 0.2s;
}

#uop-emoji-btn { background: transparent; color: #94A3B8; }
#uop-emoji-btn:hover { color: #60A5FA; background: rgba(255,255,255,0.05); }
#uop-emoji-btn svg { width: 24px; height: 24px; fill: currentColor; }

#uop-chat-send {
    background: var(--uop-gold-gradient); 
    color: white;
    box-shadow: 0 4px 15px var(--uop-gold-glow);
}
#uop-chat-send:hover { transform: scale(1.08); }
#uop-chat-send:active { transform: scale(0.95); }
#uop-chat-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; pointer-events: none; }
#uop-chat-send:disabled { background: #555; cursor: not-allowed; transform: none; box-shadow: none; }

emoji-picker {
    position: absolute; 
    bottom: 80px; 
    left: 15px; 
    z-index: 100; 
    display: none;
    box-shadow: var(--uop-shadow); 
    border-radius: 16px; 
    width: 320px; 
    height: 380px;
    border: 1px solid var(--uop-border); 
    --background: #1E293B; 
    --border-color: rgba(255,255,255,0.1);
}

/* RESPONSIVE MOBILE */
@media (max-width: 480px) {
    #uop-button { bottom: 20px; right: 20px; width: 50px; height: 50px; }
    #uop-button svg { width: 42px; height: 42px; }
    #uop-popup { 
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; 
        width: 100% !important; height: 100% !important; max-height: none !important; 
        border-radius: 0; border: none; 
    }
    .uop-header { padding-top: max(15px, env(safe-area-inset-top)); }
    .uop-chat-input { padding-bottom: max(15px, env(safe-area-inset-bottom)); background: #0F172A; }
    .uop-header-sub-desc { font-size: 10.5px; }
    emoji-picker { width: 92%; left: 4%; bottom: 90px; }
}