/* LoopMensal - Mobile and tablet refinements */

@media (max-width: 991.98px) {
    html { scroll-padding-top: 72px; }

    body { overflow-x: hidden; }

    .navbar {
        position: sticky;
        top: 0;
        z-index: 1030;
        box-shadow: 0 8px 24px rgba(13, 110, 253, .16);
    }

    .navbar .container { padding-inline: 1rem; }
    .navbar-brand { font-size: 1.1rem !important; }

    .navbar-collapse {
        margin-top: .75rem;
        padding: .75rem;
        background: rgba(255, 255, 255, .1);
        border-radius: 8px;
    }

    .navbar-nav {
        align-items: stretch !important;
        gap: .35rem !important;
    }

    .navbar-nav .nav-link,
    .navbar-nav .btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }

    .hero-section {
        min-height: auto;
        padding-block: 2rem;
    }

    .min-vh-75 { min-height: auto; }

    .hero-section .row { min-height: auto !important; }
    .hero-section .col-lg-6 { padding-block: 2rem !important; }

    .display-4,
    .display-5,
    .display-6 {
        line-height: 1.08;
    }

    .display-4 { font-size: 2.35rem; }
    .display-5 { font-size: 2rem; }
    .display-6 { font-size: 1.75rem; }

    .lead { font-size: 1rem; }

    .hero-section .btn,
    .py-6 .btn {
        width: 100%;
        justify-content: center;
    }

    .hero-section .d-flex.flex-wrap.gap-3 {
        display: grid !important;
        grid-template-columns: 1fr;
    }

    .py-6 {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }

    .feature-card .card-body { padding: 1.25rem !important; }

    .brand-logo-lg {
        width: 52px;
        height: 52px;
        border-radius: 14px;
    }

    .min-vh-100.d-flex.align-items-center.bg-light {
        align-items: flex-start !important;
        min-height: auto !important;
        padding-block: 2rem;
    }

    .min-vh-100 .card.rounded-4 {
        border-radius: 12px !important;
    }

    .min-vh-100 .card-body {
        padding: 1.25rem !important;
    }

    .footer { padding-block: 1.5rem !important; }

    /* Logged-in app shell */
    #app-wrapper {
        display: block !important;
        min-height: 100dvh;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(82vw, var(--sidebar-width));
        max-width: 320px;
        min-height: 100dvh;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 18px 0 42px rgba(15, 23, 42, .28);
        overflow-y: auto;
    }

    .sidebar.collapsed {
        width: min(82vw, var(--sidebar-width));
        transform: translateX(0);
    }

    .sidebar.collapsed span,
    .sidebar.collapsed .sidebar-tenant {
        display: block !important;
    }

    .sidebar.collapsed .sidebar-link {
        justify-content: flex-start;
        padding: .65rem .8rem;
    }

    .sidebar.collapsed .nav-link.sidebar-link i {
        width: 20px;
        margin: 0;
    }

    #main-content {
        width: 100%;
        min-height: 100dvh;
    }

    .top-bar {
        height: auto;
        min-height: var(--topbar-height);
        padding-inline: 1rem !important;
        gap: .75rem;
    }

    .top-bar > .d-flex {
        gap: .5rem !important;
        min-width: 0;
    }

    #toggle-sidebar {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
        border-radius: 8px;
    }

    .topbar-user-avatar {
        width: 38px;
        height: 38px;
    }

    #main-content > .p-4 {
        padding: 1rem !important;
    }

    .app-footer {
        padding: 1rem !important;
        text-align: center;
    }

    .app-footer .d-flex:last-child {
        justify-content: center;
        flex-wrap: wrap;
    }

    .category-form-card {
        position: static;
    }

    .category-summary-card {
        min-height: 82px;
        padding: .9rem;
    }

    .category-health {
        width: 100%;
        border-radius: 8px;
    }

    .modal-dialog {
        margin: .75rem;
    }

    .modal-body {
        padding: 1rem !important;
    }

    .whatsapp-float {
        right: 1rem;
        bottom: 1rem;
        width: 3rem;
        height: 3rem;
        font-size: 1.45rem;
    }
}

@media (max-width: 767.98px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .display-4 { font-size: 2rem; }
    .display-5 { font-size: 1.75rem; }
    .display-6 { font-size: 1.55rem; }

    h1, .h1 { font-size: 1.85rem; }
    h2, .h2 { font-size: 1.55rem; }
    h3, .h3 { font-size: 1.35rem; }
    h4, .h4 { font-size: 1.2rem; }

    .card {
        border-radius: 8px !important;
    }

    .card-header,
    .card-body,
    .card-footer {
        padding: 1rem !important;
    }

    .row.g-4 { --bs-gutter-y: 1rem; }
    .row.g-3 { --bs-gutter-y: .85rem; }

    .btn-lg {
        min-height: 46px;
        padding: .65rem 1rem !important;
        font-size: 1rem;
    }

    .form-control,
    .form-select,
    .btn {
        min-height: 42px;
    }

    .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: .35rem;
        padding-bottom: .35rem;
        scrollbar-width: thin;
    }

    .nav-tabs .nav-item {
        flex: 0 0 auto;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        border-radius: 8px;
        font-size: .9rem;
    }

    .table-responsive {
        border-radius: 8px;
        border: 1px solid rgba(15, 23, 42, .06);
    }

    .table {
        min-width: 680px;
    }

    .table th,
    .table td {
        white-space: nowrap;
    }

    .dropdown-menu {
        max-width: calc(100vw - 1.5rem);
    }

    .loading-box {
        padding: 2rem 1.25rem;
        border-radius: 16px;
    }

    .loading-ring {
        width: 70px;
        height: 70px;
    }

    .loading-icon-spin {
        font-size: 2rem;
    }

    .category-type-selector {
        grid-template-columns: 1fr;
    }

    .category-summary-value {
        font-size: 1.35rem;
    }

    .category-row-icon {
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 575.98px) {
    .navbar .container {
        padding-inline: .85rem;
    }

    .navbar-collapse {
        border-radius: 8px;
    }

    .hero-section {
        text-align: center;
    }

    .hero-section .badge {
        white-space: normal;
        line-height: 1.35;
    }

    .hero-section .mt-4.d-flex {
        justify-content: center;
        align-items: center;
        flex-direction: column;
        gap: .75rem !important;
    }

    .border-y .d-flex.flex-wrap {
        justify-content: flex-start !important;
        gap: .85rem !important;
    }

    .border-y .d-flex.align-items-center {
        width: 100%;
        padding: .5rem .75rem;
        background: #fff;
        border: 1px solid rgba(15, 23, 42, .06);
        border-radius: 8px;
    }

    .min-vh-100 .container {
        padding-inline: .85rem;
    }

    .min-vh-100 .text-center.mb-4 {
        margin-bottom: 1rem !important;
    }

    .form-check-label,
    .small {
        line-height: 1.35;
    }

    .top-bar {
        padding-inline: .75rem !important;
    }

    .topbar-user > button {
        padding: .2rem !important;
    }

    .topbar-user .dropdown-menu {
        position: fixed !important;
        inset: auto .75rem auto .75rem !important;
        transform: none !important;
        width: auto;
    }

    #main-content > .p-4 {
        padding: .75rem !important;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 {
        align-items: flex-start !important;
        gap: .75rem;
    }

    .help-btn {
        width: 38px;
        height: 38px;
    }

    .toast-auto,
    .alert {
        font-size: .9rem;
    }

    .swal2-popup {
        width: calc(100vw - 2rem) !important;
    }
}
