/* ==========================================================
   Mobile Tables & Responsive Utilities for sadi.kz
   Designed for construction brigades using smartphones
   ========================================================== */

/* ---- Table Responsive Wrapper ---- */
.mob-table-wrap {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -8px;
    padding: 0 8px;
}

/* Scroll indicator gradient on right edge */
.mob-table-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.06));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.mob-table-wrap.has-scroll::after {
    opacity: 1;
}

/* ---- Sticky First Column ---- */
@media only screen and (max-width: 991px) {
    .mob-table-wrap table th:first-child,
    .mob-table-wrap table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: #fff;
    }
    .mob-table-wrap table th:first-child {
        background: #f2f2f2;
        z-index: 3;
    }

    /* ---- Compact Table Cells ---- */
    .mob-table-wrap table th,
    .mob-table-wrap table td {
        padding: 5px 6px;
        font-size: 12px;
        white-space: nowrap;
    }
    .mob-table-wrap table td.chapter {
        font-size: 16px !important;
        white-space: normal;
    }

    /* ---- Touch-friendly rows ---- */
    .mob-table-wrap table tbody tr {
        min-height: 44px;
    }

    /* ---- Scroll hint message ---- */
    .mob-scroll-hint {
        display: block;
        text-align: center;
        font-size: 12px;
        color: #888;
        padding: 4px 0 8px;
    }
    .mob-scroll-hint i {
        animation: hintBounce 1.5s ease-in-out infinite;
    }
    @keyframes hintBounce {
        0%, 100% { transform: translateX(0); }
        50% { transform: translateX(6px); }
    }
}

@media only screen and (min-width: 992px) {
    .mob-scroll-hint {
        display: none;
    }
}

/* ---- Mobile Header / Title ---- */
@media only screen and (max-width: 768px) {
    h2[align="center"] {
        font-size: 16px !important;
        padding: 0 8px;
    }
}

/* ---- Mobile-friendly buttons ---- */
@media only screen and (max-width: 768px) {
    .btn, button, input[type="submit"], input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        font-size: 14px;
    }

    /* Action buttons at bottom of page */
    .mob-actions-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid #e0e0e0;
        padding: 8px 12px;
        display: flex;
        gap: 8px;
        z-index: 1050;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    }
    .mob-actions-bar .btn {
        flex: 1;
        text-align: center;
    }
}

/* ---- Mobile form inputs ---- */
@media only screen and (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important; /* Prevent iOS zoom on focus */
        min-height: 44px;
    }
}

/* ---- Container overrides for mobile ---- */
@media only screen and (max-width: 1100px) {
    .container-fluid-header {
        width: 100% !important;
        max-width: 1255px;
        padding-left: 12px;
        padding-right: 12px;
    }
    .container-fluid {
        width: 100% !important;
        max-width: 1440px;
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* ---- Card-based view for small phones ---- */
@media only screen and (max-width: 480px) {
    /* Quote Asset Sheet checkboxes - bigger touch targets */
    input[type="checkbox"] {
        width: 22px;
        height: 22px;
        cursor: pointer;
    }

    /* Modal dialogs - full width on phones */
    .modal-dialog {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }

    /* Tables - minimal padding */
    .mob-table-wrap table th,
    .mob-table-wrap table td {
        padding: 4px 4px;
        font-size: 11px;
    }
}

/* ---- Bottom Navigation Bar ---- */
.mob-bottom-nav {
    display: none;
}

@media only screen and (max-width: 991px) {
    .mob-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: #fff;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
        z-index: 1060;
        justify-content: space-around;
        align-items: center;
        padding: 0 4px;
    }
    .mob-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #666;
        font-size: 10px;
        font-weight: 500;
        padding: 4px 8px;
        border-radius: 8px;
        transition: all 0.2s;
        flex: 1;
        gap: 2px;
    }
    .mob-bottom-nav a i {
        font-size: 20px;
        margin-bottom: 2px;
    }
    .mob-bottom-nav a.active,
    .mob-bottom-nav a:hover {
        color: #0c2e8a;
        background: rgba(12, 46, 138, 0.06);
    }
    .mob-bottom-nav a.active i {
        color: #0c2e8a;
    }

    /* Add bottom padding to body so content isn't hidden behind nav */
    body {
        padding-bottom: 68px !important;
    }

    /* Hide desktop footer on very small screens to save space */
    .content_main {
        padding-bottom: 70px;
    }
}

/* ---- Utility: hide on mobile ---- */
@media only screen and (max-width: 768px) {
    .mob-hide {
        display: none !important;
    }
}

/* ---- Utility: show only on mobile ---- */
@media only screen and (min-width: 769px) {
    .mob-only {
        display: none !important;
    }
}

/* ---- Pull-to-refresh indicator ---- */
.ptr-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #1e293b, #334155);
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-100%);
    transition: transform 0.15s ease, opacity 0.15s ease;
    pointer-events: none;
    border-radius: 0 0 16px 16px;
}
.ptr-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}
.ptr-indicator.ptr-ready .ptr-spinner {
    transform: rotate(180deg);
}
.ptr-indicator.ptr-loading .ptr-spinner svg {
    animation: ptr-spin 0.8s linear infinite;
}
.ptr-indicator.ptr-ready {
    background: linear-gradient(135deg, #059669, #10b981);
}
.ptr-indicator.ptr-loading {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}
@keyframes ptr-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
