/**
 * Mobile Enhancements for Keenan Product Configurator
 * 
 * Global mobile improvements and optimizations
 */

/* Ensure proper mobile viewport behavior */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Improve tap targets on mobile */
@media (max-width: 768px) {
    button,
    a,
    input,
    select,
    textarea,
    label,
    .kpc-option-item,
    .kpc-machine-item,
    .kpc-country-item {
        min-height: 44px; /* iOS recommended touch target */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 105, 47, 0.1);
    }

    /* Prevent text selection on interactive elements */
    .kpc-option-item,
    .kpc-machine-item,
    .kpc-country-item,
    button {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Allow text selection in inputs */
    input,
    textarea {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }

    /* Better focus states for accessibility */
    button:focus,
    a:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #00692F;
        outline-offset: 2px;
    }

    /* Prevent iOS input zoom */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Better button touch feedback */
    button:active,
    .kpc-button:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

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

    /* Better scroll performance */
    * {
        -webkit-overflow-scrolling: touch;
    }

    /* Container improvements */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Improve readability */
    body {
        font-size: 16px;
        line-height: 1.5;
    }

    h1, h2, h3, h4, h5, h6 {
        line-height: 1.3;
    }

    /* Better spacing */
    p, ul, ol {
        margin-bottom: 1rem;
    }

    /* Improve form elements */
    .form-control,
    input,
    textarea,
    select {
        border-radius: 6px;
        padding: 12px 15px;
        border: 2px solid #ddd;
        transition: border-color 0.2s ease;
    }

    .form-control:focus,
    input:focus,
    textarea:focus,
    select:focus {
        border-color: #00692F;
        box-shadow: 0 0 0 3px rgba(0, 105, 47, 0.1);
    }

    /* Better button styling */
    button,
    .kpc-button,
    .kpc-submit-button {
        border-radius: 6px;
        padding: 14px 20px;
        font-weight: 600;
        font-size: 16px;
        border: none;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    /* Improve modals on mobile */
    .kpc-modal {
        padding: 0;
    }

    .kpc-modal-content {
        max-height: 90vh;
        overflow-y: auto;
        margin: 5vh auto;
    }

    /* Better loading states */
    .kpc-loading {
        padding: 40px 20px;
        text-align: center;
        font-size: 16px;
    }

    /* Improve error messages */
    .kpc-error,
    .kpc-message-error {
        padding: 15px 20px;
        border-radius: 6px;
        margin: 15px 0;
        font-size: 15px;
        line-height: 1.4;
    }

    /* Better success messages */
    .kpc-message-success {
        padding: 15px 20px;
        border-radius: 6px;
        margin: 15px 0;
        font-size: 15px;
        line-height: 1.4;
    }

    /* Improve navigation */
    .kpc-navigation {
        margin-top: 30px;
        margin-bottom: 30px;
    }

    /* Better price display */
    .kpc-price-value {
        font-weight: 700;
        color: #00692F;
    }

    .kpc-total-value {
        font-weight: 700;
        color: #00692F;
        font-size: 32px !important;
    }

    /* Improve grid layouts */
    .kpc-options-grid,
    .kpc-machines-grid,
    .kpc-countries-grid {
        gap: 12px !important;
    }

    /* Better card styling */
    .kpc-option-item,
    .kpc-machine-item,
    .kpc-country-item,
    .kpc-machine-details,
    .kpc-configuration-summary {
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }

    /* Better hover/active states */
    .kpc-option-item:active,
    .kpc-machine-item:active,
    .kpc-country-item:active {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    /* Improve sticky elements */
    .sticky-element {
        position: -webkit-sticky;
        position: sticky;
    }

    /* Better image handling */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Improve table responsiveness */
    table {
        width: 100%;
        overflow-x: auto;
        display: block;
    }

    /* Better accordion/collapse animations */
    .kpc-options-section.collapsed .kpc-options-grid {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .kpc-options-section .kpc-options-grid {
        max-height: 5000px;
        transition: max-height 0.3s ease;
    }
}

/* Very small screens - additional optimizations */
@media (max-width: 375px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    body {
        font-size: 15px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 18px;
    }

    h3 {
        font-size: 16px;
    }

    .kpc-button,
    button {
        padding: 12px 16px;
        font-size: 15px;
    }

    .kpc-total-value {
        font-size: 28px !important;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .kpc-modal-content {
        max-height: 85vh;
    }

    .kpc-mobile-price-summary {
        position: relative;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    }

    .kpc-machine-configure-page {
        padding-bottom: 20px;
    }
}

/* Print styles */
@media print {
    .kpc-mobile-price-summary,
    .kpc-price-indicator,
    .kpc-navigation,
    .kpc-back-button,
    .kpc-submit-button,
    .kpc-change-country-btn {
        display: none !important;
    }
}

