/* Theme-level overrides load after page styles. Finexy uses its page styles unchanged. */

/* Mobile App Feel: Prevent horizontal scrolling and pinch zoom */
html,
body {
    /* `hidden` creates a scrolling ancestor and prevents desktop sticky sidebars. */
    overflow-x: clip !important;
    max-width: 100vw;
    width: 100%;
    touch-action: pan-y;
    overscroll-behavior-x: none;
    -webkit-text-size-adjust: 100%;
}

/* Keep the OPAC catalog filters attached to the document scroll on desktop. */
@media (min-width: 992px) {
    body[data-theme="finexy"] .opac-content-grid > .opac-filter-sidebar {
        position: -webkit-sticky !important;
        position: sticky !important;
        align-self: start;
        top: 92px;
        height: max-content;
        max-height: none;
        overflow: visible;
    }
}

/* Fullwidth Layout Adjustments */
body[data-theme="finexy"] .home-search-popular {
    display: none !important;
}
body[data-theme="finexy"] .container,
body[data-theme="finexy"] .home-shell,
body[data-theme="finexy"] .header-inner,
body[data-theme="finexy"] .skeleton-content-area,
body[data-theme="finexy"] .ai-spa-container,
body[data-theme="finexy"] .guest-location-shell,
body[data-theme="finexy"] .news-detail-shell,
body[data-theme="finexy"] .news-list-shell,
body[data-theme="finexy"] .survey-detail-shell,
body[data-theme="finexy"] .self-service-shell,
body[data-theme="finexy"] .survey-list-shell,
body[data-theme="finexy"] .registration-shell,
body[data-theme="finexy"] .catalog-browse-shell,
body[data-theme="finexy"] .catalog-statistics-shell,
body[data-theme="finexy"] .member-statistics-shell,
body[data-theme="finexy"] .visitor-statistics-shell,
body[data-theme="finexy"] .catalog-detail-shell,
body[data-theme="finexy"] .opac-catalog-shell,
body[data-theme="finexy"] .gt-content-wrapper,
body[data-theme="finexy"] .dashboard-container {
    max-width: 100% !important;
    padding-left: 30px !important;
    padding-right: 30px !important;
}

@media (max-width: 768px) {

    body[data-theme="finexy"] .container,
    body[data-theme="finexy"] .home-shell,
    body[data-theme="finexy"] .header-inner,
    body[data-theme="finexy"] .skeleton-content-area,
    body[data-theme="finexy"] .ai-spa-container,
    body[data-theme="finexy"] .guest-location-shell,
    body[data-theme="finexy"] .news-detail-shell,
    body[data-theme="finexy"] .news-list-shell,
    body[data-theme="finexy"] .survey-detail-shell,
    body[data-theme="finexy"] .self-service-shell,
    body[data-theme="finexy"] .survey-list-shell,
    body[data-theme="finexy"] .registration-shell,
    body[data-theme="finexy"] .catalog-browse-shell,
    body[data-theme="finexy"] .catalog-statistics-shell,
    body[data-theme="finexy"] .member-statistics-shell,
    body[data-theme="finexy"] .visitor-statistics-shell,
    body[data-theme="finexy"] .catalog-detail-shell,
    body[data-theme="finexy"] .opac-catalog-shell,
    body[data-theme="finexy"] .gt-content-wrapper,
    body[data-theme="finexy"] .dashboard-container,
    body[data-theme="finexy"] .midnight-content>.home-page,
    body[data-theme="finexy"] .midnight-content>.opac-catalog-page,
    body[data-theme="finexy"] .midnight-content>.catalog-browse-page,
    body[data-theme="finexy"] .midnight-content>.catalog-detail-page,
    body[data-theme="finexy"] .midnight-content>.catalog-statistics-page,
    body[data-theme="finexy"] .midnight-content>.member-statistics-page,
    body[data-theme="finexy"] .midnight-content>.visitor-statistics-page,
    body[data-theme="finexy"] .midnight-content>.member-registration-page,
    body[data-theme="finexy"] .midnight-content>.news-list-page,
    body[data-theme="finexy"] .midnight-content>.news-detail-page,
    body[data-theme="finexy"] .midnight-content>.survey-list-page,
    body[data-theme="finexy"] .midnight-content>.survey-detail-page,
    body[data-theme="finexy"] .midnight-content>.guest-location-page,
    body[data-theme="finexy"] .midnight-content>.self-service-page,
    body[data-theme="finexy"] .gt-page-container {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    body[data-theme="finexy"] .midnight-content>.container {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    body[data-theme="finexy"] .row {
        --bs-gutter-x: 10px;
        margin-left: -5px;
        margin-right: -5px;
    }

    .midnight-shell,
    .midnight-content,
    .opac-main {
        overflow-x: hidden !important;
        max-width: 100vw;
        width: 100%;
    }

    /* Finexy Mobile Home */
    body[data-theme="finexy"] .home-section {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 0 20px !important;
    }

    body[data-theme="finexy"] .home-section-header {
        background: transparent !important;
        border: none !important;
        padding: 0 2px 10px !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
    }

    body[data-theme="finexy"] .home-shortcut-list {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 16px 4px !important;
        padding: 4px 0 14px !important;
        overflow: visible !important;
    }

    body[data-theme="finexy"] .home-shortcut-list>a,
    body[data-theme="finexy"] .home-shortcut-list>button,
    body[data-theme="finexy"] .home-shortcut-list .shortcut-more-btn {
        flex: none !important;
        width: 100% !important;
        min-height: auto !important;
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        text-decoration: none !important;
        box-sizing: border-box !important;
        cursor: pointer !important;
    }

    body[data-theme="finexy"] .home-shortcut-list > a.shortcut-item-mobile-only {
        display: flex !important;
    }

    body[data-theme="finexy"] .home-shortcut-list > a.shortcut-item-modal-only {
        display: none !important;
    }

    body[data-theme="finexy"] .home-shortcut-list .shortcut-btn-desktop {
        display: none !important;
    }

    body[data-theme="finexy"] .home-shortcut-list .shortcut-btn-mobile {
        display: flex !important;
    }

    body[data-theme="finexy"] .home-shortcut-list>a:active,
    body[data-theme="finexy"] .home-shortcut-list>button:active {
        transform: scale(0.95) !important;
    }

    body[data-theme="finexy"] .home-shortcut-list>a>span,
    body[data-theme="finexy"] .home-shortcut-list>button>span,
    body[data-theme="finexy"] .home-shortcut-list .shortcut-more-btn>span {
        width: 52px !important;
        height: 52px !important;
        border-radius: 18px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 auto 8px auto !important;
        background: #ffffff !important;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03) !important;
        border: 1px solid rgba(226, 232, 240, 0.6) !important;
        flex-shrink: 0 !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    }

    body[data-theme="finexy"] .home-shortcut-list>a svg,
    body[data-theme="finexy"] .home-shortcut-list>button svg,
    body[data-theme="finexy"] .home-shortcut-list .shortcut-more-btn svg {
        width: 24px !important;
        height: 24px !important;
        stroke-width: 2 !important;
        color: var(--icon-color, #1959c7) !important;
    }

    body[data-theme="finexy"] .home-shortcut-list strong {
        font-size: 0.72rem !important;
        font-weight: 700 !important;
        color: #172b43 !important;
        text-align: center !important;
        line-height: 1.25 !important;
        margin: 0 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        word-break: break-word !important;
    }

    body[data-theme="finexy"] .home-shortcut-list small {
        display: none !important;
    }

    /* Modal Mobile Styles - 4 columns squircle cards matching screenshot */
    body[data-theme="finexy"] #allServicesModal .modal-dialog {
        margin: 16px auto !important;
        max-width: calc(100% - 32px) !important;
    }

    body[data-theme="finexy"] #allServicesModal .home-modal-content {
        border-radius: 20px !important;
        border: none !important;
        overflow: hidden !important;
        background: #ffffff !important;
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15) !important;
    }

    body[data-theme="finexy"] #allServicesModal .home-modal-header {
        background: #ffffff !important;
        border-bottom: none !important;
        padding: 22px 20px 10px 20px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    body[data-theme="finexy"] #allServicesModal .home-modal-title {
        font-size: 1.2rem !important;
        font-weight: 700 !important;
        color: #172b43 !important;
        margin: 0 !important;
    }

    body[data-theme="finexy"] #allServicesModal .home-modal-header .btn-close {
        padding: 8px !important;
        margin: -8px -4px -8px auto !important;
        opacity: 0.6 !important;
        transition: opacity 0.2s ease !important;
    }

    body[data-theme="finexy"] #allServicesModal .home-modal-body {
        padding: 8px 14px 24px 14px !important;
        background: #ffffff !important;
    }

    body[data-theme="finexy"] .home-shortcut-list-modal {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 18px 6px !important;
        padding: 0 !important;
    }

    body[data-theme="finexy"] .home-shortcut-list-modal > a {
        flex: none !important;
        width: 100% !important;
        min-height: auto !important;
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        text-decoration: none !important;
        box-sizing: border-box !important;
        cursor: pointer !important;
    }

    body[data-theme="finexy"] .home-shortcut-list-modal > a:active {
        transform: scale(0.95) !important;
    }

    body[data-theme="finexy"] .home-shortcut-list-modal > a > span {
        width: 52px !important;
        height: 52px !important;
        border-radius: 18px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 auto 8px auto !important;
        background: #ffffff !important;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03) !important;
        border: 1px solid rgba(226, 232, 240, 0.6) !important;
        flex-shrink: 0 !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    }

    body[data-theme="finexy"] .home-shortcut-list-modal > a svg {
        width: 24px !important;
        height: 24px !important;
        stroke-width: 2 !important;
        color: var(--icon-color, #1959c7) !important;
    }

    body[data-theme="finexy"] .home-shortcut-list-modal > a strong {
        font-size: 0.72rem !important;
        font-weight: 700 !important;
        color: #172b43 !important;
        text-align: center !important;
        line-height: 1.25 !important;
        margin: 0 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        word-break: break-word !important;
    }

    body[data-theme="finexy"] .home-shortcut-list-modal > a small {
        display: none !important;
    }

    body[data-theme="finexy"] .home-stat-list {
        display: flex !important;
        gap: 10px !important;
        padding: 2px 0 10px !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        scrollbar-width: none !important;
        background: transparent !important;
        border: none !important;
    }

    body[data-theme="finexy"] .home-stat-card {
        flex: 0 0 180px !important;
        min-height: 94px !important;
        border-radius: 16px !important;
        background: #ffffff !important;
        border: 1px solid #eef2f6 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03) !important;
        padding: 14px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        scroll-snap-align: start !important;
        box-sizing: border-box !important;
    }
}
