/**
 * Responsive Overrides - DBC StreetView
 * Mobile (<576px), Tablet (576-991px), Desktop (>=992px unchanged)
 */

/* ============================================
 * 1. SIDEBAR - Off-canvas on mobile/tablet
 * ============================================ */

@media (max-width: 991px) {
    .sidebar {
        position: fixed !important;
        top: 0;
        left: -320px;
        width: 280px !important;
        height: 100vh !important;
        z-index: 1050;
        background: #fff;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.15);
        padding-top: 70px !important;
        overflow-y: auto;
        /* Remove from flow so main content takes full width */
        flex: 0 0 0px !important;
        max-width: 0px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .sidebar.show {
        left: 0;
        width: 280px !important;
        max-width: 280px !important;
        flex: 0 0 280px !important;
        overflow: visible;
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        z-index: 1040;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .sidebar-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: transparent;
        color: #333;
        font-size: 1.25rem;
        cursor: pointer;
        padding: 0;
    }

    .col-md-9,
    .col-md-8 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    .col-lg-9,
    .col-lg-10 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    .row.flex-nowrap {
        flex-wrap: wrap !important;
    }
}

@media (min-width: 992px) {
    .sidebar-toggle {
        display: none !important;
    }

    .sidebar-backdrop {
        display: none !important;
    }
}


/* ============================================
 * 2. TABLES - Card layout on mobile
 * ============================================ */

@media (max-width: 767px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .filter-controls {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .filter-controls .form-select,
    .filter-controls .input-group {
        width: 100% !important;
    }

    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}


/* ============================================
 * 3. LOGIN PAGE
 * ============================================ */

@media (max-width: 575px) {
    .background-image {
        padding: 10px !important;
        background-attachment: scroll !important;
    }

    .login-card .card-body {
        padding: 1.25rem !important;
    }

    .login-card h3 {
        font-size: 1.25rem;
    }
}


/* ============================================
 * 4. ADMIN PAGE
 * ============================================ */

@media (max-width: 767px) {
    .stats-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem;
    }

    .stats-row .col-md-3 {
        width: 100% !important;
        max-width: 100% !important;
        flex: unset !important;
        padding: 0 !important;
    }

    .action-btn {
        width: 32px !important;
        height: 32px !important;
    }
}


/* ============================================
 * 5. SETTINGS PAGE
 * ============================================ */

@media (max-width: 767px) {
    .bd-settings-main {
        padding: 0 10px !important;
    }

    .profile-header {
        flex-direction: column !important;
        text-align: center;
    }

    .profile-header .user-initials {
        margin: 0 auto 1rem auto;
    }
}


/* ============================================
 * 6. INTERNAL/DASHBOARD PAGE
 * ============================================ */

@media (max-width: 575px) {
    .row-cols-md-3 > * {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .card {
        margin-bottom: 0.75rem !important;
    }
}


/* ============================================
 * 7. PROJECT EDITOR - Mobile hint banner
 * ============================================ */

.editor-mobile-hint {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f59e0b;
    color: #1a1a1a;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.8rem;
    z-index: 9999;
    font-weight: 600;
}

@media (max-width: 767px) {
    .editor-mobile-hint {
        display: block;
    }

    .editor-header {
        margin-top: 36px;
    }

    .editor-sidebar {
        position: fixed !important;
        left: -320px;
        top: 54px;
        width: 280px !important;
        height: calc(100vh - 54px);
        z-index: 1050;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .editor-sidebar.show {
        left: 0;
    }

    .editor-sidebar-backdrop {
        display: none;
        position: fixed;
        top: 54px;
        left: 0;
        width: 100%;
        height: calc(100vh - 54px);
        background: rgba(0,0,0,0.4);
        z-index: 1040;
    }

    .editor-sidebar-backdrop.show {
        display: block;
    }

    .toolbar-text {
        display: none !important;
    }

    .editor-toolbar .btn {
        padding: 6px 10px !important;
        font-size: 0.85rem;
    }

    .editor-main {
        width: 100% !important;
        margin-left: 0 !important;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .editor-sidebar {
        width: 260px !important;
    }

    .editor-main {
        margin-left: 260px !important;
    }
}


/* ============================================
 * 8. VIEWER - Mobile optimizations
 * ============================================ */

@media (max-width: 767px) {
    .viewer-top-bar,
    #pano > div:first-child {
        padding: 5px 10px !important;
    }

    .viewer-top-bar .btn,
    #pano > div:first-child .btn {
        padding: 4px 8px !important;
        font-size: 0.8rem;
    }

    #sceneList {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 50vh !important;
        border-radius: 12px 12px 0 0;
        transform: translateY(100%) !important;
    }

    #sceneList.enabled {
        transform: translateY(0) !important;
    }

    #sceneList::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255,255,255,0.3);
        border-radius: 2px;
        margin: 8px auto;
    }

    #miniMap {
        left: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
        width: auto !important;
        height: 180px !important;
    }

    .viewControlButton {
        display: none !important;
    }
}

@media (max-width: 480px) {
    #sceneList {
        max-height: 40vh !important;
    }

    #miniMap {
        height: 140px !important;
    }

    .viewer-logo img {
        height: 24px !important;
    }
}


/* ============================================
 * 9. GENERAL TOUCH TARGETS
 * ============================================ */

@media (max-width: 991px) {
    .btn, .nav-link, .form-select, .form-control {
        min-height: 44px;
    }

    .nav-link {
        padding: 0.625rem 1rem !important;
    }

    .card {
        margin-bottom: 1rem;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }
}


/* ============================================
 * 10. OVERVIEW PAGE
 * ============================================ */

@media (max-width: 767px) {
    .overview-grid {
        grid-template-columns: 1fr !important;
    }

    .chat-section {
        width: 100% !important;
    }

    .accordion-body {
        padding: 0.75rem !important;
    }
}


/* ============================================
 * 11. COOKIE CONSENT BANNER
 * ============================================ */

@media (max-width: 575px) {
    #cookieConsent {
        padding: 15px !important;
    }

    #cookieConsent .row {
        flex-direction: column;
    }

    #cookieConsent .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}
