/**
 * M7 Memories - Mobile Responsive CSS
 * Complete mobile optimization for all pages
 * Breakpoints: 320px, 480px, 576px, 768px, 992px, 1200px
 */

/* ========================================
   BASE MOBILE STYLES
   ======================================== */

/* Ensure proper box-sizing */
* {
    box-sizing: border-box;
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Responsive images and videos */
img, video {
    max-width: 100%;
    height: auto;
}

/* ========================================
   MOBILE NAVIGATION & HEADER
   ======================================== */

@media (max-width: 991px) {
    /* Mobile menu toggle */
    .page-header .nav-holder {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100vh;
        background: #fff;
        z-index: 9999;
        transition: all 0.3s ease;
        overflow-y: auto;
    }
    
    .page-header .nav-holder.active {
        left: 0;
    }
    
    /* Hamburger menu */
    .mobile-menu-toggle {
        display: block !important;
        font-size: 24px;
        cursor: pointer;
        padding: 10px;
    }
    
    /* Header adjustments */
    .page-header {
        padding: 10px 0;
    }
    
    .page-header .logo {
        max-width: 120px;
    }
}

/* ========================================
   STUDIO & CLIENT DASHBOARD MOBILE
   ======================================== */

@media (max-width: 991px) {
    /* Sidebar mobile */
    .sidebar-wrapper {
        position: fixed;
        left: -280px;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: all 0.3s ease;
    }
    
    .sidebar-wrapper.active {
        left: 0;
    }
    
    /* Page body adjustments */
    .page-body-wrapper {
        margin-left: 0 !important;
    }
    
    .page-body {
        padding: 15px !important;
    }
    
    /* Dashboard cards */
    .card {
        margin-bottom: 20px;
    }
    
    .card-body {
        padding: 15px !important;
    }
    
    /* Stats cards - full width on mobile */
    .col-xl-3, .col-xl-4, .col-xl-6, .col-xl-7, .col-xl-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Hide desktop-only elements */
    .xl-none, .desktop-only {
        display: none !important;
    }
}

@media (max-width: 767px) {
    /* Page title */
    .page-title h3 {
        font-size: 20px !important;
    }
    
    .breadcrumb {
        display: none;
    }
    
    /* Dashboard stats */
    .total-sales .d-flex {
        flex-direction: column;
        text-align: center;
    }
    
    .total-sales h4 {
        font-size: 24px;
    }
    
    .total-sales h6 {
        font-size: 14px;
    }
}

/* ========================================
   GALLERY & IMAGE GRID MOBILE
   ======================================== */

@media (max-width: 991px) {
    /* Gallery grid - 2 columns on tablet */
    .gallery-grid, .image-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .gallery img, .gallery video {
        width: 100%;
        margin: 5px 0;
    }
}

@media (max-width: 576px) {
    /* Gallery grid - 1 column on mobile */
    .gallery-grid, .image-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    /* Image items */
    .image-item, .gallery-item {
        width: 100%;
        margin-bottom: 15px;
    }
    
    /* Image overlay controls */
    .image-overlay {
        font-size: 12px;
    }
    
    .image-overlay button {
        padding: 5px 10px;
        font-size: 12px;
    }
}

/* ========================================
   FORMS & INPUTS MOBILE
   ======================================== */

@media (max-width: 767px) {
    /* Form groups */
    .form-group {
        margin-bottom: 15px;
    }
    
    /* Input fields */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    /* Buttons */
    .btn {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
        margin: 5px 0;
    }
}

/* ========================================
   TABLES MOBILE
   ======================================== */

@media (max-width: 991px) {
    /* Responsive tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 12px;
    }
    
    table th, table td {
        padding: 8px 5px;
        white-space: nowrap;
    }
    
    /* Hide less important columns on mobile */
    .mobile-hide {
        display: none;
    }
}

@media (max-width: 576px) {
    /* Stack table rows */
    .table-mobile-stack thead {
        display: none;
    }
    
    .table-mobile-stack tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
    }
    
    .table-mobile-stack tbody td {
        display: block;
        text-align: right;
        padding: 10px;
        border-bottom: 1px solid #eee;
    }
    
    .table-mobile-stack tbody td:before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
    }
}

/* ========================================
   LANDING PAGE MOBILE
   ======================================== */

@media (max-width: 991px) {
    /* Hero slider */
    .wpo-hero-slider h2 {
        font-size: 28px !important;
        line-height: 1.3;
        padding: 0 20px;
    }
    
    /* Couple section */
    .couple-section .text-grid {
        text-align: center !important;
        margin-bottom: 30px;
    }
    
    .middle-couple-pic {
        margin: 30px auto;
    }
    
    /* Services section */
    .services-left-content {
        padding: 40px 20px !important;
    }
    
    .services-title-box h2 {
        font-size: 32px !important;
    }
    
    .service-item-grid {
        margin-bottom: 25px;
        padding-right: 0 !important;
    }
    
    .services-right-img {
        min-height: 300px !important;
    }
}

@media (max-width: 767px) {
    /* Hero text */
    .wpo-hero-slider h2 {
        font-size: 22px !important;
    }
    
    /* Section padding */
    .section-padding {
        padding: 40px 0 !important;
    }
    
    /* Feature cards */
    .wpo-feature-item {
        padding: 30px 20px;
        margin-bottom: 20px;
    }
    
    .wpo-feature-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    
    .wpo-feature-text h2 {
        font-size: 18px;
    }
}

/* ========================================
   PRICING SECTION MOBILE
   ======================================== */

@media (max-width: 991px) {
    /* Pricing cards */
    .wpo-pricing-section .pricing-card {
        margin-bottom: 30px;
    }
    
    .pricing-card {
        padding: 30px 20px;
    }
    
    /* Pricing toggle */
    .pricing-toggle {
        flex-direction: column;
        gap: 15px;
    }
}

@media (max-width: 576px) {
    .pricing-card h3 {
        font-size: 22px;
    }
    
    .pricing-card .price {
        font-size: 32px;
    }
    
    .pricing-card ul {
        font-size: 14px;
    }
}

/* ========================================
   MODALS & POPUPS MOBILE
   ======================================== */

@media (max-width: 767px) {
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 10px;
    }
    
    .modal-header, .modal-footer {
        padding: 15px;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
}

/* ========================================
   UPLOAD & FILE MANAGEMENT MOBILE
   ======================================== */

@media (max-width: 767px) {
    /* Upload area */
    .dropzone {
        min-height: 200px;
        padding: 20px;
    }
    
    .dropzone .dz-message {
        font-size: 14px;
    }
    
    /* File list */
    .file-list-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .file-list-item .file-actions {
        width: 100%;
        margin-top: 10px;
        justify-content: space-between;
    }
}

/* ========================================
   STORAGE CARD MOBILE
   ======================================== */

@media (max-width: 767px) {
    .storage-card {
        padding: 20px 15px;
    }
    
    .storage-card h4 {
        font-size: 18px;
    }
    
    .storage-progress {
        height: 8px;
    }
    
    .storage-details {
        flex-direction: column;
        gap: 10px;
    }
}

/* ========================================
   FOOTER MOBILE
   ======================================== */

@media (max-width: 991px) {
    .wpo-site-footer {
        padding: 40px 0 20px;
    }
    
    .footer-widget {
        margin-bottom: 30px;
        text-align: center;
    }
    
    .footer-widget .logo {
        margin: 0 auto 20px;
    }
    
    .footer-widget ul {
        padding: 0;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Mobile spacing */
@media (max-width: 767px) {
    .mt-mobile-20 { margin-top: 20px !important; }
    .mb-mobile-20 { margin-bottom: 20px !important; }
    .pt-mobile-20 { padding-top: 20px !important; }
    .pb-mobile-20 { padding-bottom: 20px !important; }
    
    /* Mobile text alignment */
    .text-mobile-center { text-align: center !important; }
    .text-mobile-left { text-align: left !important; }
}

/* Touch-friendly elements */
@media (max-width: 991px) {
    /* Minimum touch target size */
    a, button, .btn, input[type="checkbox"], input[type="radio"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Larger tap areas for icons */
    .icon-btn, .action-icon {
        padding: 12px;
        font-size: 20px;
    }
}

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

@media (max-width: 991px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .section-padding {
        padding: 30px 0 !important;
    }
    
    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ========================================
   DARK MODE MOBILE ADJUSTMENTS
   ======================================== */

@media (max-width: 991px) {
    body.dark-only {
        background-color: #171829;
    }
    
    body.dark-only .card {
        background-color: #1e2139;
        border-color: #2a2d47;
    }
    
    body.dark-only .sidebar-wrapper {
        background-color: #171829;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus states for keyboard navigation */
@media (max-width: 991px) {
    a:focus, button:focus, input:focus, select:focus, textarea:focus {
        outline: 2px solid #007bff;
        outline-offset: 2px;
    }
    
    /* Skip to content link */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: #007bff;
        color: white;
        padding: 8px;
        text-decoration: none;
        z-index: 100;
    }
    
    .skip-to-content:focus {
        top: 0;
    }
}


/* ========================================
   MOBILE OVERLAY & ENHANCEMENTS
   ======================================== */

/* Mobile menu overlay */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Pull to refresh indicator */
.pull-to-refresh-indicator {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #007bff;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 9999;
    transition: all 0.3s ease;
    opacity: 0;
}

.pull-to-refresh-indicator.refreshing {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: #0056b3;
    transform: translateY(-5px);
}

.back-to-top:active {
    transform: translateY(-2px);
}

/* Lazy loading image placeholder */
img[data-src], img[data-lazy-src] {
    background: #f0f0f0;
    min-height: 200px;
}

img.loaded {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Touch feedback */
@media (max-width: 991px) {
    button:active, .btn:active, a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Prevent text selection on touch */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar for mobile */
@media (max-width: 991px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
    
    ::-webkit-scrollbar-track {
        background: transparent;
    }
    
    ::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 10px;
    }
}

/* Loading spinner */
.mobile-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
}

.mobile-loading::after {
    content: "";
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .page-header {
        padding-top: max(10px, env(safe-area-inset-top));
    }
    
    .page-footer {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Viewport height fix */
.full-height-mobile {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}
