/*
 * Mobile Responsiveness Enhancement for eserviss.pumity.lv
 * Comprehensive mobile fixes for all Laravel components
 */

/* Mobile-first base styles */
@media (max-width: 575.98px) {
    /* Global mobile styles */
    body {
        font-size: 16px !important;
        line-height: 1.5;
    }

    /* Container adjustments */
    .container,
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Typography mobile */
    h1, .h1 { font-size: 1.5rem !important; }
    h2, .h2 { font-size: 1.4rem !important; }
    h3, .h3 { font-size: 1.3rem !important; }
    h4, .h4 { font-size: 1.2rem !important; }
    h5, .h5 { font-size: 1.1rem !important; }
    h6, .h6 { font-size: 1rem !important; }

    /* Form controls mobile */
    .form-control {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 12px 15px !important;
        border-radius: 8px !important;
        min-height: 48px !important; /* Better touch target */
    }

    .form-select {
        font-size: 16px !important;
        padding: 12px 15px !important;
        min-height: 48px !important;
    }

    /* Input groups mobile */
    .input-group-text {
        font-size: 14px !important;
        padding: 12px 12px !important;
        min-height: 48px !important;
        display: flex;
        align-items: center;
    }

    /* Buttons mobile */
    .btn {
        padding: 12px 20px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        min-height: 48px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn-sm {
        padding: 8px 16px !important;
        font-size: 14px !important;
        min-height: 40px !important;
    }

    .btn-lg {
        padding: 16px 24px !important;
        font-size: 18px !important;
        min-height: 56px !important;
    }

    /* Cards mobile */
    .card {
        border-radius: 12px !important;
        margin-bottom: 20px !important;
    }

    .card-body {
        padding: 15px !important;
    }

    /* Tables mobile */
    .table-responsive {
        border: none !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .table th,
    .table td {
        padding: 12px 8px !important;
        font-size: 14px !important;
        white-space: nowrap !important;
    }

    /* Modals mobile */
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }

    .modal-content {
        border-radius: 12px !important;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 15px !important;
    }

    /* Alerts mobile */
    .alert {
        padding: 15px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }

    /* Badges mobile */
    .badge {
        font-size: 11px !important;
        padding: 4px 8px !important;
        border-radius: 6px !important;
    }

    /* Navbar mobile */
    .navbar-toggler {
        padding: 8px 12px !important;
        border: none !important;
        font-size: 18px !important;
    }

    .navbar-nav .nav-link {
        padding: 12px 15px !important;
        font-size: 16px !important;
    }

    /* Dropdown menus mobile */
    .dropdown-menu {
        border-radius: 8px !important;
        border: 1px solid #dee2e6 !important;
        box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
    }

    .dropdown-item {
        padding: 12px 20px !important;
        font-size: 15px !important;
    }

    /* Pagination mobile */
    .pagination {
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
    }

    .page-link {
        padding: 8px 12px !important;
        font-size: 14px !important;
        border-radius: 6px !important;
        min-width: 40px !important;
        text-align: center !important;
    }

    /* Toast notifications mobile */
    .toast-container {
        position: fixed !important;
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        z-index: 9999 !important;
    }

    .toast {
        width: 100% !important;
        max-width: none !important;
        border-radius: 8px !important;
    }

    /* Loading states mobile */
    .spinner-border {
        width: 1.5rem !important;
        height: 1.5rem !important;
    }

    .spinner-border-sm {
        width: 1rem !important;
        height: 1rem !important;
    }

    /* Home page mobile optimizations */
    .delivery-illustration-section {
        display: none !important; /* Hide delivery illustration on mobile */
    }

    /* Make home page form take full width on mobile - more specific targeting */
    .col-lg-4 .form-sticky,
    .col-lg-8 #offers {
        width: 100% !important;
    }

    .col-lg-4:first-child,
    .col-lg-8:last-child {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 0 !important;
    }

    /* Enhanced home page form mobile styling */
    .form-sticky {
        position: static !important; /* Remove sticky positioning on mobile */
        margin-bottom: 20px !important;
    }

    .form-wrap {
        padding: 20px !important;
        margin-bottom: 15px !important;
        border-radius: 12px !important;
    }

    /* Home page form fields mobile layout */
    .form-group.inner-label {
        margin-bottom: 20px !important;
    }

    /* Package type, weight, quantity row mobile */
    .form-group .row {
        margin: 0 -5px !important;
    }

    .form-group .row [class*="col-"] {
        padding: 0 5px !important;
        margin-bottom: 15px !important;
    }

    /* Ensure first row fields (parcel type, weight, quantity) are visible */
    .row .col-5,
    .row .col-4,
    .row .col-3 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 15px !important;
    }

    .row .col-5 select,
    .row .col-4 input,
    .row .col-3 select {
        width: 100% !important;
        display: block !important;
        visibility: visible !important;
    }

    /* Dimension inputs mobile layout */
    .input-group.flex-nowrap {
        flex-direction: column !important;
        gap: 15px !important;
        margin-bottom: 0 !important;
    }

    .input-group.flex-nowrap > div {
        width: 100% !important;
    }

    .input-group.flex-nowrap > div label {
        display: block !important;
        margin-bottom: 8px !important;
        font-weight: 600 !important;
        color: #333 !important;
    }

    .input-group.flex-nowrap input {
        border-radius: 8px !important;
        margin-bottom: 0 !important;
        padding: 12px 15px !important;
        font-size: 16px !important;
    }

    .input-group.flex-nowrap .input-group {
        display: flex !important;
        flex-direction: row !important;
    }

    .input-group.flex-nowrap .input-group input {
        border-radius: 8px 0 0 8px !important;
    }

    .input-group.flex-nowrap .input-group-text {
        border-radius: 0 8px 8px 0 !important;
        background-color: #e9ecef !important;
        border-left: none !important;
    }

    /* Fix weight input group specifically */
    .col-4 .input-group {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
    }

    .col-4 .input-group .form-control {
        flex: 1 !important;
        border-radius: 8px 0 0 8px !important;
        border-right: none !important;
    }

    .col-4 .input-group .input-group-text {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background-color: #e9ecef !important;
        border: 1px solid #ced4da !important;
        border-left: none !important;
        border-radius: 0 8px 8px 0 !important;
        padding: 12px 15px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        min-width: 50px !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Ensure input-group elements are visible */
    .input-group,
    .input-group * {
        visibility: visible !important;
        opacity: 1 !important;
        display: flex !important;
    }

    .input-group .form-control {
        display: block !important;
    }

    .input-group .input-group-text {
        display: flex !important;
    }

    /* Country and postal code sections mobile */
    .row .col-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 20px !important;
    }

    .text-success.fw-semibold {
        font-size: 16px !important;
        margin-bottom: 15px !important;
        padding: 10px 0 !important;
        border-bottom: 2px solid #198754 !important;
    }

    /* Specific fixes for home page form fields */
    .form-sticky .form-wrap .form-group label {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        margin-bottom: 8px !important;
        color: #333 !important;
        position: relative !important;
        z-index: 1 !important;
    }

    /* Force all form elements to be visible */
    .form-sticky .form-wrap * {
        visibility: visible !important;
        opacity: 1 !important;
        display: block !important;
    }

    .form-sticky .form-wrap .row {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    .form-sticky .form-wrap [class*="col-"] {
        display: block !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Ensure all form fields are visible */
    .form-group label {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        margin-bottom: 8px !important;
        color: #333 !important;
    }

    .form-control,
    .form-select {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
        background-color: #fff !important;
        border: 1px solid #ced4da !important;
    }

    /* Fix any hidden or invisible elements */
    .form-group,
    .form-group *,
    .input-group,
    .input-group * {
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Home page buttons mobile */
    #find-offers,
    .form-wrap .btn {
        width: 100% !important;
        padding: 15px !important;
        font-size: 16px !important;
        border-radius: 10px !important;
        margin-top: 15px !important;
        display: block !important;
        visibility: visible !important;
    }

    /* Utility classes mobile */
    .d-none-mobile {
        display: none !important;
    }

    .d-block-mobile {
        display: block !important;
    }

    .text-center-mobile {
        text-align: center !important;
    }

    .w-100-mobile {
        width: 100% !important;
    }

    /* Gap utilities mobile */
    .gap-mobile-1 { gap: 0.25rem !important; }
    .gap-mobile-2 { gap: 0.5rem !important; }
    .gap-mobile-3 { gap: 1rem !important; }
    .gap-mobile-4 { gap: 1.5rem !important; }
    .gap-mobile-5 { gap: 3rem !important; }

    /* Padding utilities mobile */
    .p-mobile-1 { padding: 0.25rem !important; }
    .p-mobile-2 { padding: 0.5rem !important; }
    .p-mobile-3 { padding: 1rem !important; }
    .p-mobile-4 { padding: 1.5rem !important; }
    .p-mobile-5 { padding: 3rem !important; }

    /* Margin utilities mobile */
    .m-mobile-1 { margin: 0.25rem !important; }
    .m-mobile-2 { margin: 0.5rem !important; }
    .m-mobile-3 { margin: 1rem !important; }
    .m-mobile-4 { margin: 1.5rem !important; }
    .m-mobile-5 { margin: 3rem !important; }

    /* Flex utilities mobile */
    .flex-column-mobile {
        flex-direction: column !important;
    }

    .flex-row-mobile {
        flex-direction: row !important;
    }

    .justify-content-center-mobile {
        justify-content: center !important;
    }

    .align-items-center-mobile {
        align-items: center !important;
    }

    .align-items-start-mobile {
        align-items: flex-start !important;
    }

    .align-items-end-mobile {
        align-items: flex-end !important;
    }
}

/* Tablet adjustments */
@media (min-width: 576px) and (max-width: 991.98px) {
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    .form-control,
    .form-select {
        font-size: 15px !important;
        padding: 10px 15px !important;
    }

    .btn {
        padding: 10px 18px !important;
        font-size: 15px !important;
    }

    .card-body {
        padding: 20px !important;
    }

    .modal-dialog {
        margin: 20px !important;
        max-width: calc(100% - 40px) !important;
    }
}

/* Desktop improvements */
@media (min-width: 992px) {
    /* Enhanced hover states for desktop */
    .btn {
        transition: all 0.2s ease !important;
    }

    .btn:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
    }

    .card {
        transition: box-shadow 0.2s ease !important;
    }

    .card:hover {
        box-shadow: 0 8px 24px rgba(0,0,0,0.1) !important;
    }

    /* Enhanced form focus states */
    .form-control:focus,
    .form-select:focus {
        border-color: #198754 !important;
        box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25) !important;
    }
}

/* Print styles */
@media print {
    /* Hide navigation and non-essential elements */
    .navbar,
    .btn,
    .alert,
    .toast-container,
    .modal,
    .dropdown-menu {
        display: none !important;
    }

    /* Optimize text for print */
    body {
        font-size: 12pt !important;
        line-height: 1.4 !important;
        color: #000 !important;
    }

    .container {
        max-width: none !important;
        padding: 0 !important;
    }

    /* Ensure tables fit on page */
    .table {
        font-size: 10pt !important;
    }

    .table th,
    .table td {
        padding: 4px !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-control,
    .form-select {
        border: 2px solid #000 !important;
    }

    .btn {
        border: 2px solid !important;
        background: #fff !important;
        color: #000 !important;
    }

    .btn-primary {
        background: #000 !important;
        color: #fff !important;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* This can be enabled later if dark mode is desired */
    /*
    body {
        background-color: #1a1a1a !important;
        color: #fff !important;
    }

    .card {
        background-color: #2d2d2d !important;
        border-color: #404040 !important;
    }

    .form-control,
    .form-select {
        background-color: #2d2d2d !important;
        border-color: #404040 !important;
        color: #fff !important;
    }
    */
}