/**
 * Manage Night to Shine Mobile Responsive Utilities
 * Provides enhanced mobile responsiveness for admin interfaces
 */

/* Progressive Breakpoints */
@media (max-width: 1024px) {
    .admin-container {
        padding: 30px 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Tablet Optimizations */
@media (max-width: 768px) {
    .admin-container {
        padding: 20px 15px;
    }
    
    .admin-header h1 {
        font-size: 36px;
    }
    
    .content-section {
        padding: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .search-controls {
        justify-content: stretch;
    }
    
    .search-input {
        width: 100%;
    }
    
    /* Mobile Table to Card Transformation */
    .responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table th,
    .responsive-table td,
    .responsive-table tr {
        display: block;
    }
    
    .responsive-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .responsive-table tr {
        background: rgba(17, 24, 39, 0.8);
        border-radius: 12px;
        margin-bottom: 15px;
        padding: 20px;
        border: 1px solid rgba(75, 85, 99, 0.3);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        transition: all 0.3s ease;
    }
    
    .responsive-table tr:hover {
        background: rgba(17, 24, 39, 0.9);
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    }
    
    .responsive-table td {
        border: none;
        padding: 8px 0;
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
        min-height: 36px; /* Ensure touch-friendly spacing */
    }
    
    .responsive-table td:before {
        content: attr(data-label);
        font-weight: bold;
        color: #9ca3af;
        text-transform: uppercase;
        font-size: 12px;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        width: 35%;
        padding-right: 10px;
    }
    
    .responsive-table td:last-child {
        margin-bottom: 0;
    }
    
    /* Touch-Optimized Buttons */
    .btn-small {
        min-height: 44px; /* Touch target optimization */
        font-size: 12px;
        padding: 8px 12px;
        border-radius: 6px;
    }
    
    .action-buttons {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-end;
        width: 65%;
    }
    
    .action-buttons .btn-small {
        flex: 1;
        min-width: 70px;
    }
    
    /* Form Optimizations */
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-group {
        width: 100%;
    }
    
    .form-control {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Modal Optimizations */
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
        margin: 5vh auto;
        width: 95%;
        max-width: none;
    }
    
    .modal-header,
    .modal-footer {
        padding: 15px;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
}

/* Mobile Phone Optimizations */
@media (max-width: 480px) {
    .admin-header h1 {
        font-size: 28px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .responsive-table tr {
        padding: 15px;
    }
    
    .responsive-table td:before {
        width: 40%;
        font-size: 11px;
    }
    
    .action-buttons {
        width: 60%;
        flex-direction: column;
    }
    
    .btn-small {
        width: 100%;
        min-height: 48px; /* Larger touch targets on small screens */
        font-size: 14px;
    }
    
    /* Horizontal scrolling for wide content */
    .scroll-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better spacing for small screens */
    .content-section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .section-header {
        gap: 10px;
    }
    
    /* Form improvements for small screens */
    .form-control {
        min-height: 48px;
        padding: 12px 16px;
    }
    
    .modal-content {
        margin: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        max-height: none;
    }
}

/* Touch-Friendly Enhancements */
@media (hover: none) and (pointer: coarse) {
    /* These styles apply only to touch devices */
    
    .btn-small,
    .search-btn,
    .filter-btn {
        min-height: 48px;
        padding: 12px 16px;
    }
    
    .checkin-btn {
        min-height: 52px;
        font-size: 16px;
    }
    
    /* Increase spacing between interactive elements */
    .action-buttons {
        gap: 12px;
    }
    
    /* Better feedback for touch interactions */
    .btn:active,
    .btn-small:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Landscape Tablet Optimizations */
@media (max-width: 1024px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .responsive-table tr {
        display: table-row;
        background: rgba(17, 24, 39, 0.6);
        border-radius: 0;
        margin-bottom: 0;
        padding: 0;
        border: none;
        box-shadow: none;
    }
    
    .responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table th,
    .responsive-table td {
        display: table;
    }
    
    .responsive-table thead tr {
        position: static;
        display: table-row;
    }
    
    .responsive-table td {
        display: table-cell;
        padding: 12px 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        margin-bottom: 0;
        min-height: auto;
    }
    
    .responsive-table td:before {
        display: none;
    }
    
    .action-buttons {
        width: auto;
        flex-direction: row;
    }
}

/* Dark Mode Optimizations */
@media (prefers-color-scheme: dark) {
    .responsive-table tr {
        background: rgba(17, 24, 39, 0.9);
        border-color: rgba(75, 85, 99, 0.4);
    }
    
    .responsive-table tr:hover {
        background: rgba(17, 24, 39, 1);
    }
}

/* High DPI Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .responsive-table tr {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .btn-small {
        border-width: 0.5px;
    }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
    .responsive-table tr,
    .btn-small,
    .modal-content {
        transition: none;
    }
    
    .responsive-table tr:hover {
        transform: none;
    }
}

/* Print Optimizations */
@media print {
    .responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table th,
    .responsive-table td,
    .responsive-table tr {
        display: table;
    }
    
    .responsive-table thead tr {
        position: static;
        display: table-row;
    }
    
    .responsive-table td:before {
        display: none;
    }
    
    .action-buttons {
        display: none;
    }
}

/* Utility Classes */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 480px) {
    .touch-target {
        min-height: 48px;
        min-width: 48px;
    }
}