/**
 * Mobile-First Responsive Enhancements
 * Touch-friendly interactions and improved mobile UX
 */

/* Enhanced Touch Targets */
@media (max-width: 768px) {
    /* Minimum 44x44px touch targets */
    .btn, .nav-link, .theme-toggle, button, 
    input[type="button"], input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Enhanced navigation for mobile */
    .nav-container {
        height: 60px; /* Slightly smaller for mobile */
        padding: 0 var(--space-3);
    }

    .nav-brand {
        font-size: var(--font-size-lg);
    }

    .nav-brand span {
        display: none; /* Show icon only on very small screens */
    }

    .nav-menu {
        gap: var(--space-1);
    }

    .nav-link {
        flex-direction: column;
        padding: var(--space-2) var(--space-2);
        border-radius: var(--radius);
        position: relative;
        min-width: 48px;
        height: 48px;
        justify-content: center;
        align-items: center;
    }

    .nav-link span {
        position: absolute;
        bottom: -12px;
        font-size: 10px;
        line-height: 1;
        opacity: 0.8;
        white-space: nowrap;
    }

    .nav-link i {
        font-size: 1.1em;
        margin-bottom: 2px;
    }

    /* Hero section mobile optimization */
    .hero {
        padding: var(--space-8) var(--space-4) var(--space-6);
        min-height: 50vh;
        display: flex;
        align-items: center;
    }

    .hero-title {
        font-size: clamp(1.5rem, 4vw, 2.5rem);
        margin-bottom: var(--space-4);
    }

    .hero-subtitle {
        font-size: var(--font-size-base);
        margin-bottom: var(--space-6);
    }

    .hero-search {
        max-width: 100%;
    }

    /* Improved mobile search box */
    .search-box-hero {
        padding: var(--space-2);
        flex-direction: row;
        align-items: center;
        gap: var(--space-2);
    }

    .search-input-hero {
        min-height: 44px;
        padding: var(--space-3) var(--space-4) var(--space-3) var(--space-12);
        font-size: var(--font-size-base);
    }

    .search-btn-hero {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        flex-shrink: 0;
        border-radius: var(--radius);
    }

    /* Form improvements */
    .form-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .form-group label {
        font-size: var(--font-size-sm);
    }

    .form-group input,
    .form-group textarea {
        min-height: 44px;
        padding: var(--space-3) var(--space-4);
        font-size: var(--font-size-base);
    }

    /* Better mobile modals */
    .confirmation-modal-content {
        width: 95%;
        max-width: 350px;
        margin: var(--space-4);
    }

    .confirmation-modal-header,
    .confirmation-modal-body {
        padding: var(--space-4);
    }

    .confirmation-modal-actions {
        flex-direction: column;
        gap: var(--space-3);
    }

    .confirmation-modal-actions .btn {
        width: 100%;
        min-height: 48px;
    }

    /* Mobile-optimized file upload */
    .file-upload-area {
        padding: var(--space-6);
        min-height: 120px;
    }

    .upload-text p {
        font-size: var(--font-size-base);
    }

    /* Item cards mobile layout */
    .item-card {
        grid-template-columns: 80px 1fr;
        gap: var(--space-3);
        padding: var(--space-4);
    }

    .item-image {
        width: 80px;
        height: 80px;
    }

    .item-actions {
        grid-column: 1 / -1;
        flex-direction: row;
        gap: var(--space-2);
        margin-top: var(--space-3);
        justify-content: center;
        flex-wrap: wrap;
    }

    .item-actions .btn {
        flex: 1;
        min-width: 120px;
        min-height: 40px;
    }

    /* Toast notifications mobile */
    .toast-container {
        left: var(--space-3);
        right: var(--space-3);
        top: 80px;
        max-width: none;
    }

    .toast {
        padding: var(--space-3);
    }

    /* Stats grid mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .stat-card {
        padding: var(--space-6);
        text-align: center;
    }
}

/* Very small screens (phones in portrait) */
@media (max-width: 480px) {
    .nav-brand span {
        display: none;
    }

    .nav-container {
        padding: 0 var(--space-2);
    }

    .nav-link {
        min-width: 40px;
        height: 40px;
        padding: var(--space-1);
    }

    .nav-link span {
        font-size: 9px;
        bottom: -10px;
    }

    .hero {
        padding: var(--space-6) var(--space-3) var(--space-4);
        text-align: center;
    }

    .hero-title {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    .container {
        padding: 0 var(--space-3);
    }

    .section-header h2 {
        font-size: var(--font-size-xl);
        flex-direction: column;
        gap: var(--space-1);
    }

    /* Form adjustments for very small screens */
    .form-container {
        padding: var(--space-4);
    }

    .form-actions {
        flex-direction: column;
        gap: var(--space-3);
    }

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

    /* Search controls mobile */
    .search-controls {
        padding: var(--space-4);
    }

    .filter-controls {
        flex-direction: column;
        gap: var(--space-3);
        align-items: stretch;
    }

    .filter-select,
    .filter-controls .btn {
        width: 100%;
        min-height: 44px;
        text-align: center;
    }

    /* Map controls mobile */
    .map-controls {
        flex-direction: column;
        gap: var(--space-3);
    }

    .date-filter-group {
        flex-direction: column;
        gap: var(--space-3);
        width: 100%;
    }

    .date-input-group {
        width: 100%;
        justify-content: space-between;
    }

    .date-input {
        flex: 1;
        margin-left: var(--space-2);
    }

    .main-map {
        height: 350px;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: 40vh;
        padding: var(--space-6) var(--space-4);
    }

    .main-map {
        height: 300px;
    }
}

/* Touch-specific enhancements */
@media (pointer: coarse) {
    /* Larger touch targets for touch devices */
    .btn {
        min-height: 48px;
        padding: var(--space-3) var(--space-6);
    }

    .nav-link {
        min-height: 48px;
        min-width: 48px;
    }

    /* Better hover states for touch */
    .btn:hover,
    .nav-link:hover {
        transform: none; /* Remove hover animations on touch devices */
    }

    /* Focus states more prominent on touch */
    .form-group input:focus,
    .form-group textarea:focus {
        border-width: 3px;
        outline: 3px solid var(--primary-200);
        outline-offset: 2px;
    }

    /* Larger close buttons */
    .confirmation-modal-close,
    .toast-close {
        min-width: 44px;
        min-height: 44px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --text-muted: var(--text-secondary);
    }

    .status-badge {
        border-width: 2px;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .hero::before {
        animation: none;
    }

    .detective-glass {
        animation: none;
    }
}

/* Focus visible enhancements */
.btn:focus-visible,
.nav-link:focus-visible,
.theme-toggle:focus-visible {
    outline: 3px solid var(--primary-600);
    outline-offset: 2px;
    border-radius: var(--radius);
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-600);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: var(--radius);
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* Print optimizations for mobile */
@media print {
    .nav-container {
        height: auto;
        padding: var(--space-2) 0;
    }

    .hero {
        display: none;
    }

    .item-card {
        break-inside: avoid;
        margin-bottom: var(--space-4);
        grid-template-columns: 60px 1fr;
        gap: var(--space-2);
        padding: var(--space-3);
    }

    .item-image {
        width: 60px;
        height: 60px;
    }
}

/* Dark mode mobile adjustments */
@media (max-width: 768px) {
    [data-theme="dark"] .search-box-hero {
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(10px);
    }

    [data-theme="dark"] .upload-status {
        background: rgba(15, 23, 42, 0.98);
    }
}

/* Sticky navigation enhancement for mobile */
@media (max-width: 768px) {
    .navbar {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-primary);
        border-bottom: none;
        padding: var(--space-2) 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    [data-theme="dark"] .navbar {
        background: rgba(15, 23, 42, 0.98);
        border-top: 1px solid var(--border-primary);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .main-content {
        margin-top: 0;
        margin-bottom: 80px; /* Space for bottom navigation */
    }

    .nav-container {
        height: 70px;
        max-width: 100%;
        justify-content: space-around;
        padding: 0 var(--space-2);
    }

    .nav-brand {
        position: absolute;
        top: -50px;
        left: 50%;
        transform: translateX(-50%);
        background: var(--primary-600);
        color: white;
        padding: var(--space-2) var(--space-4);
        border-radius: var(--radius-xl);
        font-size: var(--font-size-sm);
        box-shadow: var(--shadow-lg);
        opacity: 0;
        pointer-events: none;
        transition: all var(--transition-normal);
    }

    .nav-brand.show {
        opacity: 1;
        top: -40px;
    }
}