/* Mobile Improvements */

/* Default Hidden (Desktop) */
.mobile-bottom-nav {
    display: none;
}

/* 1. Sticky Bottom Navigation Bar */
@media (max-width: 768px) {

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background-color: #121212 !important;
    }

    body {
        margin: 0 !important;
        padding: 0 !important;
        padding-bottom: 60px !important;
        /* Space for the bar */
        background: #121212 url('../imgs/background.webp') no-repeat center top !important;
        background-size: cover !important;
        background-attachment: fixed !important;
        overflow-x: hidden;
    }

    /* Hide Header on Mobile */
    header {
        display: none !important;
    }

    /* Adjust Hero for no header */
    .hero {
        margin-top: 0 !important;
        padding-top: 0 !important;
        height: calc(100vh - 60px) !important;
        /* Full height minus bottom nav */
    }

    .mobile-bottom-nav {
        display: flex !important;
        /* Force show on mobile */
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background: rgba(20, 20, 20, 0.95);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--secondary-color);
        justify-content: space-around;
        align-items: center;
        z-index: 2000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
    }

    .nav-item {
        color: #aaa;
        text-decoration: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 0.75rem;
        transition: color 0.3s;
    }

    .nav-item i {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }

    .nav-item.active,
    .nav-item:hover {
        color: var(--secondary-color);
    }

    /* Hide standard social/menu since we have bottom bar? 
       Actually user asked for bottom bar addition, not full replacement. 
       Keeping top menu is fine, bottom is for quick actions. */
}

/* 2. Sticky Wiki Search */
.wiki-search-sticky {
    position: sticky;
    top: 72px;
    /* Below fixed header */
    z-index: 900;
    padding: 10px 5%;
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(5px);
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

@media (max-width: 768px) {
    .wiki-search-sticky {
        top: 0 !important;
        /* Start from top since header is gone */
        margin-top: 0;
        padding-top: 15px;
    }

    /* Fix Wiki Grid on Mobile */
    .wiki-grid-2col {
        grid-template-columns: 1fr !important;
        gap: 25px;
        /* Increased gap for better separation */
    }

    /* Improve Feature Box on Mobile */
    .feature-box {
        padding: 20px !important;
        background: rgba(30, 30, 30, 0.95) !important;
        border: 1px solid rgba(212, 175, 55, 0.2);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    }

    .feature-box h3 {
        text-align: center;
        border-bottom: 2px solid var(--secondary-color);
        padding-bottom: 10px;
        margin-bottom: 20px;
        font-size: 1.4rem;
        /* Make title very prominent */
    }

    /* === 1. Class HP Tables (Small Tables) === */
    /* Restore standard table look but transparent/clean */
    .feature-box .stats-table {
        background: transparent !important;
    }

    .feature-box .stats-table thead {
        display: table-header-group !important;
        /* Restore headers! */
    }

    .feature-box .stats-table tbody tr {
        display: table-row !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .feature-box .stats-table tbody td {
        display: table-cell !important;
        padding: 10px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        width: 50% !important;
        /* Split 50/50 */
    }

    .feature-box .stats-table td:first-child {
        text-align: left;
        color: var(--secondary-color);
        font-weight: bold;
    }

    .feature-box .stats-table td:last-child {
        text-align: right;
        color: #fff;
    }


    /* === 2. Big Ranking Table (The Lists) === */
    /* This needs the CARD VIEW */

    /* Target only the big table - we can distinguish by context or add a class later, 
       but for now let's use the fact it's NOT inside the .wiki-grid-2col (it's in a margin-top-30 container) */

    /* === 2. Big Ranking Table (The Lists) === */
    /* This needs the CARD VIEW */

    /* === 2. Big Ranking Table (Scrollable Matrix) === */
    /* Conceptually correct: Maintain the grid structure via standard table */

    .margin-top-30 {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-left: -15px;
        /* Pull to edge */
        margin-right: -15px;
        padding-left: 15px;
        padding-right: 15px;
    }

    .margin-top-30 .stats-table {
        min-width: 800px;
        /* Force scroll to accommodate all columns */
        background: rgba(20, 20, 20, 0.9) !important;
        border-collapse: separate;
        border-spacing: 0;
    }

    .margin-top-30 .stats-table thead {
        display: table-header-group !important;
        /* Force show headers */
    }

    .margin-top-30 .stats-table tbody tr {
        display: table-row !important;
        background: transparent !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .margin-top-30 .stats-table th,
    .margin-top-30 .stats-table td {
        display: table-cell !important;
        white-space: nowrap !important;
        padding: 12px 15px !important;
        text-align: center !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        width: auto !important;
        font-family: 'Segoe UI', sans-serif !important;
        font-size: 0.9rem !important;
    }

    /* Sticky First Column (Rank #) */
    .margin-top-30 .stats-table th:first-child,
    .margin-top-30 .stats-table td:first-child {
        position: sticky !important;
        left: 0;
        z-index: 10;
        background: rgba(30, 30, 30, 0.95) !important;
        /* Opaque bg is must */
        border-right: 2px solid var(--secondary-color);
        width: 50px !important;
        min-width: 50px !important;
        color: var(--secondary-color);
        font-weight: bold;
    }

    /* Remove card styles from Rank # */
    .margin-top-30 .stats-table tbody td:first-child {
        border-radius: 0 !important;
        margin: 0 !important;
        height: auto !important;
        box-shadow: none !important;
        border: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-right: 2px solid var(--secondary-color) !important;
        line-height: normal !important;
    }

    /* Remove attr labels */
    .margin-top-30 .stats-table tbody td::before {
        display: none !important;
    }
}

/* Character Marketplace Mobile */
@media (max-width: 768px) {
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0 10px;
    }

    .character-card {
        margin-bottom: 0;
    }

    .char-image {
        height: 140px;
    }

    .char-info h3 {
        font-size: 1rem;
    }

    .btn-details {
        font-size: 0.8rem;
        padding: 8px;
    }

    /* Modal Mobile */
    /* ... (other mobile styles keep 768px) ... */
}

/* Modal specific breakpoint - Lower to keep horizontal view on tablets */
@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .modal-left {
        border-right: none;
        padding-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 20px;
    }

    .modal-char-img {
        max-height: 200px;
    }
}