:root {
    --d-bg: #36393f;
    --d-sidebar: #2f3136;
    --d-header: #2f3136;
    --d-input: #40444b;
    --d-text-main: #dcddde;
    --d-text-muted: #72767d;
    --d-accent: #5865F2;
    --d-green: #3ba55c;
    --d-red: #ed4245;
    --d-hover: #32353b;
    --d-font: "gg sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* --- LAUNCHER (PILL SHAPE) --- */
#chat-widget-launcher {
    position: fixed; bottom: 25px; right: 25px; 
    height: 56px; 
    width: auto; 
    padding: 0 24px; 
    background: var(--d-accent); 
    border-radius: 28px; 
    display: flex; align-items: center; justify-content: center; gap: 12px;
    cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: transform 0.2s, background 0.2s; 
    z-index: 10000;
    font-family: var(--d-font);
}

#chat-widget-launcher:hover { 
    transform: scale(1.05); 
    background: #4752c4; 
}

#chat-widget-launcher svg { 
    width: 28px; height: 28px; fill: white; flex-shrink: 0; 
}

.launcher-text {
    color: white; font-weight: 700; font-size: 16px; 
    white-space: nowrap; pointer-events: none;
}

/* --- MOBILE: REVERT TO CIRCLE --- */
@media (max-width: 480px) {
    #chat-widget-launcher {
        width: 56px; padding: 0; border-radius: 50%;
    }
    .launcher-text { display: none; }
    
    /* Mobile Window Positioning */
    #chat-widget-window {
        width: calc(100% - 30px) !important; 
        height: 85vh !important; 
        right: 15px !important; 
        bottom: 15px !important; /* Move down on mobile too */
    }
}

/* --- WINDOW & CHAT STYLES --- */
#chat-widget-window {
    position: fixed; 
    bottom: 25px; /* CHANGED: Was 100px. Now sits lower since button is gone. */
    right: 25px; 
    width: 380px; 
    height: 600px;
    background: var(--d-bg); border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    display: none; flex-direction: column; overflow: hidden;
    z-index: 10000; font-family: var(--d-font); color: var(--d-text-main);
    border: 1px solid #202225;
}

.chat-header {
    background: var(--d-header); padding: 12px 16px;
    display: flex; align-items: center; border-bottom: 1px solid #202225;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.header-hash { color: var(--d-text-muted); font-size: 24px; margin-right: 8px; font-weight: 300; }
.header-title { font-weight: 700; color: white; font-size: 16px; }
.header-status { font-size: 12px; color: var(--d-text-muted); margin-left: 10px; display: flex; align-items: center; gap: 4px; }
.status-dot { width: 8px; height: 8px; background: var(--d-text-muted); border-radius: 50%; }
.status-dot.online { background: var(--d-green); box-shadow: 0 0 5px var(--d-green); }

#chat-messages {
    flex: 1; padding: 16px 0; overflow-y: auto; overflow-x: hidden;
    display: flex; flex-direction: column; gap: 4px; 
}

.discord-msg {
    display: flex; padding: 4px 16px; width: 100%; box-sizing: border-box;
    margin-top: 10px;
}
.discord-msg:hover { background: rgba(4, 4, 5, 0.07); }

.d-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    margin-right: 16px; flex-shrink: 0; cursor: pointer;
    background-size: cover; background-position: center;
}
.d-avatar:hover { opacity: 0.8; }

.d-content { flex: 1; min-width: 0; }
.d-author-line { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.d-username { font-weight: 500; color: white; font-size: 1rem; cursor: pointer; }
.d-username:hover { text-decoration: underline; }

.d-bot-tag {
    background: var(--d-accent); color: white; font-size: 0.625rem;
    padding: 1px 4px; border-radius: 3px; font-weight: 500; display: flex; align-items: center;
}
.d-bot-tag svg { width: 9px; margin-right: 2px; }

.d-timestamp { font-size: 0.75rem; color: var(--d-text-muted); margin-left: 4px; font-weight: 400; }
.d-text {
    color: var(--d-text-main); font-size: 0.95rem; line-height: 1.375rem;
    white-space: pre-wrap; word-wrap: break-word;
}
.d-text a { color: #00b0f4; text-decoration: none; }
.d-text a:hover { text-decoration: underline; }

.chat-image { max-width: 100%; max-height: 300px; border-radius: 4px; margin-top: 6px; cursor: pointer; }
.file-attachment {
    display: flex; align-items: center; gap: 10px; background: #2f3136;
    padding: 10px; border-radius: 4px; border: 1px solid #202225;
    margin-top: 6px; max-width: fit-content; text-decoration: none; color: var(--d-text-main);
}
.file-attachment svg { width: 30px; height: 30px; color: var(--d-accent); }

.chat-footer {
    padding: 0 16px 20px 16px; background: var(--d-bg);
    display: flex; flex-direction: column;
}

.input-wrapper {
    background: var(--d-input); border-radius: 8px;
    display: flex; align-items: center; padding: 0 10px;
}

.chat-footer input {
    flex: 1; background: transparent; border: none;
    padding: 11px 0; color: var(--d-text-main); font-size: 0.95rem;
    outline: none;
}

.attach-btn {
    background: none; border: none; cursor: pointer; color: #b9bbbe;
    padding: 8px; display: flex; align-items: center; justify-content: center;
    border-right: 1px solid #4f545c; margin-right: 10px; height: 24px;
}
.attach-btn:hover { color: var(--d-text-main); }

.notification-badge {
    position: absolute; top: -3px; right: -3px; background: var(--d-red);
    color: white; border-radius: 50%; width: 22px; height: 22px;
    font-size: 11px; font-weight: bold; display: none; align-items: center; justify-content: center;
    border: 3px solid #ffffff; 
}

.uploading-overlay {
    position: absolute; top:0; left:0; width:100%; height:100%;
    background: rgba(0,0,0,0.7); display:none; flex-direction: column;
    align-items: center; justify-content: center; z-index: 20; color: white;
}

#chat-email-row {
    padding: 0 16px 10px 16px; background: var(--d-bg);
}
#chat-email {
    width: 100%; background: var(--d-input); border: none; color: white;
    padding: 8px; border-radius: 4px; outline: none; font-size: 0.85rem;
}

#chat-messages::-webkit-scrollbar { width: 8px; background: #2e3338; border-radius: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: #202225; border-radius: 4px; }

.discord-typing { padding: 0 16px; font-size: 0.75rem; color: var(--d-text-main); font-weight: bold; display: none; margin-bottom: 5px; }
.dots { display: inline-block; animation: typing 1.4s infinite; }
@keyframes typing { 0%{opacity:0.2;} 20%{opacity:1;} 100%{opacity:0.2;} }

/* --- POPUP --- */
#admin-popup-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: none;
    align-items: center; justify-content: center; z-index: 20000;
}
#admin-popup-card {
    background: #36393f; width: 90%; max-width: 440px; border-radius: 5px;
    overflow: hidden; box-shadow: 0 0 0 1px #202225;
}
.popup-header { background: #202225; color: white; padding: 16px; font-weight: bold; }
.popup-body { padding: 16px; color: var(--d-text-main); line-height: 1.5; }
.popup-footer { background: #2f3136; padding: 12px 16px; text-align: right; }
#close-admin-popup {
    background: var(--d-accent); color: white; border: none; padding: 8px 16px;
    border-radius: 3px; cursor: pointer; font-weight: 500;
}
#close-admin-popup:hover { background: #4752c4; }