/* 1. Global Reset & Industrial Foundation */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    background-color: #050506;
    /* Cyber Grid */
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    color: #e2e8f0;
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    overflow: hidden; 
    /* FIX: Ensure body allows sidebar and main to sit side-by-side */
    display: flex;
}

/* 2. Structured Layout (The Splits) */
aside {
    width: 18rem; /* Equivalent to w-72 */
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    background: linear-gradient(to bottom, #080809, #050506);
    position: relative;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

aside::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 20%;
    height: 60%;
    width: 1px;
    background: linear-gradient(to bottom, transparent, #3b82f6, transparent);
    opacity: 0.3;
}

/* FIX: Main needs to be a flex column to hold header, chat, and footer */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    position: relative;
    transition: filter 0.5s ease; /* Smooth unblur */
}

header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(5, 5, 6, 0.85);
    backdrop-filter: blur(12px);
    position: relative;
    flex-shrink: 0; 
}

header::before {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 40px;
    height: 1px;
    background: #3b82f6;
    box-shadow: 0 0 10px #3b82f6;
}

/* 3. The Message Stream */
#chat-messages {
    flex: 1; /* Fills all available space */
    overflow-y: auto;
    min-height: 0; /* CRITICAL: Allows the flex item to shrink and scroll */
    padding: 1rem 2rem;
    mask-image: linear-gradient(to bottom, transparent 0%, black 5%, black 95%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 5%, black 95%, transparent 100%);
}

.msg-stream-item {
    padding: 1.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    position: relative;
    transition: all 0.3s ease;
}

.msg-stream-item:hover {
    background: rgba(59, 130, 246, 0.015);
}

/* 4. The Industrial Chat Box */
footer {
    padding: 24px;
    background: linear-gradient(to top, #050506 70%, transparent);
    flex-shrink: 0; 
    z-index: 10;
}

#chat-form div {
    background: #0d0d0f !important; 
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 4px !important;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
}

/* Technical Corner Accents */
#chat-form div::before, #chat-form div::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    pointer-events: none;
    transition: all 0.3s ease;
}

#chat-form div::before {
    top: -1px; left: -1px;
    border-top: 2px solid rgba(59, 130, 246, 0.3);
    border-left: 2px solid rgba(59, 130, 246, 0.3);
}

#chat-form div::after {
    bottom: -1px; right: -1px;
    border-bottom: 2px solid rgba(59, 130, 246, 0.3);
    border-right: 2px solid rgba(59, 130, 246, 0.3);
}

#chat-form div:focus-within {
    border-color: rgba(59, 130, 246, 0.5) !important;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.08);
    background: #111114 !important;
}

#chat-form div:focus-within::before, 
#chat-form div:focus-within::after {
    border-color: #3b82f6;
}

/* 5. Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
}

/* 6. Animations & Logic */
body:not(.clearance-granted) main {
    filter: blur(8px);
    pointer-events: none;
}

.staff-badge {
    background: linear-gradient(90deg, #ff4b2b, #ff416c);
    box-shadow: 0 0 15px rgba(255, 75, 43, 0.3);
}