/*
 * Author: MAKATANGA
 * Telegram: t.me/@MAKATANGA
 * This product is sold exclusively on codecanyon.net
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');

* {
    box-sizing: border-box;
}

:root {
    /* Modern Dark Theme Palette */
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --component-bg: rgba(30, 30, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #9d4edd;
    --primary-hover: #7b2cbf;
    --secondary: #00b4d8;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    
    --msg-sent-bg: linear-gradient(135deg, #7b2cbf, #9d4edd);
    --msg-received-bg: rgba(60, 60, 60, 0.6);
    
    --input-bg: rgba(0, 0, 0, 0.3);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}


body {
    background: var(--bg-gradient);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    margin: 0;
    height: 100dvh; /* Use dvh for mobile address bar support */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Animated Glowing Border Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9999;
    border: 3px solid transparent;
    border-image: linear-gradient(
        90deg,
        rgba(0, 123, 255, 0.8),
        rgba(138, 43, 226, 0.8),
        rgba(0, 191, 255, 0.8),
        rgba(138, 43, 226, 0.8),
        rgba(0, 123, 255, 0.8)
    ) 1;
    animation: borderGlow 3s ease-in-out infinite;
    box-shadow: 
        inset 0 0 30px rgba(0, 123, 255, 0.3),
        inset 0 0 60px rgba(138, 43, 226, 0.2),
        0 0 30px rgba(0, 123, 255, 0.3),
        0 0 60px rgba(138, 43, 226, 0.2);
}

@keyframes borderGlow {
    0%, 100% {
        opacity: 0.6;
        filter: brightness(1) hue-rotate(0deg);
    }
    50% {
        opacity: 1;
        filter: brightness(1.3) hue-rotate(20deg);
    }
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Glassmorphism Container */
.auth-container, .app-layout {
    background: #1e1e1e;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 1100px;
    animation: fadeIn 0.8s ease-out;
    display: flex;
    overflow: hidden;
    height: 85vh;
}

.auth-container {
    padding: 3rem 2rem;
    max-width: 420px;
    display: block;
    height: auto;
    text-align: center;
}

.auth-container h2 {
    margin: 0 0 2rem 0;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
    box-shadow: none; /* Reset */
    border: none;
    border-radius: 0;
    padding: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #18191a !important; /* Force true black-ish background */
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    height: 100%;
    margin-right: -1px; /* Overlap border with chat area for seamless alignment */
}

.sidebar-header {
    height: 80px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: #1e1f20;
    flex-shrink: 0;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rooms-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.room-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: rgba(255, 255, 255, 0.6) !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
}

.room-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white !important;
    transform: translateX(4px);
}

.room-item.active {
    background: linear-gradient(135deg, #7b2cbf, #9d4edd);
    color: #fff !important;
    box-shadow: 0 8px 20px rgba(123, 44, 191, 0.3);
    font-weight: 600;
}

.room-actions {
    display: none;
    gap: 8px;
}

.room-item:hover .room-actions {
    display: flex;
}

.room-action-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
    font-size: 1rem;
}

.room-action-btn:hover { color: #fff; }

.create-room {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
    background: transparent;
    flex-shrink: 0;
}

.create-room input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0 14px;
    border-radius: 12px;
    width: 100%;
    font-size: 0.9rem;
    height: 44px;
    transition: all 0.2s;
    outline: none;
}
.create-room input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.create-room button {
    height: 44px;
    width: 44px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.create-room button:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.sidebar-profile-btn:hover {
    background: rgba(157, 78, 221, 0.2) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(157, 78, 221, 0.2);
}

.create-room input:focus {
    border-color: var(--primary);
}

.create-room button {
    width: 42px;
    height: 42px;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    border-radius: 12px;
    background: #fff; /* White button as per screenshot */
    color: #000;
    border: none;
    cursor: pointer;
    transition: transform 0.1s;
}

.create-room button:active {
    transform: scale(0.95);
}

/* Chat Header */
.chat-header {
    height: 80px;
    padding: 0 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.chat-header h3 {
    margin: 0;
    font-weight: 500;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
}

.logout-btn {
    text-decoration: none;
    color: #ff6b6b;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
    padding: 6px 12px;
    border-radius: 8px;
}

.logout-btn:hover {
    background: rgba(255, 107, 107, 0.1);
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    width: 100%;
    margin-bottom: 5px;
}

.message-row.sent {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.avatar-container {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.avatar-container .status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border: 2px solid #1e1e1e;
    margin: 0;
    z-index: 5;
}

.msg-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}

.message {
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
    animation: messageIn 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

@keyframes messageIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.message.sent {
    background: var(--msg-sent-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received {
    background: var(--msg-received-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--glass-border);
}

.user-name {
    font-size: 0.75rem !important;
    opacity: 0.8;
    margin-bottom: 4px;
    display: block;
}

.meta {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 6px;
    text-align: right;
}

/* Custom Audio Player */
.custom-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 14px 8px 8px; /* Extra padding right for time */
    border-radius: 50px;
    margin-top: 6px;
    width: 240px;
    border: 1px solid var(--glass-border);
    transition: background 0.3s;
}

.custom-audio-player:hover {
    background: rgba(0, 0, 0, 0.35);
}

.audio-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: none;
    color: var(--primary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.audio-btn:hover {
    transform: scale(1.05);
    background: #f0f0f0;
}

.audio-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    margin-left: 2px; /* Visual center adjustment for play icon */
}

.audio-btn.playing svg {
    margin-left: 0; /* Center pause icon */
}

.audio-track {
    flex-grow: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.audio-progress {
    height: 100%;
    background: white;
    width: 0%;
    border-radius: 10px;
    transition: width 0.1s linear;
}

.audio-time {
    font-size: 0.7rem;
    font-family: monospace;
    opacity: 0.8;
    color: white;
    min-width: 35px;
    text-align: right;
}

/* Input Area */
.input-area {
    height: 96px;
    padding: 0 2rem;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 12px;
    align-items: center;
    align-items: center;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    position: relative; /* For typing indicator & recording overlay */
    flex-shrink: 0;
}

.recording-overlay {
    position: absolute;
    left: 45px;
    right: 120px; /* Space for buttons */
    height: 100%;
    display: flex;
    align-items: center;
    color: #ff4757;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.recording-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.rec-dot {
    width: 12px;
    height: 12px;
    background-color: #ff4757;
    border-radius: 50%;
    margin-right: 10px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.input-area input {
    flex-grow: 1;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 12px 20px;
    color: white;
    font-family: inherit;
    transition: all 0.3s;
}

.input-area input.recording {
    color: transparent;
    background: rgba(40, 0, 0, 0.3);
    border-color: rgba(255, 71, 87, 0.3);
}

.input-area input.recording::placeholder {
    color: transparent;
}

.input-area input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(157, 78, 221, 0.2);
}

.icon-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.icon-btn:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

.icon-btn:active {
    transform: scale(0.95);
}

#recordBtn {
    background: #ff4757;
}

#recordBtn:hover {
    background: #ff6b81;
}

#recordBtn.recording {
    animation: pulseRecord 1s infinite;
    background: #ff0000;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

#photoBtn {
    background: #0984e3;
}
#photoBtn:hover {
    background: #74b9ff;
}

@keyframes pulseRecord {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Typing Indicator */
.typing-indicator {
    position: absolute;
    top: -30px;
    left: 40px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    animation: fadePulse 1.5s infinite;
}

.typing-indicator.hidden {
    display: none;
}

@keyframes fadePulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Auth Pages Specific */
.link {
    text-align: center;
    margin-top: 1.5rem;
}

.link a {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 600;
}

form button {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
    margin-top: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

form button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

form input {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 14px 18px;
    border-radius: 12px;
    width: 100%;
    margin-bottom: 15px;
    text-align: left; /* Keep text left-aligned inside inputs */
    font-size: 0.95rem;
}

form label {
    text-align: left;
    display: block;
    width: 100%;
}

/* Fix for Autofill causing white blocks */
form input:-webkit-autofill,
form input:-webkit-autofill:hover, 
form input:-webkit-autofill:focus, 
form input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #2a2a2a inset !important;
    -webkit-text-fill-color: white !important;
    border-radius: 10px;
    transition: background-color 5000s ease-in-out 0s;
}

form input:focus {
    border-color: var(--primary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile Components */
.mobile-menu-btn { display: none; margin-right: 15px; background: transparent; border: none; color: #fff; cursor: pointer; }
.mobile-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 90;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.mobile-overlay.active { 
    opacity: 1; 
    pointer-events: auto;
}

/* ... Mobile Responsive Adjustments ... */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding: 0;
        height: 100dvh; /* Dynamic viewport height to fix mobile UI issues */
    }

    .auth-container {
        width: 100%;
        height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 2rem;
    }

    .app-layout {
        width: 100%;
        height: 100dvh;
        max-width: 100%;
        border-radius: 0;
        border: none;
        flex-direction: column;
    }

    /* Off-Canvas Sidebar Logic */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 300px;
        height: 100dvh;
        background: #18191a; 
        z-index: 100;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid rgba(255,255,255,0.1);
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .sidebar.active {
        left: 0;
        z-index: 2000; /* Ensure strictly above everything */
    }
    
    .mobile-menu-btn { display: flex; }

    .sidebar-header {
        padding: 20px;
    }

    .rooms-list {
        padding: 10px;
    }

    .messages-area {
        padding: 15px;
        gap: 15px;
    }

    .message {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 0.9rem;
        border-radius: 16px;
    }

    /* Header Cleanup for Mobile */
    .desktop-only { display: none !important; }
    .header-controls { display: flex !important; margin-right: 0 !important; }
    .welcome-text { display: none !important; }
    .header-profile-badge { display: none !important; }
    .header-user-info { margin-bottom: 0 !important; }
    
    /* Compact buttons for mobile header */
    #toggleBotBtn, #editRoomBtn {
        padding: 6px 10px !important;
        font-size: 0.7rem !important;
        margin-right: 5px !important;
    }
    
    .mobile-only-controls { display: block !important; }

    .msg-avatar {
        width: 32px;
        height: 32px;
    }

    .avatar-container {
        width: 32px;
        height: 32px;
    }

    .input-area {
        width: 100%;
        box-sizing: border-box;
        padding: 0 10px;
        gap: 5px;
        background: #1a1a1a;
        height: 75px;
        overflow: hidden; /* Prevent any accidental shifts */
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    .icon-btn svg {
        width: 18px;
        height: 18px;
    }

    .input-area input {
        padding: 10px 12px;
        font-size: 15px;
        border-radius: 20px;
        height: 40px;
        min-width: 0; /* Allow input to shrink to fit */
        flex-grow: 1;
    }

    .recording-overlay {
        left: 5px;
        right: 5px;
        width: auto;
        font-size: 0.8rem;
    }

    .custom-audio-player {
        min-width: 160px;
        max-width: 100%;
    }

    .sidebar-footer {
        height: auto !important;
        padding: 20px 15px;
    }
}

/* Reply Feature */
.reply-preview-bar {
    background: #1e1e1e;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    z-index: 10;
    transform: translateY(100%);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.reply-preview-bar.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.reply-info {
    font-size: 0.9rem;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.reply-info strong {
    color: #00b4d8; /* Secondary color (Blue) */
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.close-reply {
    cursor: pointer;
    padding: 8px;
    color: #a0a0a0;
    transition: color 0.2s;
    font-size: 1.2rem;
    line-height: 1;
}

.close-reply:hover { color: #fff; }

.quote-block {
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border-left: 4px solid #00b4d8;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    margin-top: 2px;
}

.quote-block strong {
    color: #00b4d8;
    font-size: 0.75rem;
    margin-bottom: 2px;
    font-weight: 600;
}

.quote-block span {
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message.sent .quote-block {
    background: rgba(0, 0, 0, 0.15);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.message.sent .quote-block strong {
    color: rgba(255, 255, 255, 0.8);
}

.message.replying {
    animation: highlightPulse 1s;
}

@keyframes highlightPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}
/* Online Status */
.online-status {
    font-size: 0.8rem;
    margin-top: 4px;
    opacity: 0.9;
    transition: all 0.3s;
}




/* Sidebar Sidebar */
.room-action-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    padding: 4px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.room-action-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

.sidebar-footer {
    height: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    opacity: 0.8;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    display: block;
    margin-bottom: 15px;
    opacity: 0.7;
    transition: all 0.2s;
    font-weight: 500;
}

.footer-link:hover {
    opacity: 1;
    color: #fff;
    transform: translateY(-1px);
}

.admin-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    display: block;
    margin-top: 5px;
    font-size: 0.8rem;
    transition: all 0.2s;
    padding: 6px 12px;
    background: rgba(157, 78, 221, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(157, 78, 221, 0.2);
}

.admin-link:hover {
    background: rgba(157, 78, 221, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.create-room input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* Desktop Force Visibility */
@media (min-width: 769px) {
    .sidebar {
        position: relative !important;
        left: 0 !important;
        display: flex !important;
        width: 260px !important;
    }
    .mobile-menu-btn, .mobile-overlay {
        display: none !important;
    }
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #bbb;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.status-dot.online {
    background-color: #4cd137;
    box-shadow: 0 0 10px rgba(76, 209, 55, 0.5);
}

/* Improved Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px); /* Stronger blur for focus */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.4s ease;
}

/* Spectacular Profile Card */
.profile-card {
    background: rgba(30, 30, 30, 0.6); /* Glassy base */
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3rem 2.5rem;
    border-radius: 30px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    position: relative;
    box-shadow: 
        0 20px 50px rgba(0,0,0,0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset; /* Inner light rim */
    animation: cardSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: linear-gradient(145deg, rgba(40,40,40,0.7), rgba(20,20,20,0.8));
}

/* Gradient Top Border Effect */
.profile-card::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    filter: blur(2px);
}

/* Avatar Glow in Modal */
.profile-card img#profile-preview {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.profile-card img#profile-preview:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(157, 78, 221, 0.4) !important;
}

/* Custom File Upload Label */
.profile-card label[for="avatar-input"] {
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.profile-card label[for="avatar-input"]:hover {
    transform: scale(1.1);
    background: #fff !important;
    color: var(--primary) !important;
}

@keyframes cardSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal:hover {
    background: rgba(255, 69, 58, 0.2);
    color: #ff453a;
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    display: block;
    text-align: center;
    text-decoration: none;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(157, 78, 221, 0.3);
}

.profile-card h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Message Options Bottom Sheet */
.msg-options-sheet {
    background: rgba(30, 30, 30, 0.98);
    backdrop-filter: blur(15px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.opt-btn button {
    transition: transform 0.2s, background 0.2s;
}
.opt-btn button:active {
    transform: scale(0.9);
}

/* Inline Editing */
.inline-edit-area {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
    padding: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 60px;
    margin-bottom: 8px;
    outline: none;
}
.inline-edit-area:focus {
    border-color: var(--primary);
}

.inline-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.inline-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

.inline-btn-save {
    background: var(--primary);
    color: white;
}
.inline-btn-cancel {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* Fix Header Controls & Icon Buttons */
.header-controls {
    display: flex;
    align-items: center;
    gap: 8px; 
}

.icon-only-btn {
    background: transparent !important;
    border: none !important;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    box-shadow: none !important; /* Remove any default shadow */
}

.icon-only-btn:hover {
    background: rgba(255,255,255,0.1) !important;
    color: #fff;
    transform: scale(1.05);
}

.icon-only-btn:active {
    transform: scale(0.95);
}

/* Fix Profile Image inside button */
.icon-only-btn img {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Reset specific overrides if needed */
#toggleBotBtn {
    background: rgba(255,255,255,0.1) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    font-size: 0.75rem !important;
    padding: 6px 12px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    height: auto !important;
    width: auto !important;
}
#toggleBotBtn:hover {
    background: rgba(255,255,255,0.2) !important;
}
@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Audio Call Styles */
.call-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.call-modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 24px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.caller-info {
    margin-bottom: 30px;
}

.caller-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    border: 4px solid rgba(157, 78, 221, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.caller-info h3 {
    font-size: 1.5rem;
    margin: 0 0 10px 0;
    color: #fff;
}

.caller-info p {
    color: var(--text-secondary);
    margin: 0;
}

.calling-animation {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9d4edd, #7b2cbf);
    animation: pulse 1.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.calling-animation::before {
    content: '📞';
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.call-timer {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
}

.call-actions, .call-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.call-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.call-btn svg {
    width: 28px;
    height: 28px;
}

.accept-btn {
    background: linear-gradient(135deg, #32d74b, #248a3d);
    color: #fff;
}

.accept-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(50, 215, 75, 0.4);
}

.reject-btn {
    background: linear-gradient(135deg, #ff453a, #d32f2f);
    color: #fff;
}

.reject-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(255, 69, 58, 0.4);
}

.end-btn {
    background: linear-gradient(135deg, #ff453a, #d32f2f);
    color: #fff;
}

.end-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(255, 69, 58, 0.4);
}

.mute-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.mute-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mute-btn.muted {
    background: linear-gradient(135deg, #ff453a, #d32f2f);
    border-color: transparent;
}

.mute-btn.muted:hover {
    box-shadow: 0 8px 24px rgba(255, 69, 58, 0.4);
}

/* Audio call button in profile */
.audio-call-btn {
    background: linear-gradient(135deg, #32d74b, #248a3d);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    margin-top: 15px;
}

.audio-call-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(50, 215, 75, 0.3);
}

.audio-call-btn svg {
    width: 20px;
    height: 20px;
}

/* Notification animations */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Fix Mobile Sidebar Scrolling */
@media (max-width: 768px) {
    .sidebar {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        height: 100vh !important; /* Use viewport height */
    }
    
    .sidebar-header {
        flex-shrink: 0; /* Header stays at top */
    }
    
    .rooms-list {
        overflow-y: visible !important; /* Allow sidebar to scroll */
        height: auto !important;
        flex: none !important;
    }

}

/* Compact Profile Modal for Mobile */
@media (max-width: 480px) {
    .profile-card {
        width: 90% !important;
        padding: 1.2rem !important;
        margin-top: 20px;
    }
    
    /* Override inline styles for avatar */
    #profile-preview, 
    #view-profile-avatar,
    #new-room-preview,
    .profile-card img {
        width: 80px !important;
        height: 80px !important;
    }
    
    /* Name and header */
    #self-name-display,
    #view-profile-name {
        font-size: 1.2rem !important;
    }
    
    .profile-card h2 {
        font-size: 1.2rem;
        margin-bottom: 15px !important;
    }
    
    /* Form elements */
    .profile-card input[type="text"],
    .profile-card input[type="email"],
    .profile-card input[type="password"] {
        padding: 8px 12px !important;
        font-size: 0.9rem !important;
    }
    
    .profile-card .btn,
    .profile-card a.btn-secondary {
        padding: 10px !important;
        font-size: 0.95rem !important;
    }
    
    /* Adjust spacing */
    .profile-card > div {
        margin-bottom: 15px !important;
    }
    
    /* Camera icon for upload */
    label[for="avatar-input"],
    label[for="newRoomAvatar"] {
        width: 30px !important;
        height: 30px !important;
        font-size: 1rem !important;
    }
}

/* Video Note Preview */
.video-preview-container {
    position: fixed;
    bottom: 140px; /* Moved up above the button */
    right: 20px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    z-index: 2000;
    border: 3px solid #ff3b30;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    display: none; /* Hidden by default */
    background: #000;
    transition: all 0.2s ease;
}
.video-preview-container.visible {
    display: block;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.video-preview-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror effect */
}

/* Video Note Message Bubble */
.message-video-note {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    background: #000;
    margin: 5px 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 4px solid var(--primary); /* Optional border */
}
.message-video-note video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Video Progress Ring */
.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.1s linear;
    transform-origin: 50% 50%;
    stroke: #0a84ff; /* Primary color */
    stroke-linecap: round;
}

/* Recording UI */
.recording-ui {
    position: absolute;
    left: 20px; 
    right: 80px; /* Leave space for record button */
    top: 50%;
    transform: translateY(-50%);
    background: #202020;
    display: flex; /* controlled by inline style */
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    height: 52px;
    border-radius: 26px;
    z-index: 100;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,59,48,0.3);
}

.recording-ui .rec-status {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ff3b30;
    font-weight: 700;
    font-size: 1rem;
    font-family: monospace;
}

.recording-ui #cancelRecBtn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex; 
    align-items: center; 
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.2s;
}

.recording-ui #cancelRecBtn:hover {
    background: rgba(255,59,48,0.2);
    color: #ff3b30;
}

/* Reply Preview */
.reply-preview {
    background: rgba(157, 78, 221, 0.1);
    border-left: 3px solid var(--primary);
    padding: 10px 15px;
    margin: 0 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.reply-content {
    flex: 1;
    min-width: 0;
}

.reply-label {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 4px;
}

.reply-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cancel-reply-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.cancel-reply-btn:hover {
    background: rgba(255, 59, 48, 0.2);
    color: #ff3b30;
}

/* ===== SIDEBAR FOOTER STYLES ===== */
.sidebar-footer {
    margin-top: auto;
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.sidebar-footer .footer-link:hover {
    background: rgba(255,255,255,0.08) !important;
    color: rgba(255,255,255,0.95) !important;
    transform: translateX(3px);
}

.sidebar-footer .admin-link:hover {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.25), rgba(75, 0, 130, 0.25)) !important;
    border-color: rgba(138, 43, 226, 0.5) !important;
    color: rgba(186, 85, 211, 1) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(138, 43, 226, 0.3);
}

.sidebar-footer .copyright-text {
    user-select: none;
}

/* Language Switcher in Footer */
.sidebar-footer .lang-switcher {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sidebar-footer .lang-switcher a {
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.sidebar-footer .lang-switcher a:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.8);
    border-color: rgba(255,255,255,0.1);
}

.sidebar-footer .lang-switcher a.active {
    background: linear-gradient(135deg, rgba(157, 78, 221, 0.2), rgba(123, 44, 191, 0.2));
    color: rgba(157, 78, 221, 1);
    border-color: rgba(157, 78, 221, 0.3);
}
