/* Emergency Mobile Override Styles */
/* Force mobile styles on ALL devices with width <= 768px or touch capability */

/* JavaScript-detected mobile devices */
.is-mobile-device {
    font-size: 14px !important;
}

.is-mobile-device .main-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

.is-mobile-device input,
.is-mobile-device select,
.is-mobile-device textarea,
.is-mobile-device button {
    font-size: 14px !important;
    min-height: 38px !important;
}

/* Method 1: Width-based override */
@media screen and (max-width: 768px) {
    * {
        box-sizing: border-box !important;
        max-width: 100% !important;
    }

    html, body {
        width: 100% !important;
        overflow-x: hidden !important;
        font-size: 14px !important;
    }

    /* Force fit to viewport */
    .main-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .main-container {
        width: 100% !important;
        padding: 0 10px !important;
    }

    .column {
        width: 100% !important;
        padding: 10px !important;
    }

    /* Force larger text */
    .column-header {
        font-size: 16px !important;
        padding: 10px 8px !important;
    }

    .section-title {
        font-size: 14px !important;
    }

    .cash-input-container label {
        font-size: 14px !important;
    }

    .cash-input {
        font-size: 18px !important;
        padding: 10px !important;
        width: calc(100% - 20px) !important;
    }

    /* All inputs */
    input, select, textarea {
        font-size: 14px !important;
        padding: 8px 6px !important;
        min-height: 36px !important;
        width: 100% !important;
    }

    /* All buttons */
    button, .btn {
        font-size: 14px !important;
        padding: 8px 12px !important;
        min-height: 36px !important;
    }

    /* Item rows */
    .item-row {
        padding: 12px 8px !important;
        gap: 10px !important;
    }

    .item-row input {
        font-size: 14px !important;
        padding: 8px 6px !important;
        min-height: 36px !important;
    }

    /* Total amounts */
    .total-amount {
        font-size: 14px !important;
        display: block !important;
        margin-top: 4px !important;
    }

    .section-total {
        font-size: 14px !important;
    }

    /* Floating button */
    .floating-calculate-btn {
        font-size: 16px !important;
        padding: 10px 16px !important;
        min-height: 42px !important;
    }

    /* Ensure row controls stay visible on mobile */
    .btn-delete-desktop {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .item-checkbox {
        display: block !important;
        -webkit-appearance: checkbox !important;
        appearance: checkbox !important;
    }
}

/* Method 2: Touch device detection */
@media (hover: none) and (pointer: coarse) {
    body {
        font-size: 20px !important;
    }

    input, select, textarea, button {
        font-size: 20px !important;
        min-height: 50px !important;
    }
}

/* Method 3: Small height screens (landscape phones) */
@media (max-height: 768px) and (orientation: landscape) {
    body {
        font-size: 18px !important;
    }
}

/* Method 4: iPhone specific */
@supports (-webkit-touch-callout: none) {
    body {
        font-size: 20px !important;
        -webkit-text-size-adjust: 100% !important;
    }

    input, select, textarea {
        font-size: 20px !important;
        -webkit-appearance: none !important;
    }
}

/* Method 5: Very specific iPhone viewport sizes */
@media screen and (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3),
       screen and (device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3),
       screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2),
       screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
    body {
        font-size: 20px !important;
    }

    .main-content {
        width: 100vw !important;
    }
}
