/**
 * Critical Layout Fixes for Klick-Game
 * Addresses: page title width, background, footer, sidebar layout
 */

/* ===== BACKGROUND FIX - ALWAYS VISIBLE, STRETCHED ===== */
html {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #2a2a2a;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-image: url('/images/body-bg.jpg') !important;
    background-attachment: fixed !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
    -webkit-background-size: cover !important;
    -moz-background-size: cover !important;
    -o-background-size: cover !important;
    background-color: #2a2a2a !important;
}

/* ===== PAGE TITLE WIDTH FIX ===== */
.site-header {
    width: 100%;
    max-width: 90rem;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Ensure main title matches content width */
.main-title-container {
    width: 100%;
    max-width: 90rem;
    margin: 0 auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

/* ===== FOOTER FIX ===== */
.site-footer {
    background: linear-gradient(135deg, #021B40 0%, #021530 50%, #021B40 100%) !important;
    border: 1px solid #ff6600;
    border-radius: 12px 12px 0 0;
    opacity: 0.95 !important;
    backdrop-filter: blur(5px);
    padding: 1.5rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 90rem;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.site-footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-footer-content .fleft {
    color: #BAB3B4;
    font-size: 0.875rem;
}

.site-footer-url {
    color: #BAB3B4;
    font-size: 0.875rem;
}

.site-footer-url a {
    color: #ff6600;
    text-decoration: none;
    transition: color 0.3s ease;
}

.site-footer-url a:hover {
    color: #ff9900;
}

/* ===== SIDEBAR LAYOUT FIX ===== */
.site-content {
    display: grid;
    grid-template-columns: minmax(12rem, 15rem) 1fr minmax(12rem, 15rem);
    grid-template-areas: "left main right";
    gap: 1rem;
    margin: 0 auto;
    width: 100%;
    max-width: 90rem;
    padding: 0 1rem;
    min-height: calc(100vh - 20rem);
    align-items: start;
    box-sizing: border-box;
}

.site-content-left {
    grid-area: left;
    min-width: 0;
}

.site-content-main {
    grid-area: main;
    min-width: 0;
    max-width: 100%;
}

.site-content-right {
    grid-area: right;
    min-width: 0;
}

/* Ensure sidebars stay in position on desktop */
@media (min-width: 1201px) {
    .site-content-left,
    .site-content-right {
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
        overflow-x: hidden;
        align-self: start;
    }
    
    /* Scrollbar styling */
    .site-content-left::-webkit-scrollbar,
    .site-content-right::-webkit-scrollbar {
        width: 0.375rem;
    }
    
    .site-content-left::-webkit-scrollbar-track,
    .site-content-right::-webkit-scrollbar-track {
        background: #2a2a2a;
    }
    
    .site-content-left::-webkit-scrollbar-thumb,
    .site-content-right::-webkit-scrollbar-thumb {
        background: #595959;
        border-radius: 0.1875rem;
    }
    
    .site-content-left::-webkit-scrollbar-thumb:hover,
    .site-content-right::-webkit-scrollbar-thumb:hover {
        background: #726B6C;
    }
}

/* ===== RESPONSIVE: TABLET AND MOBILE ===== */
@media (max-width: 1200px) {
    .site-content {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "left"
            "main"
            "right";
        gap: 1rem;
    }
    
    .site-content-left,
    .site-content-right {
        position: relative;
        width: 100%;
        max-width: 100%;
        max-height: none;
    }
    
    .site-content-main {
        width: 100%;
        max-width: 100%;
    }
}

/* ===== HOME PAGE LOGIN SPACING FIX ===== */
.home-login-container {
    margin: 0 auto;
    max-width: 600px;
    padding: 0;
}

.home-login-container h3 {
    margin-bottom: 0.75rem;
    margin-top: 0;
}

.home-login-container form {
    margin: 0;
}

/* Remove unnecessary spacing on home page */
.row[style*="margin-bottom: 1rem"] {
    margin-bottom: 0.5rem !important;
}

/* ===== NEWS BORDERS ON HOME PAGE ===== */
.news-item,
.news-container,
.home-news {
    border: 1px solid #ff6600;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: rgba(114, 107, 108, 0.1);
}

/* ===== STATUSBAR TEXT OVERFLOW FIX ===== */
.statusbar,
.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.statusbar > div,
.status-bar > div {
    min-width: 0;
    flex: 0 0 auto;
}

.statusbar img,
.status-bar img {
    vertical-align: middle;
    margin-right: 0.25rem;
}

.statusbar span,
.status-bar span {
    display: inline-block;
    margin-right: 0.5rem;
}

/* Prevent "Bugs" text from overflowing */
.status-bugs,
.statusbar .bugs-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== CONTAINER CONSISTENCY ===== */
.container {
    width: 100%;
    max-width: 90rem;
    margin: 0 auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

/* ===== SIDEBAR LINE BREAKS FIX ===== */
.sidebar-items-left a,
.sidebar-items-right a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.sidebar-items-left img,
.sidebar-items-right img {
    flex-shrink: 0;
    vertical-align: middle;
}

.sidebar-num {
    display: inline;
    margin-left: auto;
}

/* Ensure icons and numbers stay on same line */
.sidebar-items-left div,
.sidebar-items-right div {
    display: flex;
    align-items: center;
    padding: 0.1875rem 0.625rem;
}

.sidebar-items-left div a,
.sidebar-items-right div a {
    flex: 1;
    min-width: 0;
}

/* ===== MOBILE FOOTER FIX ===== */
@media (max-width: 768px) {
    .site-footer {
        border-radius: 8px 8px 0 0;
        padding: 1rem;
    }
    
    .site-footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .site-footer-url {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
}

/* ===== WRAPPER FOR ENTIRE SITE ===== */
.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-wrapper .site-content {
    flex: 1;
}

.site-wrapper .site-footer {
    margin-top: auto;
}

/* ===== Z-INDEX MANAGEMENT ===== */
.site-header {
    z-index: 100;
}

.site-content {
    z-index: 10;
}

.site-footer {
    z-index: 50;
}
