/* ============================================
   RESPONSIVE FIXES FOR ADMIN & USER PAGES
   Mobile-First Design - All Devices
   ============================================ */

/* Mobile Menu Overlay */
@media (max-width: 767px) {
    /* Sidebar - Mobile Hidden by Default */
    .sidebar-container {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 85vw !important;
        max-width: 320px;
        height: 100vh;
        z-index: 9999;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-in-out;
        display: block;
    }
    
    .sidebar-container.mobile-open {
        transform: translateX(0) !important;
    }
    
    /* Main Content - Full Width on Mobile */
    body.has-sidebar main.sidebar-enabled,
    .has-sidebar main,
    main.sidebar-enabled,
    main {
        padding-left: 0 !important;
        width: 100% !important;
        margin-left: 0 !important;
    }
    
    /* Ensure no sidebar on public pages */
    body:not(.has-sidebar) .sidebar-container,
    body:not(.has-sidebar) aside {
        display: none !important;
    }
    
    /* Mobile Menu Toggle Button - Top Left */
    #mobileMenuBtn {
        display: flex !important;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 10000;
        width: 3rem;
        height: 3rem;
        background: linear-gradient(135deg, #0ea5e9, #6366f1);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        align-items: center;
        justify-content: center;
        color: white;
        cursor: pointer;
        box-shadow: 0 10px 30px rgba(14, 165, 233, 0.3);
        transition: all 0.2s ease-in-out;
    }
    
    #mobileMenuBtn:active {
        transform: scale(0.95);
    }
    
    /* Backdrop Overlay */
    #sidebarBackdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        z-index: 9998;
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
    }
    
    #sidebarBackdrop.active {
        display: block !important;
        opacity: 1;
    }
    
    /* Hide Desktop Toggle Button on Mobile */
    .sidebar-toggle-btn {
        display: none !important;
    }
    
    /* Adjust Main Content Padding - No sidebar padding on mobile */
    .has-sidebar main > *:first-child,
    main.sidebar-enabled > *:first-child {
        padding-top: 4.5rem !important;
    }
    
    /* Ensure full-width content */
    .has-sidebar,
    body.has-sidebar {
        overflow-x: hidden;
    }
    
    /* Force full width for all pages on mobile */
    body,
    html {
        overflow-x: hidden !important;
        width: 100vw !important;
    }
    
    /* Remove any left padding/margin on main content for mobile */
    body.has-sidebar main,
    main {
        margin-left: 0 !important;
        padding-left: 0 !important;
    }
}

/* Tablet Devices */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Sidebar - Collapsible on Tablet */
    .sidebar-container {
        width: 16rem !important;
        transform: translateX(0) !important;
    }
    
    .sidebar-container.sidebar-collapsed {
        width: 4rem !important;
    }
    
    /* Only add sidebar padding on pages that have a sidebar */
    .has-sidebar main,
    main.sidebar-enabled {
        padding-left: 16rem !important;
    }
    
    main.sidebar-collapsed-main {
        padding-left: 4rem !important;
    }
    
    /* Public pages - no sidebar */
    body:not(.has-sidebar) .sidebar-container {
        display: none !important;
    }
    
    body:not(.has-sidebar) main {
        padding-left: 0 !important;
    }
    
    /* Hide Mobile Menu Button on Tablet+ */
    #mobileMenuBtn {
        display: none !important;
    }
    
    #sidebarBackdrop {
        display: none !important;
    }
}

/* Desktop - 1024px and up */
@media (min-width: 1024px) {
    #mobileMenuBtn {
        display: none !important;
    }
    
    #sidebarBackdrop {
        display: none !important;
    }
    
    /* Sidebar - Always visible on desktop for authenticated pages */
    .sidebar-container,
    #adminSidebar,
    #userSidebar {
        position: fixed !important;
        display: flex !important;
        flex-direction: column !important;
        width: 16rem !important;
        transform: translateX(0) !important;
        transition: width 0.3s ease, transform 0.3s ease !important;
    }
    
    .sidebar-container.sidebar-collapsed,
    #adminSidebar.sidebar-collapsed,
    #userSidebar.sidebar-collapsed {
        width: 4rem !important;
    }
    
    /* Only add sidebar padding on pages that have a sidebar */
    .has-sidebar main,
    main.sidebar-enabled {
        padding-left: 16rem !important;
        transition: padding-left 0.3s ease !important;
    }
    
    .has-sidebar main.sidebar-collapsed-main,
    main.sidebar-enabled.sidebar-collapsed-main {
        padding-left: 4rem !important;
    }
    
    /* Public pages - absolutely NO sidebar */
    body:not(.has-sidebar) .sidebar-container,
    body:not(.has-sidebar) aside {
        display: none !important;
    }
    
    body:not(.has-sidebar) main {
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
}

/* Responsive Typography */
@media (max-width: 640px) {
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
    }
    
    h3 {
        font-size: 1.125rem !important;
    }
}

/* Responsive Tables */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
}

/* Responsive Cards/Grid */
@media (max-width: 768px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    .lg\\:grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
}

/* Responsive Padding/Spacing */
@media (max-width: 640px) {
    .px-6,
    .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-8,
    .py-10 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* File Upload Dropzone - Mobile */
@media (max-width: 640px) {
    #dropZone {
        padding: 2rem 1rem !important;
    }
    
    #dropZone svg {
        width: 3rem !important;
        height: 3rem !important;
    }
}

/* Data Type Buttons - Mobile Stack */
@media (max-width: 640px) {
    .data-type-btn {
        font-size: 0.75rem !important;
        padding: 0.5rem 0.75rem !important;
    }
}

/* Modal/Popup - Mobile Full Width */
@media (max-width: 640px) {
    [role="dialog"],
    .modal,
    .popup {
        width: 95% !important;
        max-width: 95% !important;
        margin: 1rem auto !important;
    }
}

/* Responsive Buttons */
@media (max-width: 640px) {
    button,
    .btn {
        font-size: 0.875rem !important;
        padding: 0.625rem 1rem !important;
    }
    
    button.btn-lg {
        font-size: 1rem !important;
        padding: 0.75rem 1.25rem !important;
    }
}

/* Credits Card - Mobile Optimization */
@media (max-width: 640px) {
    .sidebar-container .rounded-2xl {
        padding: 0.75rem !important;
    }
    
    .sidebar-container .text-3xl {
        font-size: 1.875rem !important;
    }
}

/* Navigation Links - Touch Friendly */
@media (max-width: 767px) {
    nav a {
        padding: 0.875rem 0.75rem !important;
        font-size: 0.9375rem !important;
    }
}

/* Stats Cards - Mobile Grid */
@media (max-width: 640px) {
    .grid-cols-2 > div {
        font-size: 0.875rem !important;
    }
    
    .grid-cols-2 > div .text-lg {
        font-size: 1.125rem !important;
    }
}

/* Import Jobs Table - Mobile Scroll */
@media (max-width: 768px) {
    #importJobsTable {
        overflow-x: auto;
        display: block;
    }
    
    #importJobsTable table {
        min-width: 800px;
    }
}

/* Form Elements - Mobile Friendly */
@media (max-width: 640px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* Sticky Header - Mobile Height */
@media (max-width: 640px) {
    .sticky.top-0 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Force full-width main on mobile/tablet when sidebar exists */
@media (max-width: 1023px) {
    body.has-sidebar main {
        padding-left: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ============================================
   NAVBAR MOBILE FIXES
   ============================================ */

@media (max-width: 767px) {
    /* Navbar - Full width on mobile */
    #siteNavbar {
        width: 100vw !important;
        left: 0 !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
    }
    
    /* Navbar container */
    #siteNavbar .max-w-7xl {
        margin-left: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        max-width: 100% !important;
    }
    
    /* Mobile menu toggle button */
    #mobileMenuToggle {
        min-width: 40px !important;
        min-height: 40px !important;
    }
}

/* Touch Optimization */
@media (hover: none) and (pointer: coarse) {
    button,
    a,
    [onclick] {
        -webkit-tap-highlight-color: rgba(14, 165, 233, 0.2);
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Animation Performance */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   COMPACT HEADER DESIGN - Data Search Page
   Sleek, Modern, Space-Efficient
   ============================================ */

/* Scrollbar Hide Utility */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Base Header Styles - All Screens */
.sticky.top-0 {
    transition: all 0.2s ease;
}

/* Header Title - Compact sizing */
.sticky.top-0 h1 {
    line-height: 1.2 !important;
}

/* Header Buttons - Compact and elegant */
.sticky.top-0 button {
    transition: all 0.2s ease;
    line-height: 1.2;
}

.sticky.top-0 button:hover {
    transform: translateY(-1px);
}

.sticky.top-0 button:active {
    transform: translateY(0);
}

/* Dropdown positioning */
#listsDropdown,
#downloadsDropdown {
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Data Type Tabs - Sleek design */
#dataTypeTabs button {
    transition: all 0.2s ease;
}

#dataTypeTabs button:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    /* Ultra-compact header */
    .sticky.top-0 {
        padding: 0 !important;
    }
    
    .sticky.top-0 > div:first-child {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Compact title */
    .sticky.top-0 h1 {
        font-size: 1rem !important;
    }
    
    /* Button sizing - compact but touch-friendly */
    .sticky.top-0 button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
        min-height: 2rem !important;
    }
    
    .sticky.top-0 button svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }
    
    /* Dropdown menus on mobile */
    #listsDropdown,
    #downloadsDropdown {
        right: 0.5rem !important;
        left: 0.5rem !important;
        width: auto !important;
    }
    
    /* Data Type Tabs - horizontal scroll */
    #dataTypeTabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    #dataTypeTabs button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
}

/* Tiny screens - even more compact */
@media (max-width: 375px) {
    .sticky.top-0 h1 {
        font-size: 0.875rem !important;
    }
    
    .sticky.top-0 button {
        padding: 0.375rem 0.625rem !important;
        min-height: 1.75rem !important;
    }
    
    .sticky.top-0 button svg {
        width: 0.75rem !important;
        height: 0.75rem !important;
    }
}

/* Tablet and up - comfortable spacing */
@media (min-width: 641px) and (max-width: 1024px) {
    .sticky.top-0 > div:first-child {
        padding: 0.75rem 1rem !important;
    }
    
    .sticky.top-0 h1 {
        font-size: 1.25rem !important;
    }
}

/* Desktop - standard spacing */
@media (min-width: 1025px) {
    .sticky.top-0 > div:first-child {
        padding: 0.875rem .5rem !important;
    }
}

/* ============================================
   SIDEBAR VISIBILITY ENFORCEMENT
   Ensure sidebars are always visible on desktop
   ============================================ */

/* Default state - Desktop (no media query needed, applies to all) */
#adminSidebar,
#userSidebar,
aside.sidebar-container {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Force mobile button hidden on desktop */
@media (min-width: 768px) {
    #mobileMenuBtn {
        display: none !important;
    }
    
    #sidebarBackdrop {
        display: none !important;
    }
    
    /* Ensure sidebar is visible and positioned correctly */
    #adminSidebar,
    #userSidebar,
    aside.sidebar-container {
        display: flex !important;
        position: fixed !important;
        transform: translateX(0) !important;
        left: 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

