/* Mobile optimization for all interfaces */
@media (max-width: 640px) {
    /* General mobile styles */
    body {
        font-size: 14px;
        line-height: 1.4;
    }
    
    /* Ensure minimum touch target size */
    button, input, select, textarea, a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Improve form fields for mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px !important;
        border-radius: 8px !important;
    }
    
    /* Better button sizing */
    button {
        padding: 12px 16px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
    }
    
    /* Responsive containers */
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    
    /* Better spacing for mobile */
    .space-y-4 > * + * {
        margin-top: 12px !important;
    }
    
    /* Mobile-friendly tables */
    table {
        font-size: 14px;
    }
    
    /* Floating buttons positioning */
    .fixed {
        position: fixed;
    }
    
    /* Better modal/form sizing */
    .modal, .form-container {
        margin: 16px !important;
        width: calc(100% - 32px) !important;
        max-width: none !important;
    }
    
    /* Improve text readability */
    h1 {
        font-size: 24px !important;
        line-height: 1.3 !important;
    }
    
    h2 {
        font-size: 20px !important;
        line-height: 1.3 !important;
    }
    
    h3 {
        font-size: 18px !important;
        line-height: 1.3 !important;
    }
    
    /* Better grid layouts for mobile */
    .grid {
        gap: 12px !important;
    }
    
    /* Ensure proper overflow handling */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
}

/* Tablet optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
    /* Medium screens optimizations */
    .container {
        max-width: 100% !important;
        padding-left: 24px !important;
        padding-right: 24px !important;
    }
    
    /* Better grid layouts for tablets */
    .grid-cols-1.md\\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-cols-1.md\\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Better touch targets */
    button:hover,
    a:hover,
    input:hover,
    select:hover {
        background-color: inherit;
        transform: none;
    }
    
    /* Remove hover effects on touch devices */
    .hover\\:bg-red-600:hover {
        background-color: #dc2626;
    }
    
    .hover\\:bg-orange-600:hover {
        background-color: #ea580c;
    }
    
    .hover\\:bg-gray-600:hover {
        background-color: #4b5563;
    }
}

/* Landscape mobile orientation */
@media (max-width: 896px) and (orientation: landscape) {
    /* Adjust for landscape mode */
    .fixed.top-4 {
        top: 8px !important;
    }
    
    .fixed.bottom-4 {
        bottom: 8px !important;
    }
    
    /* Reduce padding in landscape */
    .p-4 {
        padding: 8px !important;
    }
    
    .p-6 {
        padding: 12px !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Crisp borders and shadows */
    .border {
        border-width: 0.5px;
    }
    
    .shadow-lg {
        box-shadow: 0 5px 15px -3px rgba(0, 0, 0, 0.1), 0 2px 6px -2px rgba(0, 0, 0, 0.05);
    }
}

/* Dark mode support (if user prefers) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed in the future */
    .bg-white {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .text-gray-700 {
        color: #d1d5db;
    }
    
    .text-gray-600 {
        color: #e5e7eb;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    /* Remove animations for users who prefer reduced motion */
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    /* Hide navigation elements when printing */
    .fixed,
    .absolute {
        display: none !important;
    }
    
    /* Optimize for print */
    body {
        background: white !important;
        color: black !important;
    }
    
    .bg-gradient-to-br,
    .bg-gradient-to-r,
    .login-bg {
        background: white !important;
    }
}
