/* Custom Responsive Overrides for Truck App */

/* Global Mobile Fixes */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .navbar .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Better card spacing on mobile */
    .card {
        margin-bottom: 1rem;
    }

    /* Adjust typography for small screens */
    h1,
    .h1 {
        font-size: 1.75rem;
    }

    h2,
    .h2 {
        font-size: 1.5rem;
    }

    h3,
    .h3 {
        font-size: 1.3rem;
    }

    /* Make modal dialogs fuller width on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: none;
    }
}

/* Sidebar Toggle Fixes */
.sidenav-toggler-inner .sidenav-toggler-line {
    height: 2px;
}

/* Responsive Tables - Card Stack Approach */
@media (max-width: 992px) {
    .table-responsive-stack thead {
        display: none;
    }

    .table-responsive-stack tbody tr {
        display: block;
        background: #fff;
        border-radius: 0.75rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        padding: 1rem;
    }

    .table-responsive-stack tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.65rem 0;
        border-bottom: 1px solid #f0f0f0;
        text-align: right;
        flex-wrap: wrap;
    }

    .table-responsive-stack tbody td:last-child {
        border-bottom: none;
    }

    .table-responsive-stack tbody td:before {
        content: attr(data-label);
        font-weight: 700;
        color: #444;
        text-align: left;
        margin-right: 0.8rem;
        width: 40%;
        min-width: 120px;
        flex: 0 0 40%;
    }

    .table-responsive-stack tbody td:last-child:before {
        width: 100%;
        flex: 1 1 100%;
        margin-bottom: 0.5rem;
    }

    .table-responsive-stack tbody td .text-sm {
        width: 55%;
        flex: 1 1 55%;
        text-align: right;
    }
}

@media (max-width: 768px) {
    .nav-tabs,
    .nav-pills {
        flex-wrap: wrap !important;
        gap: 0.6rem;
    }

    .mobile-hide {
        display: none !important;
    }

    .nav-tabs .nav-item,
    .nav-pills .nav-item {
        flex: 1 1 48%;
        min-width: 45%;
    }

    .nav-tabs .nav-link,
    .nav-pills .nav-link {
        text-align: center;
        padding: 0.65rem 0.9rem;
        font-size: 0.92rem;
    }

    .table-responsive-stack tbody td:before {
        width: 100%;
        flex: 1 1 100%;
        margin-bottom: 0.35rem;
    }

    .table-responsive-stack tbody td {
        justify-content: flex-start;
    }
}

/* Orders and operations card-style table behavior on mobile */
@media (max-width: 768px) {
    .operations-table thead,
    .orders-table thead {
        display: none;
    }

    .operations-table tbody tr,
    .orders-table tbody tr {
        display: block;
        background: #fff;
        border-radius: 0.75rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
        padding: 1rem;
    }

    .operations-table tbody td,
    .orders-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #f0f0f0;
        padding: 0.65rem 0;
        text-align: right;
        flex-wrap: wrap;
    }

    .operations-table tbody td.mobile-hide,
    .orders-table tbody td.mobile-hide {
        display: none !important;
    }

    .operations-table,
    .orders-table {
        min-width: 720px;
    }

    .mobile-hide {
        display: table-cell;
    }

    .operations-table tbody td:before,
    .orders-table tbody td:before {
        content: attr(data-label);
        font-weight: 700;
        color: #444;
        text-align: left;
        margin-right: 0.8rem;
        width: 40%;
        min-width: 120px;
        flex: 0 0 40%;
    }

    .operations-table tbody td:last-child:before,
    .orders-table tbody td:last-child:before {
        width: 100%;
        flex: 1 1 100%;
        margin-bottom: 0.5rem;
    }

    .operations-table tbody td,
    .orders-table tbody td {
        justify-content: flex-start;
    }
}

/* Move tabs wrap instead of horizontal scroll */
.move-tabs-scroll,
.nav-pills.mb-3.nav-pills-primary {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.move-tabs-scroll .nav-tabs,
.nav-pills.mb-3.nav-pills-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.move-tabs-scroll .nav-item,
.nav-pills.mb-3.nav-pills-primary .nav-item {
    flex: 0 0 auto;
}

.move-tabs-scroll .nav-link,
.nav-pills.mb-3.nav-pills-primary .nav-link {
    white-space: nowrap;
}


/* Dashboard Grid Fixes */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

/* Utilities */
.cursor-pointer {
    cursor: pointer;
}

.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Premium Inputs */
.form-control {
    border: 1px solid #d2d6da;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.form-control:focus {
    border-color: #e91e63;
    box-shadow: 0 0 0 2px rgba(233, 30, 99, 0.25);
}

.input-group-outline .form-label {
    top: -0.6rem;
    background: #fff;
    padding: 0 5px;
    font-size: 0.75rem;
    color: #e91e63 !important;
    opacity: 1 !important;
}

.input-group-outline.is-filled .form-label,
.input-group-outline.is-focused .form-label {
    top: -0.6rem;
    font-size: 0.75rem;
    color: #e91e63;
}

.input-group.input-group-outline {
    margin-bottom: 1.5rem !important;
}

/* Ensure select2 or other selects look good */
select.form-control {
    -webkit-appearance: auto;
    appearance: auto;
}