/* --- FULL SCREEN OVERRIDES --- */
body {
    overflow: hidden !important; /* Prevent page scroll */
    padding-bottom: 0 !important; 
    height: 100vh;
    height: 100dvh; /* Fix for mobile browser bars */
    background-color: var(--bg);
}

/* Community Container */
.community-container {
    display: flex;
    /* PC Header is ~120px */
    height: calc(100vh - 120px);
    height: calc(100dvh - 120px); 
    margin-top: 120px; 
    padding: 20px;
    gap: 20px;
    max-width: 100%;
    box-sizing: border-box;
}

/* Sidebar (User List) */
.chat-sidebar {
    width: 280px;
    background: var(--box);
    border: 1px solid rgba(159, 0, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
}

.chat-sidebar h3 {
    margin-top: 0;
    color: #9F00FF;
    border-bottom: 1px solid rgba(159, 0, 255, 0.2);
    padding-bottom: 15px;
    flex-shrink: 0;
}

#user-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

#user-list li {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.2s;
    color: var(--text);
}

.user-status {
    width: 10px;
    height: 10px;
    background-color: #00e676;
    border-radius: 50%;
    box-shadow: 0 0 5px #00e676;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    background: var(--box);
    border: 1px solid rgba(159, 0, 255, 0.2);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    position: relative;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(159, 0, 255, 0.2);
    background: rgba(159, 0, 255, 0.05);
    flex-shrink: 0;
}

.chat-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0,0,0,0.2);
}

/* Push messages to bottom */
.chat-messages > :first-child {
    margin-top: auto; 
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar,
#user-list::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb,
#user-list::-webkit-scrollbar-thumb {
    background: #9F00FF;
    border-radius: 10px;
}

/* Message Bubbles */
.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.message.self {
    align-self: flex-end;
    background: linear-gradient(135deg, #9F00FF, #7B00C7);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(159, 0, 255, 0.2);
}

.message.other {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.message-header {
    font-size: 0.75rem;
    margin-bottom: 4px;
    opacity: 0.7;
    display: flex;
    justify-content: space-between;
    gap: 15px;
    font-weight: 600;
}

.mention-highlight {
    background-color: rgba(255, 215, 0, 0.2);
    color: #ffd700;
    font-weight: bold;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 215, 0, 0.4);
}

/* Input Area */
.chat-input-area {
    padding: 20px;
    background: var(--box);
    border-top: 1px solid rgba(159, 0, 255, 0.2);
    display: flex;
    gap: 15px;
    align-items: center;
    flex-shrink: 0;
    
    /* Ensure safe area for mobile home bars */
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

#message-input {
    flex: 1;
    padding: 15px 20px;
    border-radius: 30px;
    border: 2px solid rgba(159, 0, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    outline: none;
    font-size: 1rem;
    transition: 0.3s;
}

#message-input:focus {
    border-color: #9F00FF;
    box-shadow: 0 0 15px rgba(159, 0, 255, 0.2);
}

#send-btn {
    background: #9F00FF;
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
    font-size: 1.2rem;
    box-shadow: 0 0 10px rgba(159, 0, 255, 0.4);
}

.mention-list {
    position: absolute;
    bottom: 85px;
    left: 35px;
    background: #1a1a1a;
    border: 1px solid #9F00FF;
    border-radius: 12px;
    width: 220px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
}

.mention-item {
    padding: 10px 15px;
    cursor: pointer;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 900px) {
    .community-container {
        flex-direction: column;
        /* Use dvh to ignore address bar size */
        height: calc(100dvh - 85px); 
        margin-top: 85px;
        padding: 0; /* Remove padding to maximize space */
        gap: 0;
    }
    
    /* Compact User List */
    .chat-sidebar {
        width: 100%;
        height: 50px;
        flex-direction: row;
        align-items: center;
        padding: 0 15px;
        border: none;
        border-bottom: 1px solid rgba(159,0,255,0.2);
        background: var(--bg);
        border-radius: 0;
    }
    
    .chat-sidebar h3 {
        border: none;
        margin: 0;
        padding: 0;
        font-size: 14px;
        margin-right: 15px;
    }

    #user-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 10px;
        align-items: center;
    }

    #user-list li {
        margin: 0;
        padding: 5px 12px;
        font-size: 12px;
        white-space: nowrap;
        background: rgba(159,0,255,0.15);
        border-radius: 20px;
    }
    
    /* Maximize Chat Area */
    .chat-main {
        height: auto; 
        flex: 1;
        border-radius: 0;
        border: none;
    }

    .chat-messages {
        padding: 15px;
        padding-bottom: 10px;
        
    }
    
    /* Fix Input Area on Mobile */
    .chat-input-area {
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom)); /* iPhone Bar support */
        background: var(--box);
        z-index: 50;
    }
    
    #message-input {
        padding: 10px 15px;
        font-size: 16px; /* Prevent zoom on focus */
    }

    #send-btn {
        width: 45px;
        height: 45px;
    }
}
/* -------------------- INTERACTIVE MODULE -------------------- */

/* Main Interactive Container (Used within .container) */
.interactive-module {
    /* Uses CSS Grid for easy layout switching on mobile */
    display: grid; 
    grid-template-columns: 1fr 1fr;
    grid-gap: 50px;
    justify-content: center;
    align-items: stretch;
    padding: 50px 0;
    margin: 0 auto;
    width: 95%;
    max-width: 1400px;
}

/* Base style for the Tilted, Blurred Boxes (Interactive Box) */
.interactive-box {
    position: relative;
    padding: 50px;
    border-radius: 20px;
    
    /* Tilted effect */
    transition: transform 0.4s ease-out, box-shadow 0.4s ease-out;

    /* Glass/Blur Effect - Uses existing theme variables */
    background: var(--box);
    box-shadow: 0 0 30px rgba(159, 0, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid #9F00FF33;

    /* Content Alignment */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Hover effects */
.interactive-box:hover {
    box-shadow: 0 0 50px #9F00FF;
    border-color: #9F00FF;
}

/* Glossy highlight effect */
.interactive-box::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    pointer-events: none;
}

.interactive-box h2 {
    font-size: 36px;
    color: #9F00FF;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.interactive-box p {
    font-size: 18px;
    color: var(--text);
    opacity: 0.8;
    margin-bottom: 30px;
}

/* Animated Button (Main CTA) */
.interactive-box a.main-btn {
    padding: 15px 40px;
    background: linear-gradient(90deg, #9F00FF, #B72BFF);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 8px 20px rgba(159, 0, 255, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 10;
}

.interactive-box a.main-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 30px rgba(159, 0, 255, 0.6);
}

/* -------------------- LEFT SECTION: ARTICLES ANIMATION -------------------- */
.articles-icon-wrapper,
.community-icon-wrapper {
    position: relative;
    width: 180px;
    height: 180px;
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.articles-icon-wrapper i {
    font-size: 100px;
    color: #00e676; /* Green for articles */
    filter: drop-shadow(0 0 10px #00e67688);
}

.article-element {
    position: absolute;
    width: 50px;
    height: 6px;
    background: var(--text);
    opacity: 0.4;
    border-radius: 3px;
    animation: articleFly 10s linear infinite;
}

/* Individual Article elements positioning and animation delay */
.article-element:nth-child(2) {
    width: 30px;
    height: 4px;
    top: 10px;
    left: 20px;
    animation-delay: 2s;
}
.article-element:nth-child(3) {
    width: 70px;
    top: 50%;
    right: 10px;
    background: #9F00FF;
    animation-delay: 4s;
}
.article-element:nth-child(4) {
    width: 40px;
    height: 5px;
    bottom: 10px;
    left: 50%;
    animation-delay: 6s;
}

@keyframes articleFly {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 0.4; }
    25% { transform: translate(30px, -20px) rotate(10deg); opacity: 0.8; }
    50% { transform: translate(0, 0) rotate(0deg); opacity: 0.4; }
    75% { transform: translate(-30px, 20px) rotate(-10deg); opacity: 0.8; }
    100% { transform: translate(0, 0) rotate(0deg); opacity: 0.4; }
}
.light-mode .article-element { background: #555; }
.light-mode .article-element:nth-child(3) { background: #9F00FF; }


/* -------------------- RIGHT SECTION: COMMUNITY ANIMATION -------------------- */
.community-icon-wrapper i {
    font-size: 100px;
    color: #2979ff; /* Blue for chat */
    filter: drop-shadow(0 0 10px #2979ff88);
}

/* Chat bubble animation */
.chat-bubble {
    position: absolute;
    background: #9F00FF;
    color: white;
    font-size: 14px;
    padding: 5px 10px;
    border-radius: 15px 15px 15px 0;
    opacity: 0;
    animation: chatPop 8s infinite ease-out;
}

/* Individual Chat bubbles */
.chat-bubble:nth-child(2) {
    top: 20px;
    left: 10px;
    animation-delay: 1.5s;
    background: #00e676;
}
.chat-bubble:nth-child(3) {
    bottom: 30px;
    right: 10px;
    animation-delay: 4s;
    background: #ff9900;
    border-radius: 15px 15px 0 15px;
}
.chat-bubble:nth-child(4) {
    top: 40px;
    right: 20px;
    animation-delay: 6.5s;
    background: #ff0055;
    font-size: 20px;
    padding: 3px 8px;
}

@keyframes chatPop {
    0% { opacity: 0; transform: scale(0.5) translateY(10px); }
    10% { opacity: 1; transform: scale(1) translateY(0); }
    30% { opacity: 1; transform: scale(1); }
    40% { opacity: 0; transform: scale(0.8) translateY(-10px); }
    100% { opacity: 0; }
}
/* -------------------- FINALIZED FULLSCREEN POPUP STYLES -------------------- */

/* 1. The Fullscreen Overlay Container (Ensures it covers the screen) */
.popup {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.76);
    backdrop-filter: blur(10px);
    display: flex; 
    justify-content: center;
    align-items: center;
    z-index: 999999 !important;
    animation: fadeIn 0.3s ease; 
}

/* 2. The Pop-up Box (The centered, visible card) */
.popup-box {
    /* INCREASED DIMENSIONS */
    width: 60%; /* Wider on desktop */
    max-width: 800px; 
    height: auto; 
    max-height: 90vh; /* Taller, but limited on small screens */
    
    padding: 40px; /* More internal space */
    
    /* ALIGNMENT: CENTERED for title/buttons */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center; /* Titles and surrounding text are centered */
    
    /* THEME STYLES */
    border-radius: 20px;
    box-shadow: 0 0 30px #9F00FF;
    background: var(--box);
    color: var(--text);
    animation: zoomIn 0.3s ease;
}

/* 3. Scrollable Rules Content Container (The box inside the box) */
.popup-box .rules-content {
    max-height: 50vh; /* Increased scrollable area */
    overflow-y: auto;
    width: 100%; /* Take full width of the parent box */
    margin: 20px 0; /* Clear vertical spacing */
    padding: 10px;
    border: 1px solid #9F00FF55;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    
    /* CRITICAL FIX: Ensures the rules content is LEFT-ALIGNED */
    text-align: left !important;
    font-size: 15px;
    line-height: 3;
}

/* 4. Rules Text Element */
.popup-box .rules-content #rules-text-area {
    /* Ensures proper wrapping and left-alignment of the formatted text */
    white-space: pre-wrap; 
    word-wrap: break-word; 
    text-align: left !important;
    
    /* Remove default <pre> element margin/padding */
    font-family: inherit;
    margin: 0;
    padding: 0;
    color: var(--text);
}

/* 5. Button Container (Ensure buttons are together and centered) */
.popup-box > div:last-child {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    width: 100%; /* Optional: for better mobile centering */
}


/* -------------------- BUTTON VISUAL STYLES (Repeat for completeness) -------------------- */

.popup-box button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: 150px;
    font-size: 16px;
    transition: 0.3s;
    font-weight: bold;
    color: white !important; /* Default to white for better contrast */
}

#btn-disagree {
    background: #ff5555;
    box-shadow: 0 0 10px #ff555555;
}

#btn-agree-once {
    background: var(--box);
    border: 2px solid #9F00FF;
    color: var(--text) !important;
}

#btn-agree-save {
    background: #9F00FF;
    box-shadow: 0 0 15px #9F00FF55;
}

/* Disabled state */
.popup-box button:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    background: #333 !important;
    border-color: #555 !important;
    color: #bbb !important;
    box-shadow: none !important;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .popup-box {
        width: 95%;
        max-width: unset;
        padding: 25px;
    }
    .popup-box .rules-content {
        max-height: 55vh;
        padding: 15px;
    }
    .popup-box button {
        flex: 1;
        width: 100%;
        font-size: 14px;
        padding: 10px 15px;
    }
    /* Stack buttons if not enough room */
    .popup-box > div:last-child {
        flex-wrap: wrap; 
        gap: 10px;
    }
}
/* =======================================================
   CRITICAL FIX: VERTICAL FLOW FOR INTERACTIVE BOXES (Mobile)
   ======================================================= */
@media (max-width: 900px) {
    
    /* Target the main container wrapping the two boxes */
    .interactive-module {
        /* CRITICAL CHANGE: Sets the grid to one column */
        grid-template-columns: 1fr !important; 
        grid-gap: 30px;
        padding: 20px 0;
    }

    /* Additional cleanup for the boxes themselves */
    .interactive-box {
        transform: rotate(0deg) !important; /* Remove tilt on mobile */
        padding: 40px;
        margin-bottom: 0; /* Remove excess margin */
    }
    
    .interactive-box:hover {
        transform: scale(1.02) !important; /* Adjust hover scale for single column */
    }
}

/* -------------------------------------------------------- */