/* Reset และ Compatibility Fixes */
* {
    -webkit-tap-highlight-color: transparent; /* สำหรับ mobile */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}

/* FullCalendar Compatibility */
.fc {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                 'Helvetica Neue', Arial, sans-serif !important;
}

/* Modal Compatibility */
#activityModal,
#borrowBaseModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    -webkit-overflow-scrolling: touch; /* สำหรับ iOS */
}

/* Touch Device Optimization */
@media (hover: none) and (pointer: coarse) {
    .tab-btn {
        min-height: 48px; /* Minimum touch target size */
    }
    
    button, 
    .fc-button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* เพิ่ม padding สำหรับ touch devices */
    .px-6 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .py-4 {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
}

/* Fallback สำหรับ browser ที่ไม่รองรับ grid */
@supports not (display: grid) {
    .grid {
        display: flex;
        flex-wrap: wrap;
    }
    
    .grid-cols-1 > * {
        width: 100%;
    }
    
    .grid-cols-2 > * {
        width: 50%;
    }
    
    .grid-cols-3 > * {
        width: 33.333%;
    }
    
    .gap-4 > * {
        margin: 0.5rem;
    }
}

/* iOS Safe Areas */
@supports (padding: max(0px)) {
    .safe-area-top {
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }
    
    .safe-area-bottom {
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    #calendar {
        height: auto !important;
        overflow: visible !important;
    }
    
    .fc-header-toolbar {
        display: none !important;
    }
}

/* Edge/IE Compatibility */
@supports (-ms-ime-align: auto) {
    .rounded-xl {
        border-radius: 0.75rem;
    }
    
    .rounded-2xl {
        border-radius: 1rem;
    }
}

/* Firefox Scrollbar */
@-moz-document url-prefix() {
    .overflow-y-auto {
        scrollbar-width: thin;
        scrollbar-color: #cbd5e0 #f7fafc;
    }
}