/* Responsive layout overrides for phone sized viewports. Desktop styles remain intact. */
#mobileAppBar {
    display: none;
}

@media (max-width: 767.98px) {
    html,
    body#allContent {
        width: 100%;
        min-width: 320px;
        height: 100%;
        overflow: hidden;
    }

    body#allContent {
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        overscroll-behavior: none;
    }

    #appContent {
        display: flex;
        width: 100%;
        min-width: 0;
        height: 100%;
        flex: 1 1 auto;
        overflow: hidden;
    }

    #mobileAppBar {
        z-index: 20;
        display: flex;
        min-height: calc(56px + env(safe-area-inset-top, 0px));
        flex: 0 0 calc(56px + env(safe-area-inset-top, 0px));
        align-items: center;
        gap: 12px;
        padding: env(safe-area-inset-top, 0px) 14px 0;
        border-bottom: 1px solid #dbe5ed;
        color: #082f49;
        background: #fff;
        box-shadow: 0 2px 8px rgb(15 23 42 / 7%);
    }

    #mobileMenuToggle,
    #mobileSidebarClose {
        display: inline-flex;
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        align-items: center;
        justify-content: center;
        border: 1px solid #d9e4ec;
        border-radius: 12px;
        color: #0c4a6e;
        background: #f8fafc;
        font-size: 18px;
        cursor: pointer;
    }

    #mobileMenuToggle:focus-visible,
    #mobileSidebarClose:focus-visible,
    #appSidebar .icon:focus-visible,
    #appSidebar .rounded-div:focus-visible {
        outline: 3px solid #38bdf8;
        outline-offset: 2px;
    }

    .mobile-app-brand {
        display: flex;
        min-width: 0;
        flex-direction: column;
        line-height: 1.15;
    }

    .mobile-app-brand > span {
        color: #0c4a6e;
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .1em;
    }

    .mobile-app-brand > small {
        overflow: hidden;
        margin-top: 3px;
        color: #64748b;
        font-size: 13px;
        font-weight: 600;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #contenido {
        display: block;
        width: 100%;
        min-width: 0;
        min-height: 0;
        height: auto !important;
        flex: 1 1 auto;
        overflow-x: hidden;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    #contenido > * {
        min-width: 0;
        max-width: 100%;
    }

    #contenido img,
    #contenido canvas,
    #contenido video,
    #contenido iframe {
        max-width: 100%;
    }

    #contenido input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    #contenido select,
    #contenido textarea {
        min-width: 0;
        max-width: 100%;
        font-size: 16px !important;
    }

    #contenido button,
    #contenido input[type="submit"] {
        min-height: 40px;
        touch-action: manipulation;
    }

    #contenido .overflow-x-auto,
    #contenido .overflow-x-scroll {
        max-width: 100%;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    #contenido table {
        max-width: 100%;
    }

    #contenido table.table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #contenido .p-6 {
        padding: 1rem !important;
    }

    #contenido .px-6 {
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }

    #contenido .px-5 {
        padding-right: .875rem !important;
        padding-left: .875rem !important;
    }

    #contenido .gap-6 {
        gap: 1rem !important;
    }

    #contenido .flex.space-x-6.text-sm {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: .75rem 1rem;
    }

    #contenido .flex.space-x-3 {
        flex-wrap: wrap;
        gap: .5rem;
    }

    #contenido .px-6.py-4 > .flex.justify-between.items-center {
        align-items: stretch;
        flex-direction: column;
        gap: .875rem;
    }

    #contenido .px-6.py-4 > .flex.justify-between.items-center > .flex.space-x-3 {
        width: 100%;
    }

    #contenido .px-6.py-4 > .flex.justify-between.items-center > .flex.space-x-3 > button {
        min-width: 0;
        flex: 1 1 120px;
    }

    #contenido .flex.flex-wrap.items-center.justify-between.gap-4 > .flex.items-center.space-x-4 {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: .625rem;
    }

    #contenido .flex.flex-wrap.items-center.justify-between.gap-4 > .flex.items-center.space-x-4 > * {
        width: 100%;
        min-width: 0;
    }

    #contenido #agentTopStats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .75rem;
    }

    #contenido #agentTopStats > * {
        min-width: 0;
        padding: .875rem;
    }

    #contenido #agentTopStats .agent-calls-chart {
        grid-column: 1 / -1;
    }

    #contenido #calendarDiv {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #contenido #calendarDiv .dia {
        min-width: 2.55rem;
        min-height: 3.5rem;
    }

    #contenido #trucksTable,
    #contenido #driversTable,
    #contenido #loadsTable,
    #contenido #agentCallsTable {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #contenido #trucksTable,
    #contenido #driversTable,
    #contenido #loadsTable {
        min-width: 680px;
    }

    #contenido .flex-1.flex.overflow-hidden {
        min-height: 0;
        flex-direction: column;
        overflow: visible;
    }

    #contenido #detailsPanel:not(.hidden) {
        position: fixed;
        z-index: 35;
        inset: 0;
        display: block;
        width: 100% !important;
        max-width: 100%;
        height: 100dvh;
        border: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 0 0 0 100vmax rgb(15 23 42 / 42%);
    }

    #contenido #detailsPanel.hidden {
        display: none !important;
    }

    #contenido #truckModal > div,
    #contenido #driverModal > div,
    #contenido #deleteModal > div,
    #contenido #loadModal > div {
        top: auto !important;
        width: calc(100vw - 24px) !important;
        max-width: 640px;
        max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        margin: max(12px, env(safe-area-inset-top, 0px)) auto 12px;
        padding: 1rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    #contenido #deleteModal > div {
        max-width: 420px;
    }

    #contenido .modal-footer,
    #contenido #truckModal .flex.items-center.justify-end.space-x-4,
    #contenido #driverModal .flex.items-center.justify-end.space-x-4,
    #contenido #loadModal .flex.items-center.justify-end.space-x-4 {
        flex-wrap: wrap;
        gap: .625rem;
    }

    #contenido .modal-footer > *,
    #contenido #truckModal .flex.items-center.justify-end.space-x-4 > button,
    #contenido #driverModal .flex.items-center.justify-end.space-x-4 > button,
    #contenido #loadModal .flex.items-center.justify-end.space-x-4 > button {
        flex: 1 1 130px;
    }

    #contenido #truckModal .flex.items-center.justify-end.space-x-4,
    #contenido #driverModal .flex.items-center.justify-end.space-x-4,
    #contenido #loadModal .flex.items-center.justify-end.space-x-4 {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: initial;
        padding-top: 1rem;
    }

    #contenido #truckModal .flex.items-center.justify-end.space-x-4 > button,
    #contenido #driverModal .flex.items-center.justify-end.space-x-4 > button,
    #contenido #loadModal .flex.items-center.justify-end.space-x-4 > button {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        flex: none;
        margin: 0 !important;
        white-space: normal;
    }

    #contenido #driverModal input[type="file"] {
        width: 100%;
        min-height: 48px;
        max-width: 100%;
        padding: .5rem;
        font-size: 14px;
    }

    #contenido .modal-dialog {
        width: calc(100vw - 24px);
        max-width: 640px;
        margin: max(12px, env(safe-area-inset-top, 0px)) auto 12px;
    }

    #contenido .modal-content {
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    #mobileSidebarBackdrop {
        position: fixed;
        z-index: 90;
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        border: 0;
        background: rgb(15 23 42 / 48%);
        touch-action: manipulation;
    }

    #mobileSidebarBackdrop.hidden {
        display: none !important;
    }

    #appSidebar {
        position: fixed;
        z-index: 100;
        top: 0;
        bottom: 0;
        left: 0;
        display: flex !important;
        width: min(300px, 86vw) !important;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        overflow-x: hidden;
        overflow-y: auto;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 8px 0 28px rgb(15 23 42 / 18%);
        transform: translateX(-105%);
        transition: transform 220ms ease, visibility 220ms ease;
        transition-delay: 0ms;
        visibility: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    #appSidebar.is-open {
        transform: translateX(0);
        visibility: visible;
    }

    #appSidebar #sidebar {
        width: 100%;
        min-height: 100%;
        padding-bottom: 1rem;
    }

    #appSidebar .mobile-sidebar-heading {
        position: sticky;
        z-index: 1;
        top: 0;
        display: flex;
        min-height: 58px;
        align-items: center;
        justify-content: space-between;
        padding: 0 14px;
        border-bottom: 1px solid rgb(255 255 255 / 14%);
        color: #fff;
        background: #082f49;
        font-size: 14px;
    }

    #mobileSidebarClose {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
        border-color: rgb(255 255 255 / 20%);
        color: #fff;
        background: rgb(255 255 255 / 9%);
    }

    #appSidebar .icon {
        display: flex;
        min-height: 48px;
        align-items: center;
        margin: 3px 10px !important;
        padding: 0 14px;
        border-radius: 10px;
        touch-action: manipulation;
    }

    #appSidebar .icon > div {
        display: flex;
        width: 100%;
        align-items: center;
        gap: 14px;
    }

    #appSidebar .icon > div > span:first-child {
        width: 24px;
        flex: 0 0 24px;
        text-align: center;
    }

    #appSidebar .sidebar-text {
        display: inline !important;
        font-size: 14px;
    }

    #appSidebar .icon.active {
        background: rgb(255 255 255 / 12%);
    }

    #appSidebar .rounded-div {
        width: 44px;
        height: 44px;
        margin-top: 12px !important;
        font-size: 16px;
        touch-action: manipulation;
    }

    #appSidebar hr {
        margin: 10px 14px !important;
        border-color: rgb(255 255 255 / 18%);
    }

    #appSidebar.is-open,
    #mobileSidebarBackdrop {
        touch-action: pan-y;
    }

    body.mobile-menu-open {
        overflow: hidden;
    }
}

.mobile-sidebar-heading {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    #appSidebar {
        transition-duration: .01ms !important;
    }
}
