/**
 * HMS responsive layout — show/hide desktop sidebar vs mobile app menu.
 * Plain CSS so mobile/desktop nav stays correct even if Tailwind build is missing.
 */

[x-cloak] {
    display: none !important;
}

/* —— Desktop left sidebar (admin + patient) —— */
.hms-layout-sidebar {
    display: none !important;
}

@media (min-width: 1024px) {
    .hms-layout-sidebar {
        display: flex !important;
    }
}

/* —— Mobile hamburger (top bar) —— */
.hms-layout-menu-btn {
    display: inline-flex !important;
}

@media (min-width: 1024px) {
    .hms-layout-menu-btn {
        display: none !important;
    }
}

/* —— Portal: desktop top links —— */
.hms-layout-desktop-nav {
    display: none !important;
}

@media (min-width: 1024px) {
    .hms-layout-desktop-nav {
        display: flex !important;
    }
}

.hms-layout-desktop-actions {
    display: none !important;
}

@media (min-width: 1024px) {
    .hms-layout-desktop-actions {
        display: flex !important;
    }
}

/* —— Mobile app menu (bottom bar + drawer) —— */
.hms-layout-mobile-nav,
.hms-layout-mobile-drawer,
.hms-layout-mobile-backdrop {
    display: none !important;
}

@media (max-width: 1023px) {
    body.hms-app-mobile {
        padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
    }

    body.hms-patient-app .hms-patient-mobile-main {
        padding-bottom: 0.25rem;
    }

    body.hms-patient-app .hms-layout-menu-btn {
        display: inline-flex !important;
    }

    body.hms-app-mobile.hms-drawer-open {
        overflow: hidden;
    }

    .hms-layout-mobile-nav {
        display: flex !important;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1035;
        max-width: 32rem;
        margin: 0 auto;
        padding-bottom: env(safe-area-inset-bottom, 0);
        background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
        border-top: 1px solid rgba(148, 163, 184, 0.35);
        box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
        align-items: stretch;
        justify-content: space-around;
        gap: 0;
    }

    .hms-layout-mobile-drawer {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1050;
        width: min(360px, 92vw);
        max-height: 100dvh;
        height: 100dvh;
        background: #fff;
        box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow: hidden;
    }

    .hms-layout-mobile-drawer[data-open="true"] {
        transform: translateX(0);
    }

    .hms-layout-mobile-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(15, 23, 42, 0.5);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s, visibility 0.25s;
    }

    .hms-layout-mobile-backdrop[data-open="true"] {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

@media (min-width: 1024px) {
    body.hms-app-mobile {
        padding-bottom: 0 !important;
    }
}

/* —— AdminLTE admin: mobile app shell —— */
@media (max-width: 1023px) {
    .main-sidebar,
    .main-sidebar::before {
        display: none !important;
    }

    .content-wrapper,
    .main-footer {
        margin-left: 0 !important;
    }

    /* Use bottom "Menu" only — hide AdminLTE top hamburger */
    .main-header .navbar-nav .nav-item:has([data-widget="pushmenu"]) {
        display: none !important;
    }

    /* Hide topnav extras that crowd the mobile header */
    .main-header .navbar-nav.ml-auto .nav-item:has([data-widget="fullscreen"]),
    .main-header .navbar-nav.ml-auto .nav-item:has(.hms-topnav-desktop-only) {
        display: none !important;
    }

    .main-header .navbar-nav.ml-auto {
        flex-wrap: nowrap;
    }

    .main-header .navbar-nav.ml-auto .nav-link {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        white-space: nowrap;
    }

    .hms-layout-mobile-nav {
        z-index: 1045;
    }
}

/* —— Mobile drawer & bottom bar (isolate from Bootstrap/AdminLTE) —— */
#hms-mobile-drawer,
#hms-mobile-drawer * {
    box-sizing: border-box;
}

#hms-mobile-drawer .hms-drawer-item,
#hms-mobile-drawer .hms-drawer-item:hover,
#hms-mobile-drawer .hms-drawer-item:focus {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border: none !important;
    border-radius: 0;
    box-shadow: none !important;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
    text-decoration: none;
    color: #1e293b;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

#hms-mobile-drawer .hms-drawer-item:hover {
    background: #f8fafc;
}

#hms-mobile-drawer .hms-drawer-item.is-active {
    background: #eff6ff;
    color: #1d4ed8;
}

#hms-mobile-drawer .hms-drawer-item:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

#hms-mobile-drawer .hms-drawer-section {
    margin: 0;
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

#hms-mobile-drawer .hms-drawer-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.5rem;
    padding: calc(0.75rem + env(safe-area-inset-top, 0)) 1rem 1rem;
    background: linear-gradient(to bottom right, #0f172a, #2563eb);
    color: #fff;
}

/* Scrollable menu list area */
#hms-mobile-drawer .hms-drawer-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#hms-mobile-drawer .hms-drawer-panel {
    position: absolute;
    inset: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0.5rem 0 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
}

#hms-mobile-drawer .hms-drawer-panel--sub {
    background: #fff;
}

#hms-mobile-drawer .hms-drawer-panel-scroll {
    min-height: 100%;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

#hms-mobile-drawer .hms-drawer-footer {
    flex-shrink: 0;
    border-top: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    background: #fff;
}

#hms-mobile-drawer .hms-drawer-footer button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.75rem;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 600;
    color: #dc2626;
    cursor: pointer;
}

#hms-mobile-drawer .hms-drawer-header strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
}

#hms-mobile-drawer .hms-drawer-header small {
    display: block;
    font-size: 0.875rem;
    opacity: 0.85;
}

#hms-mobile-drawer .hms-drawer-icon-btn {
    display: inline-flex;
    height: 2.25rem;
    width: 2.25rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border: none !important;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
}

.hms-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 3.5rem;
    padding: 0.35rem 0.25rem 0.5rem;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    text-decoration: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    color: #64748b;
}

.hms-tab-label {
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.02em;
}

.hms-tab-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: #e2e8f0;
    color: #475569;
    transition: background 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.hms-tab-icon-wrap svg {
    width: 1.25rem;
    height: 1.25rem;
}

.hms-tab.is-active {
    color: var(--hms-tab-color, #2563eb);
}

.hms-tab.is-active .hms-tab-icon-wrap {
    background: var(--hms-tab-color, #2563eb);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--hms-tab-color, #2563eb) 45%, transparent);
}

.hms-tab:focus-visible {
    outline: none;
}

.hms-tab:focus-visible .hms-tab-icon-wrap {
    outline: 2px solid var(--hms-tab-color, #2563eb);
    outline-offset: 2px;
}
