/**
 * Mobile UX improvements — touch targets, header, sidebar, breadcrumbs, preloader.
 * Desktop / large screens: rules scoped to max-width media queries only.
 */

/* ── 1. Hide dense header-top auth bar on small screens ── */
@media (max-width: 991.98px) {
    .th-header .header-top {
        display: none !important;
    }

    .header-layout4 .header-middle .abad-header-auth-desktop {
        display: none !important;
    }

    .header-layout2 .header-top {
        display: none !important;
    }

    .header-button {
        display: flex;
        align-items: center;
        gap: 0.35rem;
    }
}

/* Mobile account dropdown in sticky header */
.abad-mobile-account__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font-size: 1.35rem;
    line-height: 1;
}

.abad-mobile-account__toggle::after {
    display: none;
}

.abad-mobile-account__menu .dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Hamburger — ensure touch-friendly size on mobile */
@media (max-width: 991.98px) {
    .th-header .th-menu-toggle.d-block.d-lg-none,
    .th-header .header-button .th-menu-toggle {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* ── 2. Language switcher & theme switcher touch targets ── */
.language-switcher-dropdown .lang-switcher-touch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 !important;
    border-radius: 10px;
}

.language-switcher-dropdown .lang-switcher-touch img {
    width: 22px;
    height: auto;
}

.language-switcher-dropdown .dropdown-menu .dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
}

@media (max-width: 991.98px) {
  .switcher-fixed {
    top: auto;
    bottom: calc(148px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    margin-top: 0;
    transform: none;
    z-index: 1035;
  }

  body.has-floating-fabs.has-scroll-top-fab.has-whatsapp-fab .switcher-fixed {
    bottom: calc(210px + env(safe-area-inset-bottom, 0px));
  }

  .switcher-fixed .theme-switcher {
    width: 52px;
    height: 28px;
  }

  .switcher-fixed .theme-switcher-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
    margin-top: -8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
  }

  .switcher-fixed .theme-switcher.active .theme-switcher-btn {
    left: calc(100% - 44px);
  }
}

@media (min-width: 992px) {
  .switcher-fixed .theme-switcher-btn {
    min-width: 24px;
    min-height: 24px;
  }
}

/* ── 3. Sidebar widgets — collapse extras on mobile ── */
@media (max-width: 991.98px) {
    .sidebar-area[data-mobile-sidebar] .sidebar-widget-item--extra {
        display: none;
    }

    .sidebar-area[data-mobile-sidebar].is-expanded .sidebar-widget-item--extra {
        display: block;
    }

    .sidebar-show-more-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        width: 100%;
        min-height: 44px;
        margin-top: 0.5rem;
        padding: 0.65rem 1rem;
        border: 1px dashed var(--border-color, #e2e8f0);
        border-radius: 10px;
        background: var(--body-bg, #fff);
        color: var(--title-color, #0f172a);
        font-weight: 600;
        font-size: 0.9rem;
        cursor: pointer;
        transition: background 0.2s ease, border-color 0.2s ease;
    }

    .sidebar-show-more-btn:hover,
    .sidebar-show-more-btn:focus-visible {
        background: var(--smoke-color, #f8fafc);
        border-color: var(--theme-color, #e53935);
        outline: none;
    }

    .sidebar-area.is-expanded .sidebar-show-more-btn .bi-chevron-down {
        transform: rotate(180deg);
    }

    .forum-civis-sidebar[data-mobile-sidebar] .forum-civis-panel--extra {
        display: none;
    }

    .forum-civis-sidebar[data-mobile-sidebar].is-expanded .forum-civis-panel--extra {
        display: block;
    }
}

@media (min-width: 992px) {
    .sidebar-show-more-btn {
        display: none !important;
    }
}

/* ── 4. Breadcrumb truncation on small screens ── */
@media (max-width: 767.98px) {
    .breadcumb-wrapper {
        padding: 12px 0;
    }

    .breadcumb-menu {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        overflow: hidden;
        max-width: 100%;
    }

    .breadcumb-menu li {
        flex-shrink: 0;
        max-width: 100%;
    }

    .breadcumb-menu li:not(:first-child):not(:last-child) {
        display: none;
    }

    .breadcumb-menu li:last-child,
    .breadcumb-menu li:last-child a,
    .breadcumb-menu li:last-child span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: min(72vw, 100%);
        display: inline-block;
        vertical-align: bottom;
        font-size: 0.82rem;
        line-height: 1.35;
    }

    .breadcumb-menu li:first-child a {
        font-size: 0.82rem;
    }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    .breadcumb-menu li:last-child,
    .breadcumb-menu li:last-child a,
    .breadcumb-menu li:last-child span {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        vertical-align: bottom;
    }
}

/* ── 5. Faster preloader fade on mobile / reduced motion ── */
@media (max-width: 767.98px) {
    #site-preloader.is-hidden {
        transition-duration: 200ms !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    #site-preloader,
    #site-preloader.is-hidden {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
