:root {
    --primary-color: #ff5722; /* MudRunner style orange */
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --bg-sidebar: #181818;
    --text-main: #e0e0e0;
    --text-secondary: #aaaaaa;
}

/* Search Suggestions */
#search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #252525;
    border: 1px solid #333;
    border-top: none;
    z-index: 1000;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: none;
}
.suggestion-item {
    display: flex;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #303030;
    color: #ccc;
}
.suggestion-item:last-child {
    border-bottom: none;
}
.suggestion-item:hover {
    background-color: var(--primary-color);
    color: #fff;
}
.cursor-pointer { cursor: pointer; }
.hover-bg-dark:hover { background-color: rgba(255,255,255,0.1); }
.suggestion-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 10px;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Roboto', sans-serif;
}

/* Navbar */
.navbar {
    background-color: rgba(30, 30, 30, 0.95) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #333;
}
.navbar-brand {
    font-weight: 700;
    color: var(--primary-color) !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-sidebar);
    border-radius: 8px;
    padding: 20px;
    position: sticky;
    top: 80px;
}
.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #fff;
    border-left: 3px solid var(--primary-color);
    padding-left: 10px;
}

/* Filter Links */
.filter-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 8px 10px;
    border-radius: 5px;
    transition: all 0.2s;
    cursor: pointer;
}
.filter-link:hover, .filter-link.active {
    background-color: #2a2a2a;
    color: #fff;
    padding-left: 15px;
}

/* Outline Accent */
.sidebar-title-accent {
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 8px 15px;
    background: linear-gradient(90deg, rgba(255, 87, 34, 0.1) 0%, rgba(255, 87, 34, 0) 100%);
    margin-bottom: 10px;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* Scrollable lists */
.scrollable-list {
    max-height: 140px; /* ~3.5 items (40px per item) */
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom scrollbar class for reuse */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}

/* Horizontal Scroll Carousel */
.horizontal-scroll-container {
    display: flex;
    flex-wrap: nowrap; /* Explicitly prevent wrapping */
    overflow-x: auto;
    gap: 15px;
    padding-bottom: 15px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}
.horizontal-scroll-container::-webkit-scrollbar {
    height: 6px;
}
.horizontal-scroll-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
.horizontal-scroll-container::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 4px;
}
.horizontal-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}
.news-card-wrapper {
    flex: 0 0 auto;
    width: 280px;
}

/* Cards */
.mod-card {
    background-color: var(--bg-card);
    border: none;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
}
.mod-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 87, 34, 0.2);
}
.card-img-wrapper {
    position: relative;
    overflow: hidden;
    height: 180px;
}
.mod-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.mod-card:hover .mod-img {
    transform: scale(1.05);
}
.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}
.card-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.4;
    color: #fff;
}
.card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.btn-details {
    margin-top: auto;
    background-color: #2a2a2a;
    color: #fff;
    border: 1px solid #333;
    width: 100%;
    border-radius: 4px;
    padding: 8px;
    transition: 0.2s;
}
.btn-details:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* Pagination */
.page-link {
    background-color: var(--bg-card);
    border-color: #333;
    color: var(--text-main);
}
.page-link:hover {
    background-color: #333;
    color: #fff;
}
.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Homepage banner (admin-managed) */
.banner-card {
    background: linear-gradient(120deg, rgba(255, 87, 34, 0.12) 0%, rgba(30, 30, 30, 0.95) 40%, rgba(30, 30, 30, 0.98) 100%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.banner-image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    overflow: hidden;
    background: #151515;
}

.banner-image {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    object-position: center;
    display: block;
}

.banner-message {
    font-size: 0.98rem;
    line-height: 1.55;
}

@media (max-width: 767.98px) {
    .banner-image {
        max-height: 360px;
    }
}

/* Modal */
.modal-content {
    background-color: #252525;
    color: #fff;
}
.modal-header, .modal-footer {
    border-color: #333;
}
.btn-download {
    background-color: var(--primary-color);
    border: none;
    padding: 10px 30px;
    font-weight: 600;
}
.btn-download:hover {
    background-color: #e64a19;
}

.loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    width: 100%;
}

/* Carousel Navigation Fix */
.carousel-control-prev-icon,
.carousel-control-next-icon {
    filter: invert(1) grayscale(100); /* Invert to white */
    background-color: rgba(0, 0, 0, 0.5); /* Dark background for contrast */
    border-radius: 50%;
    background-size: 50%;
    padding: 20px;
}
.carousel-control-prev, .carousel-control-next {
    opacity: 1; /* Always visible */
    width: 10%;
}
.carousel-control-prev:hover, .carousel-control-next:hover {
    background: rgba(0,0,0,0.2);
}

/* Games List Scrollbar */
.games-list::-webkit-scrollbar {
    width: 6px;
}
.games-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
.games-list::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 4px;
}
.games-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}

.hover-white:hover {
    color: #fff !important;
    transition: color 0.2s;
}

/* ===== NEW IMPROVEMENTS ===== */

/* Skeleton Loading */
.skeleton {
    background-color: #2a2a2a;
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200px 100%;
    background-repeat: no-repeat;
    background-position: left -200px top 0;
    animation: skeleton-loading 1.2s ease-in-out infinite;
    color: transparent !important;
    pointer-events: none;
    border-radius: 4px;
}
.skeleton-text { height: 1em; margin-bottom: 0.5rem; }
.skeleton-img { height: 100%; }

@keyframes skeleton-loading {
    100% {
        background-position: right -200px top 0;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.2s;
    z-index: 9999;
}
.back-to-top.show {
    opacity: 1;
    visibility: visible;
}
.back-to-top:hover {
    transform: translateY(-5px);
    background-color: #e64a19;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1080;
}

/* News Modal Content Fixes */
#newsModalBody {
    overflow-x: hidden;
    color: #d0d0d0;
}
#newsModalBody img,
#newsModalBody video,
#newsModalBody iframe {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 4px;
    margin: 10px 0;
    display: block;
}
#newsModalBody figure {
    margin: 0;
    width: 100% !important;
}

/* ===== GRID / LIST VIEW ===== */
.view-mode-btn {
    border-radius: 6px;
    padding: 0 12px; /* Adjusted logic for flex centering */
    border: 1px solid #444;
    background: #1e1e1e;
    color: #888;
    transition: all 0.2s;
}
.view-mode-btn.active, .view-mode-btn:hover {
    background: #333;
    color: #fff;
    border-color: #555;
}
.view-mode-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* LIST VIEW OVERRIDES */
#mods-container.view-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
#mods-container.view-list .col {
    width: 100% !important;
    max-width: 100% !important;
}
#mods-container.view-list .mod-card {
    display: flex;
    flex-direction: row;
    height: auto;
    min-height: 220px;
    align-items: stretch;
}
#mods-container.view-list .card-img-wrapper {
    width: 300px;
    height: auto;
    min-height: 100%;
    flex-shrink: 0;
}
#mods-container.view-list .mod-img {
    height: 100%;
}
#mods-container.view-list .card-body {
    padding: 20px;
    justify-content: flex-start;
    flex: 1;
    min-width: 0; /* Prevents overflow with truncate */
}
/* Adjust internal elements for list */
#mods-container.view-list .card-title {
    font-size: 1.4rem;
    margin-bottom: 5px;
}
#mods-container.view-list .small.text-secondary {
    font-size: 0.95rem;
    margin-bottom: 15px;
}
/* Default hidden in grid, shown in list */
.mod-desc-preview {
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Show 3 lines in grid */
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #999;
    font-size: 0.9rem;
    margin-bottom: 10px;
    line-height: 1.4;
}
#mods-container.view-list .mod-desc-preview {
    -webkit-line-clamp: 6; /* Show more lines to fill the space as requested */
    line-clamp: 6;
    color: #ccc;
    font-size: 1rem;
    margin-bottom: auto; /* Push meta/buttons down */
    line-height: 1.5;
}
#mods-container.view-list .card-meta {
    font-size: 0.95rem;
    padding-top: 15px;
    border-top: 1px solid #333;
    margin-top: 15px;
    
    /* Full width adjustment ignoring parent padding */
    width: calc(100% + 40px);
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    
    /* Extra space on right */
    padding-right: 20px;
    box-sizing: border-box;
}
#mods-container.view-list .btn-details {
    display: none;
}

/* Mobile adaptation for list view */
@media (max-width: 768px) {
    #mods-container.view-list .mod-card {
        flex-direction: column;
    }
    #mods-container.view-list .card-img-wrapper {
        width: 100%;
        height: 200px;
    }
    #mods-container.view-list .btn-details {
        display: block;
        width: 100%;
    }
}


/* Top Mods Widget Tabs */
#topModsTab .nav-link {
    color: var(--text-secondary);
    border: none;
    border-radius: 0;
    transition: color 0.2s;
}

#topModsTab .nav-link:hover {
    color: #fff;
}

#topModsTab .nav-link.active {
    color: var(--primary-color) !important;
    background-color: transparent !important;
    border-bottom: 2px solid var(--primary-color) !important;
}
