/**
 * ChinaDrive - Responsive CSS
 * Complete mobile-first responsive styles for all devices
 * Version 1.0
 */

/* ============================================
   LAZY LOADING IMAGES
============================================ */

.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-image.loaded {
    opacity: 1;
}

img[loading="lazy"] {
    background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

img[loading="lazy"].loaded {
    animation: none;
    background: none;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   GLOBAL RESPONSIVE UTILITIES
============================================ */

/* Default state - Desktop first */
.hide-mobile { display: block !important; }
.hide-tablet { display: block !important; }
.hide-desktop { display: none !important; }
.show-mobile { display: none !important; }
.show-tablet { display: none !important; }
.show-desktop { display: block !important; }

/* ============================================
   MOBILE MENU - HIDDEN ON DESKTOP
============================================ */

/* Mobile navigation - completely hidden on desktop */
.mobile-nav {
    display: none !important;
    visibility: hidden;
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(20px);
    z-index: 1100;
    padding: 80px 30px 30px;
    transition: right 0.3s ease;
    flex-direction: column;
    gap: 0;
}

/* Mobile backdrop - hidden on desktop */
.mobile-nav-backdrop {
    display: none !important;
    visibility: hidden;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1090;
}

/* Mobile toggle button - hidden on desktop */
.mobile-nav-toggle {
    display: none !important;
    visibility: hidden;
}

/* Desktop navigation - ensure visible */
@media (min-width: 992px) {
    .lux-nav {
        display: flex !important;
    }
    
    .mobile-nav,
    .mobile-nav-backdrop,
    .mobile-nav-toggle {
        display: none !important;
        visibility: hidden !important;
    }
    
    .hide-mobile {
        display: block !important;
    }
    
    .show-mobile {
        display: none !important;
    }
}

/* Responsive text */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive images */
.img-responsive {
    max-width: 100%;
    height: auto;
}

/* ============================================
   ADMIN LAYOUT - MOBILE RESPONSIVE
============================================ */

/* Mobile Sidebar Overlay */
@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease, transform 0.3s ease;
        box-shadow: none;
    }
    
    .sidebar.active {
        left: 0;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }
    
    /* Overlay backdrop when sidebar is open */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-backdrop.active {
        display: block;
        opacity: 1;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Mobile menu button */
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: var(--lux-surface, #1e1e1e);
        border: 1px solid var(--lux-border, rgba(255,255,255,0.1));
        border-radius: 8px;
        color: var(--lux-text, #fff);
        font-size: 20px;
        cursor: pointer;
    }
    
    /* Top bar adjustments */
    .top-bar {
        padding: 0 16px !important;
        height: 60px;
    }
    
    .search-bar {
        display: none !important;
    }
    
    .top-bar-actions {
        gap: 8px !important;
    }
    
    .profile-dropdown-toggle span {
        display: none !important;
    }
    
    /* Content area */
    .content-area {
        padding: 16px !important;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991px) {
    .content-area {
        padding: 20px !important;
    }
    
    .search-bar {
        display: flex !important;
        max-width: 200px;
    }
}

/* ============================================
   ADMIN TABLES - RESPONSIVE
============================================ */

@media (max-width: 991px) {
    .admin-table-wrapper,
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
    
    .admin-table,
    .table-modern {
        min-width: 700px;
    }
    
    .admin-table th,
    .admin-table td,
    .table-modern th,
    .table-modern td {
        padding: 12px 10px !important;
        font-size: 13px !important;
    }
    
    .admin-table-item-image {
        width: 40px !important;
        height: 40px !important;
    }
    
    .admin-table-actions {
        flex-wrap: nowrap;
    }
    
    .admin-table-action {
        width: 32px !important;
        height: 32px !important;
    }
}

/* Card-style table on very small screens */
@media (max-width: 576px) {
    .table-card-mobile thead {
        display: none;
    }
    
    .table-card-mobile tbody tr {
        display: block;
        margin-bottom: 16px;
        background: var(--lux-surface, #1e1e1e);
        border: 1px solid var(--lux-border, rgba(255,255,255,0.1));
        border-radius: 12px;
        padding: 16px;
    }
    
    .table-card-mobile tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0 !important;
        border: none !important;
        border-bottom: 1px solid var(--lux-border-light, rgba(255,255,255,0.05)) !important;
    }
    
    .table-card-mobile tbody td:last-child {
        border-bottom: none !important;
    }
    
    .table-card-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        color: var(--lux-text-muted, rgba(255,255,255,0.5));
    }
}

/* ============================================
   ADMIN FORMS - RESPONSIVE
============================================ */

@media (max-width: 768px) {
    .admin-form-row,
    .admin-form-row.cols-2,
    .admin-form-row.cols-3,
    .admin-form-row.cols-4 {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .admin-card-body {
        padding: 16px !important;
    }
    
    .admin-card-header {
        padding: 16px !important;
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .admin-card-footer {
        padding: 16px !important;
        flex-direction: column;
        gap: 10px;
    }
    
    .admin-card-footer .admin-btn {
        width: 100%;
        justify-content: center;
    }
    
    .admin-btn {
        padding: 12px 20px !important;
        font-size: 13px !important;
    }
    
    .admin-btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .admin-btn-group .admin-btn {
        width: 100%;
    }
}

/* ============================================
   ADMIN PAGE HEADER - RESPONSIVE
============================================ */

@media (max-width: 768px) {
    .admin-page-header {
        padding: 20px !important;
        flex-direction: column;
        text-align: center;
    }
    
    .admin-page-header-left {
        flex-direction: column;
    }
    
    .admin-page-header-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 22px !important;
    }
    
    .admin-page-header-title {
        font-size: 20px !important;
    }
    
    .admin-page-header-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .admin-page-header-actions .admin-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Dashboard specific */
    .page-header-card {
        padding: 16px !important;
        flex-direction: column;
        text-align: center;
    }
    
    .page-header-content {
        flex-direction: column;
    }
    
    .page-header-actions {
        width: 100%;
    }
    
    .page-header-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   ADMIN STATS GRID - RESPONSIVE
============================================ */

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .stat-card {
        padding: 16px !important;
    }
    
    .stat-value {
        font-size: 24px !important;
    }
    
    .stat-icon {
        width: 44px !important;
        height: 44px !important;
        font-size: 18px !important;
    }
}

/* ============================================
   ADMIN DASHBOARD GRID - RESPONSIVE
============================================ */

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .revenue-card {
        padding: 20px !important;
    }
    
    .revenue-amount {
        font-size: 32px !important;
    }
    
    .revenue-header {
        flex-direction: column;
        gap: 12px;
    }
}

/* ============================================
   ADMIN FILTERS - RESPONSIVE
============================================ */

@media (max-width: 768px) {
    .admin-filters {
        flex-direction: column;
        padding: 16px !important;
        gap: 12px !important;
    }
    
    .admin-search {
        max-width: none !important;
        width: 100%;
    }
    
    .admin-filter-tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }
    
    .admin-filter-tab {
        flex-shrink: 0;
        padding: 8px 14px !important;
        font-size: 12px !important;
    }
}

/* ============================================
   ADMIN MODALS - RESPONSIVE
============================================ */

@media (max-width: 576px) {
    .admin-modal-backdrop {
        padding: 10px !important;
    }
    
    .admin-modal {
        max-width: 100% !important;
        max-height: 95vh !important;
        border-radius: 16px !important;
    }
    
    .admin-modal-header {
        padding: 16px !important;
    }
    
    .admin-modal-body {
        padding: 16px !important;
        max-height: calc(95vh - 140px) !important;
    }
    
    .admin-modal-footer {
        padding: 16px !important;
        flex-direction: column;
    }
    
    .admin-modal-footer .admin-btn {
        width: 100%;
    }
}

/* ============================================
   ADMIN IMAGE GALLERY - RESPONSIVE
============================================ */

@media (max-width: 576px) {
    .admin-image-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .admin-image-upload {
        padding: 24px !important;
    }
    
    .admin-image-upload-icon {
        width: 48px !important;
        height: 48px !important;
        font-size: 20px !important;
    }
    
    .admin-thumbnail-upload {
        width: 120px !important;
        height: 120px !important;
    }
}

/* ============================================
   FRONT-END HEADER - MOBILE RESPONSIVE
============================================ */

@media (max-width: 991px) {
    /* Header mobile - compact and totally transparent for ALL themes and states */
    header,
    .lux-header,
    header.smaller,
    header.scroll-light,
    header.scroll-dark,
    header.autoshow,
    header.header-mobile,
    [data-theme="dark"] .lux-header,
    [data-theme="light"] .lux-header {
        padding: 12px 16px !important;
        justify-content: space-between !important;
        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        border-bottom: none !important;
        height: auto !important;
        margin-top: 0 !important;
        top: 0 !important;
    }
    
    /* Ensure no blue tint from bootstrap or other styles */
    .lux-header::before,
    .lux-header::after {
        display: none !important;
    }
    
    /* Hide desktop nav */
    .lux-nav {
        display: none !important;
    }
    
    /* Logo compact - icon only on very small screens */
    .lux-logo {
        font-size: 18px !important;
        gap: 8px !important;
    }
    
    .lux-logo-icon {
        width: 32px !important;
        height: 32px !important;
    }
    
    /* Header actions - align right */
    .lux-header-actions {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        margin-left: auto !important;
    }
    
    /* Mobile menu toggle button - visible on mobile */
    .mobile-nav-toggle {
        display: flex !important;
        visibility: visible !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: transparent;
        border: 1px solid rgba(255,255,255,0.3);
        border-radius: 8px;
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        transition: all 0.3s ease;
        order: 10; /* Push to far right */
    }
    
    .mobile-nav-toggle:hover {
        background: rgba(255,255,255,0.1);
        border-color: rgba(255,255,255,0.5);
    }
    
    /* Mobile navigation menu - show on mobile */
    .mobile-nav {
        display: flex !important;
        visibility: visible !important;
        right: -100%;
    }
    
    .mobile-nav.active {
        right: 0;
    }
    
    .mobile-nav-backdrop {
        display: none !important;
        visibility: visible !important;
    }
    
    .mobile-nav-backdrop.active {
        display: block !important;
    }
    
    .mobile-nav-close {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        background: transparent;
        border: 1px solid rgba(255,255,255,0.2);
        border-radius: 8px;
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-nav a {
        display: block;
        padding: 16px 0;
        color: rgba(255,255,255,0.8);
        font-size: 16px;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 1px;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        transition: all 0.3s ease;
        text-decoration: none;
    }
    
    .mobile-nav a:hover,
    .mobile-nav a.active {
        color: #fff;
        padding-left: 10px;
    }
    
    /* Show mobile utilities */
    .show-mobile {
        display: block !important;
    }
    
    .hide-mobile {
        display: none !important;
    }
    
    .lux-header-actions {
        gap: 10px !important;
    }
    
    .lux-btn-started {
        padding: 10px 16px !important;
        font-size: 12px !important;
    }
    
    .lux-btn-started span {
        display: none;
    }
}

@media (max-width: 576px) {
    .lux-header {
        padding: 10px 12px !important;
    }
    
    /* Logo - icon only on small screens */
    .lux-logo {
        font-size: 0 !important; /* Hide text */
        gap: 0 !important;
    }
    
    .lux-logo-icon {
        width: 36px !important;
        height: 36px !important;
    }
    
    /* Hide CTA button on very small screens */
    .lux-btn-started {
        display: none !important;
    }
    
    .header-theme-toggle {
        width: 38px !important;
        height: 38px !important;
    }
    
    .mobile-nav-toggle {
        width: 40px !important;
        height: 40px !important;
    }
}

/* ============================================
   FRONT-END HERO - RESPONSIVE
============================================ */

@media (max-width: 991px) {
    .lux-hero {
        height: auto;
        min-height: 100vh;
    }
    
    .lux-hero-bg-text {
        font-size: 20vw !important;
        opacity: 0.05;
    }
    
    .lux-hero-bottom {
        flex-direction: column;
        align-items: flex-start;
        bottom: 180px !important; /* Increased space to separate from brands bar */
        padding: 0 20px !important;
        gap: 24px;
    }
    
    .lux-hero-tagline {
        font-size: 28px !important;
        max-width: 100% !important;
    }
    
    .lux-hero-desc-right {
        text-align: left !important;
        max-width: 100% !important;
    }
    
    .lux-controls {
        margin-top: 20px !important;
    }
}

@media (max-width: 576px) {
    .lux-hero-bottom {
        bottom: 160px !important; /* Consistent spacing on small screens to avoid overlap with brands */
        gap: 16px;
    }
    
    .lux-hero-tagline {
        font-size: 20px !important;
    }
    
    .lux-hero-desc-right {
        font-size: 12px !important;
    }
    
    .lux-explore-btn {
        width: 100%;
        text-align: center;
        padding: 12px 20px !important;
        font-size: 12px !important;
    }
    
    .lux-controls {
        margin-top: 10px !important;
    }
    
    .lux-control-btn {
        width: 40px !important;
        height: 40px !important;
    }
}

/* ============================================
   FRONT-END SECTIONS - RESPONSIVE
============================================ */

@media (max-width: 991px) {
    .lux-section {
        padding: 60px 20px !important;
    }
    
    .lux-section-title {
        font-size: 36px !important;
        letter-spacing: -1px !important;
    }
    
    .lux-section-text {
        font-size: 14px !important;
    }
}

@media (max-width: 576px) {
    .lux-section {
        padding: 40px 16px !important;
    }
    
    .lux-section-title {
        font-size: 28px !important;
    }
    
    .lux-section-subtitle {
        font-size: 12px !important;
        letter-spacing: 2px !important;
    }
}

/* ============================================
   FRONT-END GRIDS - RESPONSIVE
============================================ */

@media (max-width: 991px) {
    .lux-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
}

@media (max-width: 576px) {
    .lux-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
}

/* ============================================
   FRONT-END CARDS - RESPONSIVE
============================================ */

@media (max-width: 768px) {
    .lux-card {
        margin-bottom: 16px;
    }
    
    .lux-card-img {
        height: 200px !important;
    }
    
    .lux-card-body {
        padding: 20px !important;
    }
    
    .lux-card-title {
        font-size: 18px !important;
    }
    
    .lux-card-text {
        font-size: 13px !important;
    }
}

/* ============================================
   FRONT-END PAGE HEADER - RESPONSIVE
============================================ */

@media (max-width: 991px) {
    .lux-page-header {
        padding: 40px 20px !important;
        min-height: 300px !important;
    }
    
    .lux-page-header h1 {
        font-size: 42px !important;
        letter-spacing: -1px !important;
    }
    
    .lux-page-header p {
        font-size: 14px !important;
    }
}

@media (max-width: 576px) {
    .lux-page-header {
        min-height: 250px !important;
        padding: 30px 16px !important;
    }
    
    .lux-page-header h1 {
        font-size: 32px !important;
    }
}

/* ============================================
   FRONT-END BRANDS BAR - RESPONSIVE
============================================ */

@media (max-width: 991px) {
    /* Keep brands bar at bottom */
    .lux-brands-bar {
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        padding: 16px 0 !important;
    }
    
    .lux-brands-container {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 12px 20px !important;
        padding: 0 16px !important;
    }
    
    .lux-brand {
        font-size: 12px !important;
    }
    
    .partner-logo {
        height: 22px !important;
    }
}

@media (max-width: 576px) {
    .lux-brands-bar {
        padding: 12px 0 !important;
    }
    
    .lux-brands-container {
        gap: 8px 16px !important;
    }
    
    .lux-brand {
        font-size: 10px !important;
    }
    
    .partner-logo {
        height: 18px !important;
    }
}

/* ============================================
   FRONT-END FOOTER - RESPONSIVE
============================================ */

@media (max-width: 991px) {
    .lux-footer {
        padding: 50px 20px 30px !important;
    }
    
    .lux-footer-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 30px !important;
    }
    
    .lux-footer-brand {
        font-size: 24px !important;
    }
}

@media (max-width: 576px) {
    .lux-footer {
        padding: 40px 16px 24px !important;
    }
    
    .lux-footer-grid {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }
    
    .lux-footer-bottom {
        flex-direction: column !important;
        gap: 16px !important;
        text-align: center !important;
    }
    
    .lux-footer-copy {
        font-size: 12px !important;
    }
    
    .lux-footer-social {
        justify-content: center;
    }
}

/* ============================================
   FRONT-END BUTTONS - RESPONSIVE
============================================ */

@media (max-width: 576px) {
    .lux-btn {
        padding: 12px 20px !important;
        font-size: 12px !important;
        width: 100%;
        justify-content: center;
    }
    
    .lux-btn-primary,
    .lux-btn-outline {
        width: 100%;
        text-align: center;
    }
}

/* ============================================
   UTILITY CLASSES - RESPONSIVE
============================================ */

@media (max-width: 991px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .hide-tablet {
        display: none !important;
    }
    
    .show-tablet {
        display: block !important;
    }
}

@media (min-width: 992px) {
    .hide-desktop {
        display: none !important;
    }
    
    .show-desktop {
        display: block !important;
    }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .admin-btn,
    .lux-btn,
    .btn-modern {
        min-height: 44px;
    }
    
    .admin-table-action {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Remove hover effects that don't work on touch */
    .lux-card:hover {
        transform: none;
    }
    
    .stat-card:hover {
        transform: none;
    }
    
    /* Smooth scrolling for touch */
    .admin-table-wrapper,
    .table-responsive,
    .admin-filter-tabs {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

/* ============================================
   LIGHT MODE - MOBILE RESPONSIVE
============================================ */

[data-theme="light"] .mobile-nav-toggle {
    border-color: rgba(0,0,0,0.3) !important;
    color: #333 !important;
}

[data-theme="light"] .mobile-nav-toggle:hover {
    background: rgba(0,0,0,0.1) !important;
    border-color: rgba(0,0,0,0.5) !important;
}

[data-theme="light"] .mobile-nav {
    background: rgba(255, 255, 255, 0.98) !important;
}

[data-theme="light"] .mobile-nav a {
    color: rgba(0,0,0,0.7) !important;
    border-bottom-color: rgba(0,0,0,0.1) !important;
}

[data-theme="light"] .mobile-nav a:hover,
[data-theme="light"] .mobile-nav a.active {
    color: #000 !important;
}

[data-theme="light"] .mobile-nav-close {
    border-color: rgba(0,0,0,0.2) !important;
    color: #333 !important;
}

/* ============================================
   PRINT STYLES
============================================ */

@media print {
    .sidebar,
    .top-bar,
    .lux-header,
    .lux-footer,
    .mobile-menu-btn,
    .admin-btn,
    .lux-btn {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .content-area {
        padding: 0 !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION FIXES
============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .lux-hero {
        height: auto;
        min-height: 100vh;
        padding-bottom: 80px;
    }
    
    .lux-hero-bottom {
        position: relative;
        bottom: auto;
        margin-top: 40px;
    }
    
    .sidebar {
        overflow-y: auto;
    }
}

/* ============================================
   SAFE AREA INSETS (iPhone X+)
============================================ */

@supports (padding: max(0px)) {
    .lux-header {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .lux-footer {
        padding-bottom: max(30px, env(safe-area-inset-bottom));
    }
    
    .sidebar {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .mobile-nav {
        padding-bottom: max(30px, env(safe-area-inset-bottom));
    }
}
