/* Mobile Device Fixes for SSK Repair System */

/* Reset styles for mobile browsers */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    position: relative;
    width: 100%;
}

/* Prevent horizontal scroll on all elements */
* {
    max-width: 100%;
}

/* Safe area insets for notched devices (iPhone X and newer) */
@supports (padding: max(0px)) {
    body {
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* Fix for WebKit browsers (Safari, Chrome on iOS, LINE browser) */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select,
    textarea,
    input {
        font-size: 16px !important;
    }
}

/* Prevent zoom on input focus for iOS */
@media screen and (max-width: 767px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Fix for mobile menu and sidebar */
@media (max-width: 1023px) {
    #sidebar {
        position: fixed !important;
        top: 4rem !important;
        left: 0 !important;
        height: calc(100vh - 4rem) !important;
        width: 16rem !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-in-out !important;
        z-index: 50 !important;
        background: white !important;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1) !important;
    }
    
    #sidebar.open {
        transform: translateX(0) !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* Ensure navigation bar is responsive */
nav {
    width: 100% !important;
    max-width: 100% !important;
}

/* Fix for cards and containers on mobile */
@media (max-width: 767px) {
    .container,
    .max-w-7xl,
    .max-w-full {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    .grid {
        grid-template-columns: 1fr !important;
    }
}

/* Improve touch targets for mobile */
a, button, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
}

/* Allow small native checkboxes when explicitly sized */
input[type="checkbox"].h-4.w-4,
input[type="checkbox"].h-3.w-3 {
    min-height: 0;
    min-width: 0;
}

/* Fix for tables on mobile */
@media (max-width: 767px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Prevent text selection on certain UI elements */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Fix for position fixed elements on mobile Safari */
@supports (-webkit-touch-callout: none) {
    .fixed {
        position: -webkit-sticky;
        position: sticky;
    }
}

/* Ensure images are responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Fix for LINE in-app browser specific issues */
@media screen and (max-width: 1023px) {
    /* Force repaint on LINE browser */
    body {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Fix for LINE browser viewport issues */
    .main-content {
        min-height: calc(100vh - 4rem);
        overflow-x: hidden;
    }
}

/* Loading spinner for better UX */
.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Accessibility improvements */
:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}
