/* --- VARIABLES & THEME (Midnight Gold Luxury) --- */
:root {
    --uop-gold-gradient: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    --uop-gold-glow: rgba(245, 158, 11, 0.5);
    --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;
    
    /* New Luxury Badge Colors */
    --uop-badge-gradient: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    --uop-badge-glow: rgba(239, 68, 68, 0.6);
    --uop-online-color: #10B981;
}

/* --- MAIN BUTTON --- */
#uop-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--uop-gold-gradient);
    color: white;
    padding: 14px 24px;
    border-radius: 50px;
    cursor: pointer;
    z-index: 99999;
    box-shadow: 0 4px 25px var(--uop-gold-glow);
    font-family: var(--uop-font);
    font-size: 15px;
    font-weight: 700;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255,255,255,0.2);
}

#uop-button:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 40px var(--uop-gold-glow);
}

#uop-button.has-new-message {
    animation: uop-shake 1s cubic-bezier(.36,.07,.19,.97) both infinite;
}

#uop-total {
    background: rgba(0, 0, 0, 0.25);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    min-width: 24px;
    text-align: center;
}

@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); }
}

/* --- POPUP CONTAINER --- */
#uop-popup {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 620px;
    max-height: 80vh;
    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 --- */
.uop-header {
    background: linear-gradient(to right, rgba(255,255,255,0.03), transparent);
    color: var(--uop-text-main);
    padding: 20px;
    font-weight: 700;
    font-size: 17px;
    text-align: center;
    border-bottom: 1px solid var(--uop-border);
    position: relative;
    cursor: move;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.5px;
}

#uop-close {
    position: absolute;
    right: 20px;
    font-size: 26px;
    cursor: pointer;
    color: var(--uop-text-muted);
    transition: 0.2s;
    line-height: 1;
}
#uop-close:hover { color: #fff; transform: scale(1.1); }

#uop-content {
    display: flex; flex-direction: column; height: 100%; overflow: hidden; flex: 1;
}

/* --- MEMBER LIST --- */
#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); 
}

/* Avatar Wrapper with Online Ripple */
.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);
}

/* --- ANIMASI ONLINE DOT (RIPPLE) --- */
.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.5); 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;
}

/* --- BADGE UNREAD (MEWAH) --- */
.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); }
}

/* --- TOMBOL CHAT --- */
.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; }

/* --- CHAT ROOM & INPUT --- */
#uop-chat-section {
    display: flex; flex-direction: column; height: 100%; background: #0B101A; position: relative;
}

#uop-chat-header {
    flex-shrink: 0; padding: 15px 20px; background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid var(--uop-border);
    display: flex; align-items: center; color: white; font-weight: 600;
}
#uop-chat-back {
    background: none; border: none; font-size: 20px; color: #F59E0B; cursor: pointer; margin-right: 15px;
}

#uop-chat-messages {
    flex-grow: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
    background-image: radial-gradient(circle at center, #131d33 0%, #0b101a 100%);
}

.uop-msg {
    max-width: 80%; padding: 12px 16px; border-radius: 18px; font-size: 14px;
    line-height: 1.5; position: relative; word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.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);
}

.uop-msg small {
    display: block; font-size: 10px; opacity: 0.7; margin-top: 4px; text-align: right;
}

.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;
}

#uop-chat-message {
    flex-grow: 1; background: var(--uop-bg-lighter); border: 1px solid var(--uop-border);
    color: white; padding: 12px 16px; border-radius: 24px; resize: none;
    max-height: 100px; min-height: 44px; font-family: inherit; font-size: 14px;
}
#uop-chat-message:focus { outline: none; border-color: #F59E0B; }

#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: #F59E0B; 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.1); }
#uop-chat-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
#uop-chat-send:disabled { background: #555; cursor: not-allowed; transform: none; box-shadow: none; }

/* GUEST FORM */
#uop-guest-form { padding: 30px; display: flex; flex-direction: column; gap: 15px; color: var(--uop-text-muted); }
.uop-input {
    width: 100%; padding: 14px; background: var(--uop-bg-lighter);
    border: 1px solid var(--uop-border); border-radius: 12px;
    font-size: 14px; color: white; outline: none;
}
.uop-input:focus { border-color: #F59E0B; }
.uop-btn-primary {
    background: var(--uop-gold-gradient); color: white; border: none;
    padding: 16px; border-radius: 12px; font-weight: 700; cursor: pointer; margin-top: 10px;
    box-shadow: 0 4px 15px var(--uop-gold-glow);
}
.uop-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* EMOJI PICKER */
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);
}

/* MOBILE */
@media (max-width: 480px) {
    #uop-button { bottom: 20px; right: 20px; padding: 10px 18px; font-size: 13px; }
    #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; }
    emoji-picker { width: 92%; left: 4%; bottom: 90px; }
}