/**
 * Toad Patrol Mobile Optimizations
 * iOS and Android specific enhancements
 * Using modern CSS: Grid, Flexbox, logical properties
 * Version: 1.1.0
 */

/* ========================================
   MOBILE VIEWPORT & SAFE AREAS
======================================== */

/* iOS Safe Area Support - using logical properties */
@supports (padding: max(0px)) {

    /* Form container - Grid for centering */
    .toad-patrol-form-container {
        display: grid;
        place-items: center;
        padding-inline: max(15px, env(safe-area-inset-left));
        padding-block-end: max(15px, env(safe-area-inset-bottom));
        margin-inline: auto;
        width: 100%;
    }

    .toad-patrol-report-container,
    .toad-patrol-map-container {
        padding-inline: max(15px, env(safe-area-inset-left));
        padding-block-end: max(15px, env(safe-area-inset-bottom));
    }

    .toad-map-header,
    .toad-map-filters {
        padding-inline: max(15px, env(safe-area-inset-left));
    }
}

/* Global box-sizing for all form elements */
.toad-patrol-form-container,
.toad-patrol-form-container * {
    box-sizing: border-box;
}

/* Prevent zoom on input focus (iOS) */
.toad-form-group input,
.toad-form-group select,
.toad-form-group textarea {
    font-size: 16px !important;
}

/* ========================================
   MOBILE MAP OPTIMIZATIONS
======================================== */

@media (max-width: 768px) {

    /* Full-screen map on mobile */
    .toad-patrol-map-container {
        margin: 0 -20px;
        padding: 0;
    }

    #toad-heatmap {
        height: 400px !important;
        min-height: 400px;
        border-radius: 0;
    }

    .toad-form-map,
    #toad-report-map {
        height: 300px !important;
        min-height: 300px;
        border-radius: 8px;
        margin: 15px 0;
        /* Better touch handling */
        touch-action: pan-x pan-y;
    }

    /* Map controls larger for touch */
    .leaflet-control-zoom a {
        width: 40px !important;
        height: 40px !important;
        line-height: 40px !important;
        font-size: 20px !important;
    }

    .leaflet-bar {
        border-radius: 8px;
    }

    /* Popup adjustments */
    .leaflet-popup-content-wrapper {
        border-radius: 12px;
        max-width: 280px;
    }

    .leaflet-popup-content {
        margin: 15px;
        font-size: 14px;
    }

    /* Map header sticky on scroll */
    .toad-map-header {
        position: sticky;
        top: 0;
        z-index: 999;
        background: white;
        padding: 15px;
        margin: 0;
        border-bottom: 2px solid #e0e0e0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .toad-map-header h2 {
        font-size: 18px;
        margin: 0;
    }

    .toad-map-header .toad-btn {
        font-size: 14px;
        padding: 10px 16px;
    }
}

/* ========================================
   MOBILE FILTERS
   ======================================== */

@media (max-width: 768px) {
    .toad-map-filters {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        background: #f8f9fa;
        border-bottom: 2px solid #e0e0e0;
    }

    .toad-filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .toad-filter-group label:first-child {
        font-weight: 600;
        margin-bottom: 5px;
    }

    .toad-checkbox-inline {
        padding: 12px;
        background: white;
        border-radius: 8px;
        margin: 0;
        width: 100%;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .toad-checkbox-inline input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }

    .toad-checkbox-inline span {
        font-size: 15px;
    }

    /* Date filters full width */
    .toad-filter-group input[type="date"] {
        flex: 1;
        min-width: 120px;
        padding: 10px;
        font-size: 14px;
        border: 1px solid #ddd;
        border-radius: 6px;
    }

    .toad-filter-group button {
        width: 100%;
        margin-top: 10px;
        min-height: 44px;
    }
}

/* ========================================
   MOBILE REPORT FORM
   ======================================== */

@media (max-width: 768px) {
    .toad-patrol-report-container {
        padding: 0;
    }

    .toad-report-header {
        padding: 20px;
        background: linear-gradient(135deg, #2e7d32 0%, #4caf50 100%);
        color: white;
        margin: 0 0 20px;
    }

    .toad-report-header h1 {
        font-size: 22px;
        margin: 0 0 10px;
        color: white;
    }

    .toad-report-header p {
        font-size: 14px;
        margin: 0;
        color: rgba(255, 255, 255, 0.9);
    }

    .toad-report-form-container {
        padding: 0 15px 20px;
    }

    /* Form sections spacing */
    .toad-form-section {
        padding: 20px 0;
        margin-bottom: 0;
    }

    .toad-form-section h3 {
        font-size: 18px;
        margin-bottom: 15px;
        position: sticky;
        top: 0;
        background: white;
        padding: 10px 0;
        z-index: 10;
    }

    /* Radio cards stack vertically */
    .toad-radio-group {
        flex-direction: column;
        gap: 12px;
    }

    .toad-radio-card {
        width: 100%;
        min-width: 100%;
    }

    .toad-radio-content {
        flex-direction: row;
        text-align: left;
        padding: 15px;
        gap: 15px;
    }

    .toad-radio-icon {
        flex-shrink: 0;
        width: 44px;
        height: 44px;
    }

    .toad-radio-label {
        display: block;
        font-size: 16px;
    }

    .toad-radio-desc {
        display: block;
        font-size: 13px;
    }

    /* Touch-friendly inputs */
    .toad-form-group input,
    .toad-form-group select,
    .toad-form-group textarea {
        padding: 14px 16px;
        font-size: 16px;
        min-height: 48px;
    }

    .toad-form-group textarea {
        min-height: 120px;
    }

    /* Number inputs with larger touch targets */
    .toad-form-group input[type="number"] {
        -webkit-appearance: none;
        -moz-appearance: textfield;
    }

    /* Photo upload larger */
    .toad-photo-upload {
        padding: 30px;
        min-height: 120px;
    }

    .toad-photo-preview img {
        max-width: 100%;
        border-radius: 8px;
    }
}

/* ========================================
   MOBILE GPS & LOCATION
   ======================================== */

@media (max-width: 768px) {

    /* Quick report button prominent */
    .toad-quick-report-mobile {
        display: block !important;
        position: sticky;
        top: 0;
        z-index: 999;
        margin: 0 -15px 20px;
        padding: 20px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 0;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        animation: pulse 2s ease-in-out infinite;
    }

    @keyframes pulse {

        0%,
        100% {
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        }

        50% {
            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
        }
    }

    .toad-quick-report-mobile .toad-btn {
        width: 100%;
        min-height: 56px;
        font-size: 18px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 1px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }

    #use-my-location {
        width: 100%;
        min-height: 52px;
        font-size: 16px;
        font-weight: 600;
    }

    .toad-gps-status {
        padding: 12px;
        font-size: 14px;
        border-radius: 8px;
        margin-top: 12px;
    }

    /* Lat/Long inputs in grid */
    .toad-form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .toad-form-half {
        min-width: 0;
    }

    .toad-form-group label {
        font-size: 14px;
    }

    /* Readonly inputs styled differently */
    .toad-form-group input[readonly] {
        background: #f5f5f5;
        color: #666;
        cursor: not-allowed;
    }
}

/* ========================================
   MOBILE DASHBOARD
   ======================================== */

@media (max-width: 768px) {
    .toad-patrol-dashboard {
        padding: 15px;
    }

    .toad-dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        margin-bottom: 20px;
    }

    .toad-user-welcome {
        flex-direction: row;
        align-items: center;
        gap: 15px;
        width: 100%;
    }

    .toad-user-avatar img {
        width: 60px;
        height: 60px;
    }

    .toad-user-info h1 {
        font-size: 20px;
    }

    .toad-dashboard-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .toad-dashboard-actions .toad-btn {
        width: 100%;
        justify-content: center;
    }

    /* Chat Button - Prominent on Mobile */
    .toad-dashboard-actions .toad-btn-chat {
        background: linear-gradient(135deg, #0084ff 0%, #0066cc 100%);
        font-size: 18px;
        padding: 16px;
        font-weight: 600;
        position: relative;
        animation: chatPulse 3s infinite;
    }

    @keyframes chatPulse {

        0%,
        100% {
            box-shadow: 0 2px 8px rgba(0, 132, 255, 0.3);
        }

        50% {
            box-shadow: 0 4px 16px rgba(0, 132, 255, 0.5);
        }
    }

    .toad-unread-badge {
        font-size: 14px;
        padding: 3px 10px;
        min-width: 24px;
    }

    /* Stats grid responsive */
    .toad-dashboard-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .toad-stat-card {
        padding: 20px;
    }

    .toad-map-stats {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }

    .toad-map-stat {
        padding: 15px;
        border-radius: 8px;
    }
}

/* ========================================
   MOBILE MAP LEGEND
   ======================================== */

@media (max-width: 768px) {
    .toad-map-legend {
        padding: 15px;
        font-size: 13px;
        border-radius: 0;
        margin: 0;
    }

    .toad-legend-item {
        padding: 8px 0;
    }

    .toad-legend-color {
        height: 8px;
        border-radius: 4px;
    }

    .toad-legend-label {
        font-size: 13px;
    }

    .toad-marker-icon {
        width: 20px;
        height: 20px;
    }
}

/* ========================================
   TOUCH INTERACTIONS
   ======================================== */

/* Remove hover effects on touch devices */
@media (hover: none) {
    .toad-btn:hover {
        transform: none;
    }

    .toad-radio-content:hover {
        background: inherit;
    }

    .toad-stat-card:hover {
        transform: none;
    }
}

/* Active states for touch */
.toad-btn:active {
    transform: scale(0.97);
}

.toad-radio-card:active .toad-radio-content {
    transform: scale(0.98);
}

/* Prevent text selection during drag */
.toad-form-map,
#toad-heatmap {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ========================================
   BOTTOM SHEET / MODAL (Mobile)
   ======================================== */

@media (max-width: 768px) {

    /* Modal full-screen on mobile */
    .toad-modal-content {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
    }

    .toad-modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .toad-modal-footer {
        position: sticky;
        bottom: 0;
        background: white;
        box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
        padding: 15px;
    }

    .toad-modal-footer .toad-btn {
        width: 100%;
        margin: 5px 0;
    }
}

/* ========================================
   FORM VALIDATION MESSAGES
   ======================================== */

@media (max-width: 768px) {
    .toad-form-messages {
        position: sticky;
        top: 0;
        z-index: 100;
        margin: 0 -15px 15px;
        border-radius: 0;
    }

    .toad-notice {
        padding: 15px;
        border-radius: 0;
        font-size: 14px;
        line-height: 1.5;
    }
}

/* ========================================
   LOADING STATES
   ======================================== */

@media (max-width: 768px) {

    /* Full-screen loading overlay */
    .toad-loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.95);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        z-index: 9999;
        padding: 20px;
    }

    .toad-loading-spinner {
        width: 60px;
        height: 60px;
        border: 4px solid rgba(46, 125, 50, 0.2);
        border-top-color: #2e7d32;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

    .toad-loading-text {
        margin-top: 20px;
        font-size: 16px;
        color: #666;
        text-align: center;
    }
}

/* ========================================
   OFFLINE DETECTION
   ======================================== */

.toad-offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff6b6b;
    color: white;
    padding: 12px;
    text-align: center;
    font-weight: 600;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

/* ========================================
   iOS SPECIFIC FIXES
   ======================================== */

/* Fix iOS input zoom */
@supports (-webkit-touch-callout: none) {

    .toad-form-group input,
    .toad-form-group select,
    .toad-form-group textarea {
        font-size: 16px !important;
    }
}

/* Fix iOS button styling */
input[type="submit"],
input[type="button"],
button {
    -webkit-appearance: none;
    border-radius: 8px;
}

/* ========================================
   ANDROID SPECIFIC FIXES
   ======================================== */

/* Better checkbox/radio rendering */
@media (max-width: 768px) {

    input[type="checkbox"],
    input[type="radio"] {
        width: 22px;
        height: 22px;
    }
}

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

@media (max-width: 768px) and (orientation: landscape) {

    .toad-form-map,
    #toad-report-map {
        height: 200px !important;
    }

    #toad-heatmap {
        height: 300px !important;
    }

    .toad-quick-report-mobile {
        padding: 12px;
    }

    .toad-quick-report-mobile .toad-btn {
        min-height: 44px;
        font-size: 14px;
    }

    .toad-report-header {
        padding: 15px;
    }

    .toad-report-header h1 {
        font-size: 18px;
    }
}

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

@media (max-width: 768px) {

    /* Larger tap targets (iOS HIG: 44x44, Material: 48x48) */
    .toad-btn,
    button,
    a.toad-btn,
    input[type="submit"] {
        min-height: 48px;
        min-width: 48px;
    }

    /* Better focus indicators */
    .toad-form-group input:focus,
    .toad-form-group select:focus,
    .toad-form-group textarea:focus {
        outline: 3px solid rgba(46, 125, 50, 0.4);
        outline-offset: 2px;
    }

    /* Skip to content link */
    .toad-skip-link {
        position: absolute;
        top: -40px;
        left: 0;
        background: #2e7d32;
        color: white;
        padding: 12px 20px;
        z-index: 10001;
        text-decoration: none;
        border-radius: 0 0 8px 0;
    }

    .toad-skip-link:focus {
        top: 0;
    }
}

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

/* Hardware acceleration for animations */
.toad-btn,
.toad-radio-content,
.toad-stat-card,
.leaflet-tile {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    @media (max-width: 768px) {

        .toad-map-header,
        .toad-form-section h3 {
            background: #1e1e1e;
            color: #ffffff;
        }

        .toad-form-group input,
        .toad-form-group select,
        .toad-form-group textarea {
            background: #2d2d2d;
            color: #ffffff;
            border-color: #444;
        }
    }
}

/* ========================================
   MOBILE ENHANCEMENTS - NEW FEATURES
   ======================================== */

@media (max-width: 768px) {

    /* QUICK TEMPLATES - Mobile Optimized */
    .toad-quick-templates {
        margin: 0 -20px 20px -20px;
        padding: 20px;
        background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
        border-radius: 0;
        border-left: 4px solid #2e7d32;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .toad-quick-templates h3 {
        font-size: 16px;
        margin: 0 0 15px 0;
        color: #1b5e20;
        font-weight: 600;
    }

    .toad-template-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .toad-template-btn {
        min-height: 80px;
        padding: 12px 8px;
        font-size: 13px;
        border-radius: 12px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }

    .toad-template-btn:active {
        transform: scale(0.95);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }

    .toad-template-btn .dashicons {
        font-size: 28px;
        width: 28px;
        height: 28px;
        margin-bottom: 6px;
    }

    /* DRAFT STATUS - Mobile Position */
    .toad-draft-status {
        position: fixed;
        bottom: 70px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1000;
        padding: 10px 20px;
        border-radius: 20px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        font-size: 14px;
        min-width: 200px;
        text-align: center;
    }

    /* OFFLINE BANNER - Sticky Top */
    .toad-offline-banner {
        position: sticky;
        top: 0;
        z-index: 999;
        margin: 0 -20px;
        border-radius: 0;
        padding: 15px 20px;
        font-size: 14px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from {
            transform: translateY(-100%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .toad-offline-banner .dashicons {
        font-size: 24px;
        width: 24px;
        height: 24px;
    }

    /* DUPLICATE WARNING - Enhanced Mobile */
    .toad-warning-banner {
        margin: 0 -20px 20px -20px;
        padding: 15px 20px;
        border-radius: 0;
        border-left: 4px solid #ffc107;
        font-size: 14px;
        line-height: 1.6;
        animation: shakeWarning 0.5s ease;
    }

    @keyframes shakeWarning {

        0%,
        100% {
            transform: translateX(0);
        }

        25% {
            transform: translateX(-5px);
        }

        75% {
            transform: translateX(5px);
        }
    }

    .toad-warning-banner strong {
        display: block;
        font-size: 15px;
        margin-bottom: 5px;
    }

    /* GPS ACCURACY INDICATOR - Mobile Layout */
    .toad-gps-accuracy {
        margin: 15px -5px;
        padding: 15px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .toad-gps-accuracy .accuracy-label {
        font-size: 14px;
        margin-bottom: 10px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .toad-gps-accuracy .accuracy-bar {
        height: 24px;
        border-radius: 12px;
        margin-bottom: 10px;
    }

    .toad-gps-accuracy .accuracy-text {
        font-size: 14px;
        font-weight: 700;
    }

    /* RESTORE DRAFT BUTTON - Prominent Mobile */
    #restore-draft-btn {
        display: block;
        width: 100%;
        margin: 15px 0;
        padding: 15px;
        font-size: 16px;
        border-radius: 12px;
        background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
        animation: pulse 2s infinite;
    }

    @keyframes pulse {

        0%,
        100% {
            transform: scale(1);
        }

        50% {
            transform: scale(1.02);
        }
    }

    #restore-draft-btn .dashicons {
        font-size: 20px;
        width: 20px;
        height: 20px;
        vertical-align: middle;
        margin-right: 8px;
    }

    /* PHOTO PREVIEW - Full Width Mobile */
    .toad-photo-preview {
        margin: 15px -5px;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .toad-photo-preview img {
        width: 100%;
        height: auto;
        max-height: 400px;
        object-fit: cover;
        display: block;
    }

    /* PHOTO UPLOAD BUTTON - Larger Touch Target + Camera Styling */
    #upload-photo-btn {
        width: 100%;
        min-height: 56px;
        font-size: 18px;
        font-weight: 600;
        border-radius: 12px;
        margin: 10px 0;
        background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
        color: white;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
        transition: all 0.3s ease;
    }

    #upload-photo-btn:active {
        transform: scale(0.95);
        box-shadow: 0 2px 8px rgba(33, 150, 243, 0.4);
    }

    #upload-photo-btn .dashicons {
        font-size: 28px;
        width: 28px;
        height: 28px;
        margin-right: 0;
    }

    /* User Messages Mobile */
    .toad-user-message {
        top: 70px;
        min-width: auto;
        max-width: 85%;
        font-size: 16px;
        padding: 16px 20px;
    }

    .toad-user-message .message-icon {
        font-size: 20px;
    }

    /* TIME INPUT - Better Mobile UX */
    input[type="datetime-local"] {
        width: 100%;
        min-height: 48px;
        font-size: 16px;
        padding: 12px;
        border-radius: 8px;
        border: 2px solid #ddd;
        background: white;
        -webkit-appearance: none;
        appearance: none;
    }

    input[type="datetime-local"]:focus {
        border-color: #2e7d32;
        outline: none;
        box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
    }

    /* REPORT HEADER - Mobile Spacing */
    .toad-report-header {
        padding: 20px 0;
        text-align: center;
    }

    .toad-report-header h1 {
        font-size: 24px;
        margin: 0 0 10px 0;
        line-height: 1.3;
    }

    .toad-report-header p {
        font-size: 14px;
        color: #666;
        margin: 0 0 15px 0;
    }

    /* FORM SECTIONS - Mobile Cards */
    .toad-form-section {
        background: white;
        margin: 0 -20px 20px -20px;
        padding: 20px;
        border-top: 3px solid #2e7d32;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }

    .toad-form-section h3 {
        font-size: 18px;
        margin: 0 0 15px 0;
        color: #2e7d32;
        font-weight: 600;
        display: flex;
        align-items: center;
    }

    .toad-form-section h3::before {
        content: '';
        display: inline-block;
        width: 4px;
        height: 20px;
        background: #2e7d32;
        margin-right: 10px;
        border-radius: 2px;
    }

    /* FORM MESSAGES - Mobile Toast */
    .toad-form-messages {
        position: fixed;
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 9999;
        min-width: 280px;
        max-width: 90%;
        padding: 15px 20px;
        border-radius: 12px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
        animation: slideInDown 0.3s ease;
    }

    @keyframes slideInDown {
        from {
            transform: translate(-50%, -100px);
            opacity: 0;
        }

        to {
            transform: translate(-50%, 0);
            opacity: 1;
        }
    }

    /* SUBMIT BUTTON - Fixed Bottom on Mobile */
    .toad-form-group.toad-form-submit {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 20px -20px -20px -20px;
        padding: 15px 20px;
        background: white;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .toad-form-submit button[type="submit"] {
        width: 100%;
        min-height: 56px;
        font-size: 18px;
        border-radius: 12px;
        background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
        box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
    }

    .toad-form-submit button[type="submit"]:active {
        transform: scale(0.98);
    }

    /* MAP ON MOBILE - Better Touch Handling */
    #toad-report-map {
        height: 250px !important;
        margin: 15px -5px;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        border: 2px solid #e0e0e0;
    }

    /* GPS BUTTON - Prominent on Mobile */
    #use-my-location {
        width: 100%;
        min-height: 56px;
        font-size: 16px;
        background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
        color: white;
        border: none;
        border-radius: 12px;
        margin: 15px 0;
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    }

    #use-my-location .dashicons {
        font-size: 24px;
        width: 24px;
        height: 24px;
        margin-right: 8px;
        animation: pulse-location 2s infinite;
    }

    @keyframes pulse-location {

        0%,
        100% {
            opacity: 1;
        }

        50% {
            opacity: 0.7;
        }
    }

    /* GPS STATUS - Mobile Feedback */
    .toad-gps-status {
        font-size: 14px;
        padding: 12px 15px;
        border-radius: 8px;
        margin: 10px 0;
    }

    /* RADIO CARDS - Mobile Touch Optimized */
    .toad-radio-card {
        min-height: 72px;
        margin-bottom: 12px;
        border-radius: 12px;
        padding: 15px;
    }

    .toad-radio-card input[type="radio"] {
        width: 24px;
        height: 24px;
    }

    .toad-radio-content {
        padding-left: 15px;
    }

    .toad-radio-icon .dashicons {
        font-size: 28px;
        width: 28px;
        height: 28px;
    }

    .toad-radio-label {
        font-size: 16px;
        font-weight: 600;
    }

    .toad-radio-desc {
        font-size: 13px;
        line-height: 1.4;
    }

    /* CONTAINER ADJUSTMENTS */
    .toad-patrol-report-container {
        padding: 0;
        max-width: 100%;
    }

    .toad-report-grid {
        display: block;
    }

    .toad-report-form-container {
        padding: 0 20px;
    }

    /* WHAT3WORDS - Mobile Compact */
    .toad-input-with-icon {
        position: relative;
    }

    .toad-input-with-icon input {
        padding-right: 45px;
    }

    .toad-input-with-icon .dashicons {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 20px;
        width: 20px;
        height: 20px;
        color: #2e7d32;
    }

    /* LOADING STATES - Mobile */
    .btn-loading {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .spinner {
        border: 3px solid rgba(255, 255, 255, 0.3);
        border-top-color: white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        animation: spin 0.6s linear infinite;
        margin-right: 10px;
    }

    @keyframes spin {
        to {
            transform: rotate(360deg);
        }
    }

    /* HAPTIC FEEDBACK SIMULATION */
    .toad-template-btn:active,
    .toad-btn:active,
    button:active {
        animation: haptic 0.1s ease;
    }

    @keyframes haptic {

        0%,
        100% {
            transform: scale(1);
        }

        50% {
            transform: scale(0.95);
        }
    }

    /* PWA INSTALL PROMPT */
    .toad-pwa-prompt {
        position: fixed;
        bottom: 20px;
        left: 20px;
        right: 20px;
        background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
        color: white;
        padding: 15px 20px;
        border-radius: 12px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
        z-index: 9999;
        display: flex;
        align-items: center;
        gap: 15px;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* ACCESSIBILITY - Enhanced Focus Indicators */
    *:focus-visible {
        outline: 3px solid #2e7d32;
        outline-offset: 2px;
        border-radius: 4px;
    }

    /* Remove default outline for mouse users */
    *:focus:not(:focus-visible) {
        outline: none;
    }

    /* UNDO & REMOVE FEATURES - Mobile Enhanced */
    .toad-undo-btn {
        position: fixed;
        bottom: 80px;
        right: 20px;
        z-index: 999;
        padding: 12px 20px;
        font-size: 15px;
        box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
        min-width: 120px;
    }

    .photo-remove-btn {
        width: 44px;
        height: 44px;
        top: 8px;
        right: 8px;
    }

    .photo-remove-btn .dashicons {
        font-size: 24px;
        width: 24px;
        height: 24px;
    }

    /* Context Menu Mobile */
    .toad-context-menu {
        min-width: 200px;
        border: 2px solid #e0e0e0;
    }

    .context-menu-item {
        padding: 16px 20px;
        font-size: 16px;
        min-height: 52px;
    }

    /* Template Active Indicator */
    .toad-template-btn.toad-template-active {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(46, 125, 50, 0.4);
    }

    .toad-template-btn.toad-template-active::after {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }

    /* Long Press Hint */
    .toad-template-btn.toad-template-active::before {
        content: 'Long press to clear';
        position: absolute;
        bottom: -25px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 4px 10px;
        border-radius: 4px;
        font-size: 11px;
        white-space: nowrap;
        animation: fadeInOut 3s ease;
        pointer-events: none;
    }

    @keyframes fadeInOut {

        0%,
        100% {
            opacity: 0;
        }

        10%,
        90% {
            opacity: 1;
        }
    }

    /* Photo Preview Mobile Enhanced */
    .toad-photo-preview {
        position: relative;
        margin: 15px 0;
    }

    .toad-photo-preview img {
        width: 100%;
        max-height: 400px;
        object-fit: cover;
        border-radius: 12px;
        cursor: pointer;
    }

    /* Swipe to Remove Hint */
    .toad-photo-preview::after {
        content: 'Tap X or long-press to remove';
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 6px 12px;
        border-radius: 4px;
        font-size: 12px;
        white-space: nowrap;
        animation: fadeInOut 3s ease;
        pointer-events: none;
    }
}

/* Extra Small Devices (< 375px) */
@media (max-width: 374px) {
    .toad-template-buttons {
        gap: 8px;
    }

    .toad-template-btn {
        min-height: 70px;
        font-size: 12px;
        padding: 10px 6px;
    }

    .toad-template-btn .dashicons {
        font-size: 24px;
        width: 24px;
        height: 24px;
    }

    .toad-report-header h1 {
        font-size: 20px;
    }

    .toad-form-section h3 {
        font-size: 16px;
    }
}

/* Landscape Mode Optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    #toad-report-map {
        height: 200px !important;
    }

    .toad-quick-templates {
        margin-bottom: 15px;
    }

    .toad-form-section {
        margin-bottom: 15px;
    }

    .toad-form-group.toad-form-submit {
        position: relative;
        margin: 15px 0;
    }
}
