/* Mobile Responsiveness Enhancements for Hope Movers CMS */

/* Base mobile-first approach */
* {
    box-sizing: border-box;
}

/* Use CSS custom properties for dynamic viewport height */
:root {
    --vh: 1vh;
}

.min-h-screen-mobile {
    min-height: calc(var(--vh, 1vh) * 100);
}

/* Performance optimizations */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Touch-friendly improvements */
.touch-device {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.touch-friendly {
    min-height: 44px; /* iOS recommended touch target */
    min-width: 44px;
    cursor: pointer;
}

/* Ensure tables are responsive */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile table improvements */
@media (max-width: 768px) {
    /* Hide table headers and make rows stack */
    .mobile-table-stack table,
    .mobile-table-stack thead,
    .mobile-table-stack tbody,
    .mobile-table-stack th,
    .mobile-table-stack td,
    .mobile-table-stack tr {
        display: block;
    }
    
    .mobile-table-stack thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .mobile-table-stack tr {
        border: 1px solid #e5e7eb;
        margin-bottom: 1rem;
        border-radius: 0.5rem;
        background: white;
        padding: 1rem;
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    }
    
    .mobile-table-stack td {
        border: none;
        padding: 0.75rem 0;
        position: relative;
    }
    
    .mobile-table-stack td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #374151;
        display: inline-block;
        width: 30%;
        margin-right: 1rem;
    }
}

/* Mobile form improvements */
@media (max-width: 640px) {
    /* Stack form elements on mobile */
    .mobile-form-stack .grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Improve button spacing */
    .mobile-button-stack .flex {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .mobile-button-stack .space-x-2 > * + * {
        margin-left: 0 !important;
    }
    
    /* Full width buttons on mobile */
    .mobile-full-button {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Prevent zoom on form inputs on iOS */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="url"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Mobile card improvements */
@media (max-width: 768px) {
    .mobile-card-padding {
        padding: 1rem !important;
    }
    
    .mobile-spacing {
        margin: 0.5rem 0 !important;
    }
    
    /* Improve stats grid on mobile */
    .stats-mobile .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
}

/* Mobile navigation improvements */
@media (max-width: 1024px) {
    /* Ensure mobile sidebar overlays properly */
    .mobile-sidebar-overlay {
        position: fixed !important;
        inset: 0 !important;
        z-index: 50 !important;
    }
    
    /* Improve header spacing on tablets */
    .mobile-header-spacing {
        padding: 0.5rem 1rem !important;
    }
}

/* Text responsiveness */
@media (max-width: 640px) {
    /* Responsive text sizes */
    .mobile-text-responsive h1 {
        font-size: 1.875rem !important; /* text-3xl to text-2xl */
        line-height: 2.25rem !important;
    }
    
    .mobile-text-responsive h2 {
        font-size: 1.5rem !important; /* text-2xl to text-xl */
        line-height: 2rem !important;
    }
    
    .mobile-text-responsive h3 {
        font-size: 1.25rem !important; /* text-xl to text-lg */
        line-height: 1.75rem !important;
    }
    
    /* Truncate long text on mobile */
    .mobile-truncate {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 150px;
    }
}

/* Mobile badge and status improvements */
@media (max-width: 640px) {
    .mobile-badge-stack {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
        align-items: flex-start !important;
    }
    
    .mobile-badge-full {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
    }
}

/* Mobile modal and overlay improvements */
@media (max-width: 640px) {
    .mobile-modal-full {
        margin: 0 !important;
        max-width: none !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
    }
    
    .mobile-modal-padding {
        padding: 1rem !important;
    }
}

/* Client portal mobile improvements */
@media (max-width: 1024px) {
    .client-portal-mobile .grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
}

/* Improve scrolling on mobile */
.smooth-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Hide/show elements based on screen size */
@media (max-width: 640px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 641px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* Loading states */
.loading {
    pointer-events: none;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Focus improvements for accessibility */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-gray-50 {
        background-color: white !important;
    }
    
    .text-gray-600 {
        color: black !important;
    }
    
    .border-gray-200 {
        border-color: black !important;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-full-width {
        width: 100% !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .shadow {
        box-shadow: none !important;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    .dark-mode {
        background-color: #1f2937;
        color: #f9fafb;
    }
}