﻿/* Mobile Adaptation for GigPilot */
@media screen and (max-width: 768px) {

    /* Reset Layout */
    #app {
        display: block !important;
        height: auto;
        overflow-x: hidden;
    }

    /* Sidebar */
    aside.sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        z-index: 2000;
        transition: left 0.3s ease;
        transform: none;
        background-color: var(--bg-sidebar, #1e1e1e) !important;
        padding-top: 20px;
        pointer-events: auto !important;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.5);
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
        overflow-y: auto !important;
        /* Enable Sidebar Scrolling */
    }

    /* Force Body Scrolling */
    body,
    html {
        overflow-y: auto !important;
        height: auto !important;
    }

    aside.sidebar.active {
        left: 0;
        transform: none;
    }

    body.sidebar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    /* Main Content */
    main#main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem;
        padding-top: 70px;
        /* Space for header */
    }

    /* Mobile Header */
    .mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background-color: var(--bg-card, #252525);
        border-bottom: 1px solid var(--border, #333);
        padding: 0 1rem;
        z-index: 900;
        color: var(--text-primary, #fff);
    }

    /* Specific visibility targets */
    aside.sidebar nav li,
    aside.sidebar nav li span,
    aside.sidebar nav li i,
    aside.sidebar nav li svg {
        color: #ffffff !important;
        opacity: 1 !important;
        visibility: visible !important;
        position: relative !important;
    }

    /* Force text display */
    aside.sidebar nav li span {
        display: inline-block !important;
    }

    /* Show Sidebar Footer (Backup/Restore) */
    .sidebar-footer {
        display: block !important;
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 80px !important;
        /* Space for bottom scrolling */
    }

    .sidebar-footer button {
        width: 100%;
        margin-bottom: 10px;
        justify-content: flex-start;
        padding: 10px;
    }

    .sidebar-footer p,
    .sidebar-footer a {
        display: block;
        margin-bottom: 10px;
    }

    /* Reset container layout */
    aside.sidebar nav {
        width: 100%;
        padding: 0 !important;
        margin: 0 !important;
    }

    aside.sidebar nav ul {
        display: flex !important;
        flex-direction: column !important;
        width: 100%;
        padding: 0 !important;
        margin: 0 !important;
        list-style: none !important;
    }

    aside.sidebar nav li {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 15px 20px !important;
        /* Force padding */
        box-sizing: border-box;
        gap: 15px;
        cursor: pointer;
        margin: 0 !important;
    }

    /* Grid & Flex Adjustments */
    .dashboard-stats,
    .grid-container {
        display: grid;
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 1rem;
    }

    /* Modals */
    .modal-content {
        width: 95% !important;
        margin: 20px auto;
        max-height: 85vh;
        overflow-y: auto;
    }

    /* Tables */
    table {
        display: block;
        width: 100%;
        overflow-x: hidden;
        /* Prevent horizontal scroll */
    }

    /* Mobile Card View for Songs Table */
    #main-content table thead {
        display: none;
    }

    #main-content table tbody,
    #main-content table tr,
    #main-content table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    #main-content table tr {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 1rem;
        padding: 1rem;
        position: relative;
    }

    #main-content table td {
        padding: 0.25rem 0;
        border: none;
        background: none;
        text-align: left;
    }

    /* Title Column */
    #main-content table td:nth-of-type(1) {
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--text-primary);
        padding-bottom: 0.25rem;
    }

    /* Artist Column */
    #main-content table td:nth-of-type(2) {
        font-size: 0.9rem;
        color: var(--text-muted);
        margin-bottom: 0.5rem;
    }

    /* Key & BPM - Inline */
    #main-content table td:nth-of-type(3),
    #main-content table td:nth-of-type(4) {
        display: inline-block;
        width: auto;
        margin-right: 1.5rem;
        font-size: 0.9rem;
        background: rgba(255, 255, 255, 0.05);
        padding: 4px 8px;
        border-radius: 4px;
        color: var(--text-main);
    }

    #main-content table td:nth-of-type(3)::before {
        content: "Key: ";
        color: var(--text-muted);
    }

    #main-content table td:nth-of-type(4)::before {
        content: "BPM: ";
        color: var(--text-muted);
    }

    /* Actions Column */
    #main-content table td:nth-of-type(5) {
        margin-top: 1rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
        display: flex;
        justify-content: flex-end;
        gap: 1rem;
    }
}