﻿/* Time Tracking Mobile Optimization CSS
   Designed for field workers on mobile devices
   RateRight Australian Construction Marketplace */

/* =================== MOBILE RESPONSIVE BREAKPOINTS =================== */

/* Large mobile and up (576px and up) */
@media (min-width: 576px) {
    .hour-summary-cards .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Medium devices and below (768px and below) */
@media (max-width: 768px) {
    
    /* =================== CLOCK IN/OUT BUTTONS =================== */
    
    /* Touch-friendly clock buttons with minimum 60px height */
    .clock-button,
    #clock-status button,
    button[onclick*="clock"] {
        min-height: 60px !important;
        font-size: 1.2rem !important;
        padding: 15px 30px !important;
        border-radius: 8px !important;
        font-weight: 600 !important;
        letter-spacing: 0.5px !important;
        text-transform: uppercase !important;
        box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
        transition: all 0.2s ease !important;
    }
    
    /* Enhanced button states for mobile */
    .clock-button:hover,
    #clock-status button:hover,
    button[onclick*="clock"]:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 6px 12px rgba(0,0,0,0.2) !important;
    }
    
    .clock-button:active,
    #clock-status button:active,
    button[onclick*="clock"]:active {
        transform: translateY(1px) !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    }
    
    /* Clock widget mobile optimization */
    #clock-widget {
        position: sticky !important;
        top: 20px !important;
        /* z-index: 100 !important; - Moved to z-index-master.css */
        margin-bottom: 20px !important;
    }
    
    #clock-status .col-md-4 {
        margin-top: 15px !important;
    }
    
    /* =================== TABLE OPTIMIZATION =================== */
    
    /* Make time entry tables horizontally scrollable */
    .time-entries-table,
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
    
    /* Table styling for mobile */
    .table-responsive table {
        min-width: 800px !important;
        font-size: 0.9rem !important;
    }
    
    .table-responsive th,
    .table-responsive td {
        padding: 12px 8px !important;
        white-space: nowrap !important;
    }
    
    /* Responsive table headers */
    .table-responsive th {
        background-color: #f8f9fa !important;
        position: sticky !important;
        top: 0 !important;
        /* z-index: 10 !important; - Moved to z-index-master.css */
        font-weight: 600 !important;
        border-bottom: 2px solid #dee2e6 !important;
    }
    
    /* Table row highlighting for mobile */
    .table-responsive tr:hover {
        background-color: rgba(0,123,255,0.05) !important;
    }
    
    /* =================== HOUR SUMMARY CARDS =================== */
    
    /* Stack hour summary cards vertically on mobile */
    .hour-summary-cards .col-md-3 {
        margin-bottom: 15px !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    /* Optimize card content for mobile */
    .hour-summary-cards .card {
        border-radius: 12px !important;
        box-shadow: 0 3px 12px rgba(0,0,0,0.12) !important;
        border: none !important;
    }
    
    .hour-summary-cards .card-body {
        padding: 20px 15px !important;
    }
    
    .hour-summary-cards h3 {
        font-size: 2rem !important;
        font-weight: 700 !important;
    }
    
    .hour-summary-cards h5 {
        font-size: 1rem !important;
        margin-bottom: 8px !important;
    }
    
    /* =================== FORM INPUTS & DATE PICKERS =================== */
    
    /* Optimize date pickers for mobile */
    .date-picker,
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"] {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 12px 15px !important;
        border-radius: 8px !important;
        border: 2px solid #dee2e6 !important;
        min-height: 50px !important;
        -webkit-appearance: none !important;
        appearance: none !important;
    }
    
    /* Focus states for mobile inputs */
    .date-picker:focus,
    input[type="date"]:focus,
    input[type="datetime-local"]:focus,
    input[type="time"]:focus {
        border-color: #007bff !important;
        box-shadow: 0 0 0 3px rgba(0,123,255,0.25) !important;
        outline: none !important;
    }
    
    /* General form inputs mobile optimization */
    .form-control {
        font-size: 16px !important;
        padding: 12px 15px !important;
        border-radius: 8px !important;
        min-height: 50px !important;
    }
    
    .form-select {
        font-size: 16px !important;
        padding: 12px 15px !important;
        min-height: 50px !important;
    }
    
    /* =================== NAVIGATION & BUTTONS =================== */
    
    /* Mobile-friendly navigation buttons */
    .btn {
        min-height: 50px !important;
        padding: 12px 20px !important;
        font-size: 1rem !important;
        border-radius: 8px !important;
        font-weight: 500 !important;
    }
    
    .btn-lg {
        min-height: 60px !important;
        padding: 15px 25px !important;
        font-size: 1.1rem !important;
    }
    
    .btn-sm {
        min-height: 45px !important;
        padding: 10px 15px !important;
        font-size: 0.9rem !important;
    }
    
    /* =================== MODALS =================== */
    
    /* Mobile-optimized modals */
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }
    
    .modal-content {
        border-radius: 12px !important;
        border: none !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
    }
    
    .modal-header {
        padding: 20px !important;
        border-bottom: 1px solid #dee2e6 !important;
    }
    
    .modal-body {
        padding: 20px !important;
    }
    
    .modal-footer {
        padding: 15px 20px !important;
        border-top: 1px solid #dee2e6 !important;
    }
    
    /* =================== CONTAINER & LAYOUT =================== */
    
    /* Optimize container padding for mobile */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .card {
        border-radius: 12px !important;
        border: none !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
        margin-bottom: 20px !important;
    }
    
    .card-header {
        padding: 15px 20px !important;
        border-bottom: 1px solid #dee2e6 !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    .card-body {
        padding: 20px !important;
    }
    
    /* =================== BADGES & STATUS INDICATORS =================== */
    
    /* Larger badges for mobile readability */
    .badge {
        font-size: 0.9rem !important;
        padding: 8px 12px !important;
        border-radius: 6px !important;
    }
    
    .badge-lg {
        font-size: 1rem !important;
        padding: 10px 15px !important;
    }
    
    /* =================== TYPOGRAPHY =================== */
    
    /* Mobile-optimized typography */
    h1 {
        font-size: 2rem !important;
        line-height: 1.3 !important;
    }
    
    h2 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    h3 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    h5 {
        font-size: 1.1rem !important;
        line-height: 1.4 !important;
    }
    
    /* Improve text readability */
    p, .text-muted {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }
    
    small {
        font-size: 0.875rem !important;
    }
    
    /* =================== DROPDOWN MENUS =================== */
    
    /* Mobile-friendly dropdowns */
    .dropdown-menu {
        font-size: 1rem !important;
        border-radius: 8px !important;
        border: none !important;
        box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
        min-width: 200px !important;
    }
    
    .dropdown-item {
        padding: 12px 20px !important;
        font-size: 1rem !important;
    }
    
    .dropdown-header {
        padding: 10px 20px !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
    }
    
    /* =================== ALERTS =================== */
    
    /* Mobile-optimized alerts */
    .alert {
        border-radius: 8px !important;
        padding: 15px 20px !important;
        margin-bottom: 20px !important;
        font-size: 1rem !important;
    }
    
    .alert .fas {
        margin-right: 10px !important;
    }
    
    /* =================== FIELD WORKER SPECIFIC =================== */
    
    /* Large touch targets for field workers */
    .btn-group .btn {
        min-width: 60px !important;
        min-height: 50px !important;
    }
    
    /* Improve visibility in bright sunlight */
    .bg-primary {
        background-color: #0056b3 !important; /* Darker blue */
    }
    
    .bg-success {
        background-color: #155724 !important; /* Darker green */
    }
    
    .bg-warning {
        background-color: #856404 !important; /* Darker yellow */
        color: white !important;
    }
    
    .bg-info {
        background-color: #0c5460 !important; /* Darker teal */
    }
    
    /* High contrast mode for outdoor use */
    .field-worker-mode {
        filter: contrast(1.2) brightness(1.1) !important;
    }
    
    /* =================== LOADING STATES =================== */
    
    /* Mobile-optimized loading spinners */
    .spinner-border {
        width: 3rem !important;
        height: 3rem !important;
        border-width: 4px !important;
    }
    
    /* =================== EXPORT FUNCTIONALITY =================== */
    
    /* Mobile export button optimization */
    .btn-group .dropdown-toggle {
        min-height: 50px !important;
        padding: 12px 20px !important;
    }
    
    /* =================== ACCESSIBILITY =================== */
    
    /* Ensure sufficient contrast ratios */
    .text-muted {
        color: #495057 !important; /* Darker gray for better readability */
    }
    
    /* Focus indicators for accessibility */
    button:focus,
    .btn:focus,
    input:focus,
    select:focus {
        outline: 3px solid #007bff !important;
        outline-offset: 2px !important;
    }
    
    /* =================== PREVENT ZOOM ON INPUTS (iOS) =================== */
    
    /* Prevent iOS zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* =================== TOUCH IMPROVEMENTS =================== */
    
    /* Improve touch interactions */
    .btn, .card, .badge, .dropdown-item {
        -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    }
    
    /* Smooth scrolling for mobile */
    html {
        scroll-behavior: smooth !important;
    }
    
    /* =================== LANDSCAPE ORIENTATION =================== */
    
    /* Optimize for landscape mobile */
    @media (max-width: 768px) and (orientation: landscape) {
        .hour-summary-cards .col-md-3 {
            flex: 0 0 50% !important;
            max-width: 50% !important;
        }
        
        .modal-dialog {
            max-height: 90vh !important;
            overflow-y: auto !important;
        }
    }
}

/* =================== EXTRA SMALL DEVICES (480px and below) =================== */

@media (max-width: 480px) {
    
    /* Single column layout for very small screens */
    .hour-summary-cards .col-md-3 {
        margin-bottom: 12px !important;
    }
    
    /* Compact table display */
    .table-responsive {
        font-size: 0.85rem !important;
    }
    
    .table-responsive th,
    .table-responsive td {
        padding: 8px 6px !important;
    }
    
    /* Stack navigation buttons */
    .d-flex.justify-content-between {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .d-flex.justify-content-between > div {
        width: 100% !important;
    }
    
    /* Full width buttons on very small screens */
    .btn {
        width: 100% !important;
        margin-bottom: 10px !important;
    }
    
    .btn-group {
        width: 100% !important;
        display: flex !important;
    }
    
    .btn-group .btn {
        flex: 1 !important;
    }
    
    /* Optimize modal for small screens */
    .modal-dialog {
        margin: 5px !important;
        max-width: calc(100% - 10px) !important;
        height: calc(100vh - 10px) !important;
    }
    
    .modal-content {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .modal-body {
        flex: 1 !important;
        overflow-y: auto !important;
    }
}

/* =================== PWA SPECIFIC (STANDALONE MODE) =================== */

/* Optimize for PWA standalone mode */
@media (display-mode: standalone) {
    .container {
        padding-top: 20px !important;
    }
    
    /* Account for safe areas on devices with notches */
    .container {
        padding-left: max(15px, env(safe-area-inset-left)) !important;
        padding-right: max(15px, env(safe-area-inset-right)) !important;
        padding-top: max(20px, env(safe-area-inset-top)) !important;
        padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
    }
}

/* =================== DARK MODE SUPPORT =================== */

/* Dark mode support for mobile devices */
@media (prefers-color-scheme: dark) {
    .card {
        background-color: #2d3748 !important;
        color: #e2e8f0 !important;
    }
    
    .table-responsive th {
        background-color: #4a5568 !important;
        color: #e2e8f0 !important;
    }
    
    .table-responsive {
        background-color: #2d3748 !important;
    }
    
    .modal-content {
        background-color: #2d3748 !important;
        color: #e2e8f0 !important;
    }
}

/* =================== PERFORMANCE OPTIMIZATIONS =================== */

/* GPU acceleration for smooth animations */
.clock-button,
.btn,
.card {
    transform: translateZ(0) !important;
    backface-visibility: hidden !important;
}

/* Optimize images and icons for mobile */
.fas, .far, .fab {
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

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

/* Hide non-essential elements when printing from mobile */
@media print {
    #clock-widget,
    .btn,
    .dropdown,
    .alert-dismissible {
        display: none !important;
    }
    
    .table-responsive {
        overflow: visible !important;
    }
    
    .table-responsive table {
        min-width: auto !important;
        font-size: 0.8rem !important;
    }
}

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

/* Mobile-specific utility classes */
.mobile-only {
    display: none !important;
}

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

/* Touch target size utilities */
.touch-target {
    min-height: 44px !important;
    min-width: 44px !important;
}

.touch-target-large {
    min-height: 60px !important;
    min-width: 60px !important;
}

/* Field worker specific utilities */
.field-worker-text {
    font-size: 1.1rem !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
}

.field-worker-button {
    min-height: 60px !important;
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
}

/* =================== ANIMATION PERFORMANCE =================== */

/* 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;
    }
}

/* =================== BROWSER-SPECIFIC FIXES =================== */

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .form-control,
    .form-select {
        -webkit-appearance: none !important;
        border-radius: 8px !important;
    }
    
    /* Fix iOS Safari viewport units */
    .modal-dialog {
        height: -webkit-fill-available !important;
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    input[type="date"]::-webkit-calendar-picker-indicator {
        font-size: 20px !important;
        padding: 5px !important;
    }
}

