/**
 * S-Cloud — Mobile PWA Android-native Design
 * v2.3.14 — Expert designer pass
 *
 * Transforms the mobile experience into an Android-app-like UI:
 *   - Material Design 3 bottom nav with pill indicator
 *   - Edge-to-edge content (no boxed card wrapper)
 *   - Larger touch targets (48px minimum)
 *   - Generous border-radius (16px cards, pill buttons)
 *   - Surface-level elevation system
 *   - Smooth spring-based transitions
 *   - Full-width bottom sheets
 *   - Native-feeling scrolling & interactions
 *
 * Loaded LAST — overrides everything on mobile only.
 * Desktop is completely unaffected (all rules inside @media).
 */

/* ════════════════════════════════════════════════════════════════════
 *  1. GLOBAL MOBILE FOUNDATION (< 992px)
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* ── System-level feel ────────────────────────────────────────── */
    html {
        -webkit-tap-highlight-color: transparent;
        -webkit-text-size-adjust: 100%;
        scroll-behavior: smooth;
        overscroll-behavior-y: contain;          /* no pull-to-refresh bounce */
    }
    body.app-layout {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        overflow-x: hidden;
        background: #F3F4F6 !important;          /* warm gray surface */
    }

    /* ── Edge-to-edge content ────────────────────────────────────── */
    .app-content {
        background: #F3F4F6 !important;          /* match body */
        padding-top: 8px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .app-content > .container-fluid {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* Remove the card wrapper — content flows naturally like an app */
    .app-content-inner.card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    .app-content-inner.card > .card-body {
        padding: 0 !important;
        background: transparent !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  2. TOPBAR — Immersive App Bar
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .app-topbar,
    .app-topbar .sc-topbar {
        background: #FFFFFF !important;
        background-color: #FFFFFF !important;
        border-bottom: 1px solid rgba(0,0,0,.06) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,.04) !important;
    }

    /* Search bar — pill shaped, taller for thumb reach */
    .sc-search-input,
    .sc-search-wrap input.sc-search-input {
        background: #F3F4F6 !important;
        border: none !important;
        border-radius: 24px !important;
        height: 40px !important;
        padding: 8px 16px 8px 40px !important;
        font-size: 15px !important;
        color: #1F2937 !important;
        transition: background .2s, box-shadow .2s;
    }
    .sc-search-input::placeholder {
        color: #9CA3AF !important;
        font-size: 14px !important;
    }
    .sc-search-input:focus {
        background: #FFFFFF !important;
        box-shadow: 0 0 0 2px rgba(79,70,229,.2), 0 2px 8px rgba(0,0,0,.08) !important;
        border: none !important;
    }

    /* Icon buttons — 44px touch targets */
    .sc-topbar-icon-btn {
        width: 40px !important;
        height: 40px !important;
        border-radius: 20px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: background .15s ease;
    }
    .sc-topbar-icon-btn:active {
        background: rgba(0,0,0,.08) !important;
        transform: scale(.95);
    }

    /* Notification badge */
    .sc-topbar-badge {
        box-shadow: 0 0 0 2px #FFFFFF !important;   /* ring matches white topbar */
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  3. BOTTOM NAVIGATION — Material Design 3
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .sc-mobile-nav {
        height: 72px !important;
        background: #FFFFFF !important;
        background-color: #FFFFFF !important;
        border-top: none !important;
        box-shadow: 0 -2px 12px rgba(0,0,0,.06) !important;
    }

    .sc-mnav-items {
        padding: 0 8px !important;
        align-items: center !important;
    }

    /* Nav items — larger touch zone, MD3 style */
    .sc-mnav-item {
        gap: 4px !important;
        padding: 4px 0 8px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        color: #6B7280 !important;
        border-radius: 0 !important;
        min-height: 64px !important;
        justify-content: flex-end !important;
        transition: color .2s ease !important;
    }
    .sc-mnav-item .sc-mnav-icon,
    .sc-mnav-item svg {
        width: 24px !important;
        height: 24px !important;
        transition: transform .2s cubic-bezier(.2,0,0,1);
    }

    /* MD3 Active pill indicator behind icon */
    .sc-mnav-item.is-active {
        color: #4F46E5 !important;
    }
    .sc-mnav-item.is-active .sc-mnav-icon,
    .sc-mnav-item.is-active > svg {
        position: relative;
    }
    .sc-mnav-item.is-active .sc-mnav-icon::before,
    .sc-mnav-item.is-active::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 56px;
        height: 32px;
        background: rgba(79, 70, 229, .12);
        border-radius: 16px;
        z-index: -1;
        animation: md3-pill-in .3s cubic-bezier(.2,0,0,1) forwards;
    }
    @keyframes md3-pill-in {
        from { width: 0; opacity: 0; }
        to   { width: 56px; opacity: 1; }
    }

    /* Active dot hidden (replaced by pill) */
    .sc-mnav-dot { display: none !important; }

    /* Active icon emphasis */
    .sc-mnav-item.is-active svg {
        stroke-width: 2.2 !important;
    }

    /* Badge — slightly larger, proper positioning */
    .sc-mnav-badge {
        top: 2px !important;
        right: 14% !important;
        font-size: 10px !important;
        min-width: 18px !important;
        height: 18px !important;
        padding: 0 5px !important;
        border-radius: 9px !important;
        box-shadow: 0 1px 4px rgba(239, 68, 68, .35);
    }

    /* Menu button — brand color */
    .sc-mnav-menu-btn {
        color: #4F46E5 !important;
    }

    /* FAB — Material Design 3 elevated FAB */
    .sc-mnav-fab {
        width: 56px !important;
        height: 56px !important;
        flex: 0 0 56px !important;
        margin: -22px 6px 0 !important;
        border-radius: 16px !important;             /* MD3 FAB = rounded square */
        background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%) !important;
        box-shadow:
            0 4px 8px rgba(79,70,229,.3),
            0 1px 3px rgba(79,70,229,.15) !important;
        transition: transform .2s cubic-bezier(.2,0,0,1), box-shadow .2s !important;
    }
    .sc-mnav-fab:active {
        transform: scale(.92) !important;
        box-shadow: 0 2px 4px rgba(79,70,229,.2) !important;
    }
    .sc-mnav-fab svg {
        width: 24px !important;
        height: 24px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  4. CARDS — Material Elevation System
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* Inner cards get proper Material treatment */
    .app-content .card:not(.app-content-inner) {
        border-radius: 16px !important;
        border: 1px solid rgba(0,0,0,.05) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04) !important;
        background: #FFFFFF !important;
        overflow: hidden;
        margin-bottom: 12px;
    }
    .app-content .card:not(.app-content-inner) .card-body {
        padding: 16px !important;
    }
    .app-content .card:not(.app-content-inner) .card-header {
        background: transparent !important;
        border-bottom: 1px solid rgba(0,0,0,.05) !important;
        padding: 14px 16px !important;
        font-weight: 600;
    }
    .app-content .card:not(.app-content-inner) .card-footer {
        background: transparent !important;
        border-top: 1px solid rgba(0,0,0,.05) !important;
        padding: 12px 16px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  5. BUTTONS — Android-native Touch Targets
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* All buttons: 44px minimum height, rounded */
    .btn {
        min-height: 44px !important;
        border-radius: 12px !important;
        padding: 10px 20px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        transition: transform .1s, background .15s, box-shadow .15s !important;
        -webkit-tap-highlight-color: transparent;
    }
    .btn:active {
        transform: scale(.97) !important;
    }

    /* Primary — filled, elevated */
    .btn-primary {
        box-shadow: 0 1px 3px rgba(79,70,229,.2) !important;
    }
    .btn-primary:active {
        box-shadow: none !important;
    }

    /* Small buttons — still 40px minimum */
    .btn-sm {
        min-height: 40px !important;
        padding: 8px 16px !important;
        border-radius: 10px !important;
        font-size: 13px !important;
    }

    /* Icon-only buttons (action row) */
    .btn .bi, .btn svg {
        vertical-align: middle;
    }

    /* Toolbar buttons — flex wrap nicely */
    .sc-toolbar {
        gap: 8px !important;
        flex-wrap: wrap !important;
    }
    .sc-toolbar .btn {
        min-height: 40px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  6. FORMS & INPUTS — Material-style
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .form-control,
    .form-select {
        height: 48px !important;
        min-height: 48px !important;
        border-radius: 12px !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
        border: 1.5px solid #E5E7EB !important;
        background: #FFFFFF !important;
        color: #1F2937 !important;
        transition: border-color .2s, box-shadow .2s !important;
    }
    .form-control:focus,
    .form-select:focus {
        border-color: #4F46E5 !important;
        box-shadow: 0 0 0 3px rgba(79,70,229,.12) !important;
        outline: none !important;
    }

    textarea.form-control {
        height: auto !important;
        min-height: 100px !important;
    }

    .form-label {
        font-size: 13px !important;
        font-weight: 600 !important;
        color: #374151 !important;
        margin-bottom: 6px !important;
    }

    .form-check {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        padding-left: 2em !important;
    }
    .form-check-input {
        width: 20px !important;
        height: 20px !important;
        border-radius: 6px !important;
        border: 2px solid #D1D5DB !important;
    }
    .form-check-input:checked {
        border-color: #4F46E5 !important;
        background-color: #4F46E5 !important;
    }

    /* Form groups spacing */
    .mb-3, .mb-4 {
        margin-bottom: 16px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  7. MODALS — Bottom Sheet Style
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {

    /* Bootstrap modals → bottom sheet */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: translateY(100%) !important;
        transition: transform .3s cubic-bezier(.32,.72,0,1) !important;
    }
    .modal.show .modal-dialog {
        transform: translateY(0) !important;
    }

    .modal-content {
        border-radius: 20px 20px 0 0 !important;
        border: none !important;
        box-shadow: 0 -4px 24px rgba(0,0,0,.12) !important;
        max-height: 90vh !important;
        height: auto !important;
        min-height: auto !important;
    }
    /* Handle bar at top of bottom sheet */
    .modal-content::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: #D1D5DB;
        border-radius: 2px;
        margin: 10px auto 4px;
    }

    .modal-header {
        border-bottom: 1px solid rgba(0,0,0,.06) !important;
        padding: 12px 20px 14px !important;
    }
    .modal-body {
        padding: 16px 20px !important;
        max-height: 65vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .modal-footer {
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
        border-top: 1px solid rgba(0,0,0,.06) !important;
    }

    /* Backdrop — softer */
    .modal-backdrop.show {
        opacity: 0.35 !important;
        background: #000 !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  8. MENU MODAL — Full-Width Bottom Sheet
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .sc-app-menu-overlay {
        align-items: flex-end !important;          /* slide from bottom */
        padding: 0 !important;
    }
    .sc-app-menu-dialog {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 24px 24px 0 0 !important;
        max-height: 92vh !important;
        box-shadow: 0 -8px 30px rgba(0,0,0,.15) !important;
        transform: translateY(100%) !important;
        transition: transform .35s cubic-bezier(.32,.72,0,1) !important;
    }
    .sc-app-menu-overlay.is-open .sc-app-menu-dialog {
        transform: translateY(0) !important;
    }
    .sc-app-menu-overlay {
        background: rgba(0,0,0,.4) !important;
        backdrop-filter: blur(2px) !important;
    }

    /* Handle bar */
    .sc-app-menu-dialog::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(255,255,255,.4);
        border-radius: 2px;
        margin: 10px auto 0;
    }

    /* Header — slightly taller for thumb reach */
    .sc-app-menu-header {
        padding: 14px 20px 16px !important;
        border-radius: 24px 24px 0 0;
    }
    .sc-app-menu-avatar {
        width: 48px !important;
        height: 48px !important;
        font-size: 1rem !important;
    }
    .sc-app-menu-user-name {
        font-size: 1.05rem !important;
    }
    .sc-app-menu-close {
        width: 40px !important;
        height: 40px !important;
    }

    /* Grid — 4 columns for more compact layout */
    .sc-app-menu-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
        padding: 16px 12px !important;
    }
    .sc-app-menu-item {
        gap: 6px !important;
        padding: 12px 4px !important;
        border-radius: 16px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        background: transparent !important;
    }
    .sc-app-menu-item:active {
        background: rgba(0,0,0,.04) !important;
        transform: scale(.96) !important;
    }
    .sc-app-menu-icon {
        width: 48px !important;
        height: 48px !important;
        border-radius: 14px !important;
        box-shadow: 0 2px 6px rgba(0,0,0,.1) !important;
    }

    /* Logout button — full width with safe area */
    .sc-app-menu-logout {
        padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        font-size: .88rem !important;
        border-top: 1px solid #E5E7EB !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  9. FAB SHEET — Enhanced Bottom Sheet
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .sc-fab-sheet-content {
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 24px 24px 0 0 !important;
        padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        box-shadow: 0 -8px 30px rgba(0,0,0,.15) !important;
        transform: translateY(100%) !important;
        transition: transform .3s cubic-bezier(.32,.72,0,1) !important;
    }
    .sc-fab-sheet.is-open .sc-fab-sheet-content {
        transform: translateY(0) !important;
    }

    .sc-fab-sheet-handle {
        width: 36px !important;
        height: 4px !important;
        background: #D1D5DB !important;
        margin: 8px auto 12px !important;
    }
    .sc-fab-sheet-title {
        font-size: 16px !important;
        font-weight: 700 !important;
        margin-bottom: 12px !important;
    }

    /* 4-column grid */
    .sc-fab-sheet-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    .sc-fab-action {
        padding: 12px 4px !important;
        border-radius: 14px !important;
        font-size: 11px !important;
    }
    .sc-fab-action:active {
        background: rgba(0,0,0,.04) !important;
        transform: scale(.95) !important;
    }
    .sc-fab-action-icon {
        width: 48px !important;
        height: 48px !important;
        border-radius: 14px !important;
    }

    .sc-fab-sheet-overlay {
        background: rgba(0,0,0,.35) !important;
        backdrop-filter: blur(2px) !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  10. TABLES — Touch-friendly Rows
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* Table rows taller for touch */
    .table td, .table th {
        padding: 14px 12px !important;
        vertical-align: middle !important;
    }
    .table th {
        font-size: 12px !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: .03em !important;
        color: #6B7280 !important;
        white-space: nowrap;
    }

    /* Alternating row background */
    .table-striped > tbody > tr:nth-of-type(odd) > * {
        background-color: rgba(0,0,0,.015) !important;
    }

    /* Responsive table container */
    .table-responsive {
        border-radius: 16px !important;
        border: 1px solid rgba(0,0,0,.05) !important;
        background: #FFFFFF;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  11. LIST GROUPS — Native List Style
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .list-group {
        border-radius: 16px !important;
        overflow: hidden;
        border: 1px solid rgba(0,0,0,.05) !important;
    }
    .list-group-item {
        padding: 14px 16px !important;
        border-color: rgba(0,0,0,.04) !important;
        min-height: 52px !important;
        display: flex;
        align-items: center;
    }
    .list-group-item:active {
        background: rgba(0,0,0,.04) !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  12. TYPOGRAPHY — Mobile Hierarchy
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* Page titles — bolder, left-aligned */
    .app-content h2,
    .app-content .h2 {
        font-size: 22px !important;
        font-weight: 700 !important;
        line-height: 1.3 !important;
        color: #111827 !important;
        letter-spacing: -0.02em;
    }
    .app-content h3,
    .app-content .h3 {
        font-size: 18px !important;
        font-weight: 600 !important;
        line-height: 1.35 !important;
    }
    .app-content h4,
    .app-content .h4 {
        font-size: 16px !important;
        font-weight: 600 !important;
    }

    /* Body text slightly larger on mobile for readability */
    .app-content p,
    .app-content .text-muted,
    .app-content td,
    .app-content label:not(.form-label) {
        font-size: 14px !important;
        line-height: 1.55 !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  13. BADGES & CHIPS — Rounded Pills
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .badge {
        border-radius: 8px !important;
        padding: 5px 10px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  14. BREADCRUMB — Compact, Horizontal Scroll
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .breadcrumb {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 8px 0 !important;
        margin-bottom: 8px !important;
        gap: 0 !important;
    }
    .breadcrumb::-webkit-scrollbar { display: none; }
    .breadcrumb-item {
        white-space: nowrap;
        font-size: 13px !important;
    }
    .breadcrumb-item + .breadcrumb-item::before {
        padding: 0 6px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  15. TABS — Scrollable, Pill-shaped
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-bottom: 2px solid rgba(0,0,0,.05) !important;
        gap: 4px !important;
        padding-bottom: 0 !important;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link {
        white-space: nowrap !important;
        padding: 10px 16px !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        border-radius: 8px 8px 0 0 !important;
        min-height: 40px !important;
    }
    .nav-tabs .nav-link.active {
        border-bottom: 3px solid #4F46E5 !important;
        color: #4F46E5 !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  16. ALERTS — Rounded, Compact
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .alert {
        border-radius: 14px !important;
        padding: 14px 16px !important;
        font-size: 14px !important;
        border-width: 1px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  17. DROPDOWNS — Elevated Surface
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .dropdown-menu {
        border-radius: 16px !important;
        border: 1px solid rgba(0,0,0,.06) !important;
        box-shadow: 0 8px 24px rgba(0,0,0,.12) !important;
        padding: 8px !important;
    }
    .dropdown-item {
        border-radius: 10px !important;
        padding: 10px 14px !important;
        font-size: 14px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        transition: background .12s !important;
    }
    .dropdown-item:active {
        background: rgba(79,70,229,.08) !important;
        color: #4F46E5 !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  18. PAGE HEADERS — App-style
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .sc-page-header {
        padding: 12px 0 8px !important;
        margin-bottom: 12px !important;
    }
    .sc-page-header h2,
    .sc-page-header .h2 {
        margin-bottom: 0 !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  19. EXPLORER / FILE VIEWS — Card Grid
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* File cards in grid view */
    .sc-item-card {
        border-radius: 14px !important;
        border: 1px solid rgba(0,0,0,.05) !important;
        box-shadow: 0 1px 2px rgba(0,0,0,.04) !important;
        overflow: hidden;
        transition: transform .15s, box-shadow .15s !important;
    }
    .sc-item-card:active {
        transform: scale(.98) !important;
    }

    /* File list rows */
    .sc-row-item {
        padding: 12px 14px !important;
        border-bottom: 1px solid rgba(0,0,0,.04) !important;
        min-height: 56px !important;
    }
    .sc-row-item:active {
        background: rgba(0,0,0,.02) !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  20. ADMIN SUBNAV — Scrollable Chips
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .sc-admin-subnav {
        margin-left: -16px !important;
        margin-right: -16px !important;
        padding: 0 16px !important;
    }
    .sc-adm-link {
        padding: 10px 12px !important;
        font-size: 13px !important;
        white-space: nowrap;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  21. PAGINATION — Touch-friendly
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .pagination {
        gap: 4px !important;
    }
    .page-link {
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        padding: 6px 10px !important;
    }
    .page-item.active .page-link {
        border-radius: 10px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  22. TOAST / NOTIFICATIONS — Material Snackbar
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .toast, .sc-toast {
        border-radius: 14px !important;
        box-shadow: 0 6px 16px rgba(0,0,0,.12) !important;
        margin: 8px 16px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  23. SCROLLBARS — Hidden on Mobile (native)
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* Hide scrollbars but keep scroll behavior (Android-native feel) */
    .app-content::-webkit-scrollbar,
    .modal-body::-webkit-scrollbar,
    .card-body::-webkit-scrollbar {
        display: none;
    }
    .app-content,
    .modal-body,
    .card-body {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  24. TRANSITIONS & ANIMATIONS — Spring-based
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* Smooth elastic transitions for interactive elements */
    .btn, .sc-mnav-item, .dropdown-item, .list-group-item, .sc-fab-action, .sc-app-menu-item {
        transition: transform .12s cubic-bezier(.2,0,0,1), background .15s, color .15s, box-shadow .15s !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  25. AVATAR — Consistent Sizing
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .sc-avatar {
        border-radius: 50% !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  26. SPACING FINE-TUNING — Breathable Mobile Layout
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* Content bottom padding for bottom nav */
    .app-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Spacing between major sections */
    .app-content .row {
        --bs-gutter-x: 12px;
    }
    .app-content .row > [class*="col-"] {
        margin-bottom: 12px;
    }

    /* Flash messages — match new card style */
    .alert.alert-dismissible {
        margin-bottom: 12px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  27. SMALL PHONE (< 576px) — Extra Compact
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {

    .app-content > .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* FAB grid → 3 columns on very small screens */
    .sc-fab-sheet-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Menu grid → 3 columns on very small screens */
    .sc-app-menu-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  28. LANDSCAPE PHONE — Adapt Layout
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) and (orientation: landscape) and (max-height: 500px) {

    /* Compact bottom nav in landscape */
    .sc-mobile-nav {
        height: 56px !important;
    }
    .sc-mnav-item {
        min-height: 48px !important;
        font-size: 10px !important;
    }
    .sc-mnav-fab {
        width: 46px !important;
        height: 46px !important;
        margin-top: -14px !important;
        border-radius: 13px !important;
    }

    /* Content padding adjusted */
    .app-content {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Bottom sheets shorter */
    .sc-app-menu-dialog,
    .sc-fab-sheet-content {
        max-height: 85vh !important;
    }
    .modal-content {
        max-height: 85vh !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  29. DARK STATUS BAR INTEGRATION
 *  On Android PWA, theme-color controls the status bar.
 *  We ensure the topbar blends seamlessly with a white surface.
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) and (display-mode: standalone) {

    /* In standalone PWA mode — extra immersive */
    .app-topbar,
    .app-topbar .sc-topbar {
        padding-top: env(safe-area-inset-top, 0px) !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  30. COMMENTS PANEL — Chat-like Bubbles
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .sc-comment {
        border-radius: 16px !important;
        padding: 12px 14px !important;
        margin-bottom: 8px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  31. EMPTY STATES — Centered, Generous
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .ks-empty {
        padding: 48px 24px !important;
        text-align: center;
    }
    .ks-empty__icon {
        width: 64px !important;
        height: 64px !important;
        margin-bottom: 16px !important;
    }
    .ks-empty__title {
        font-size: 16px !important;
        font-weight: 600 !important;
        margin-bottom: 8px !important;
    }
    .ks-empty__hint {
        font-size: 13px !important;
        color: #6B7280 !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  32. DATATABLE — Mobile Polish
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    .dataTables_wrapper {
        overflow: hidden;
    }
    .dataTables_filter input {
        border-radius: 12px !important;
        height: 40px !important;
        padding: 8px 14px !important;
        border: 1.5px solid #E5E7EB !important;
    }
    .dataTables_filter input:focus {
        border-color: #4F46E5 !important;
        box-shadow: 0 0 0 3px rgba(79,70,229,.1) !important;
    }
    .dataTables_length select {
        border-radius: 10px !important;
        height: 40px !important;
        padding: 6px 10px !important;
    }
    .dataTables_info {
        font-size: 12px !important;
        color: #6B7280 !important;
        padding: 8px 0 !important;
    }
    .dataTables_paginate .paginate_button {
        min-width: 36px !important;
        min-height: 36px !important;
        border-radius: 8px !important;
        padding: 6px 10px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
 *  33. DASHBOARD MOBILE — App-native Home Screen
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* ── Mobile greeting header ──────────────────────────────────── */
    .sc-dash-mobile-greeting {
        display: flex !important;
        align-items: center;
        gap: 12px;
        padding: 4px 0 16px;
    }
    .sc-dash-mg-avatar {
        width: 44px;
        height: 44px;
        border-radius: 22px;
        background: linear-gradient(135deg, #4F46E5, #818CF8);
        color: #fff;
        font-size: 18px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    .sc-dash-mg-text {
        flex: 1;
        min-width: 0;
    }
    .sc-dash-mg-hello {
        font-size: 20px;
        font-weight: 700;
        color: #111827;
        line-height: 1.25;
        letter-spacing: -0.01em;
    }
    .sc-dash-mg-date {
        font-size: 13px;
        color: #6B7280;
        margin-top: 2px;
    }
    .sc-dash-mg-notif {
        width: 40px;
        height: 40px;
        border-radius: 20px;
        background: #FEF2F2;
        color: #EF4444;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        position: relative;
        text-decoration: none;
    }
    .sc-dash-mg-notif:active {
        transform: scale(.92);
    }
    .sc-dash-mg-notif-badge {
        position: absolute;
        top: -2px;
        right: -2px;
        background: #EF4444;
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        min-width: 18px;
        height: 18px;
        border-radius: 9px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        box-shadow: 0 0 0 2px #F3F4F6;
    }

    /* ── Hide desktop toolbar on mobile (redundant with bottom nav) ── */
    .sc-page-header .sc-toolbar {
        display: none !important;
    }
    .sc-page-header {
        margin-bottom: 4px !important;
        padding: 0 !important;
    }

    /* ── Section headers — cleaner, bolder ────────────────────────── */
    .app-content h5.text-muted.text-uppercase {
        font-size: 13px !important;
        font-weight: 700 !important;
        color: #374151 !important;
        letter-spacing: .04em !important;
        margin-bottom: 8px !important;
    }

    /* ── Quick links → horizontal scroll chips ────────────────────── */
    .sc-quick-links {
        display: flex !important;
        grid-template-columns: none !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px !important;
        padding-bottom: 4px;
        margin-left: -12px !important;
        margin-right: -12px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    .sc-quick-links::-webkit-scrollbar { display: none; }
    .sc-quick-link {
        flex-shrink: 0 !important;
        min-width: auto !important;
        padding: 10px 16px !important;
        border-radius: 24px !important;
        font-size: 13px !important;
        border-color: rgba(0,0,0,.06) !important;
        background: #fff !important;
        box-shadow: 0 1px 3px rgba(0,0,0,.04) !important;
    }
    .sc-quick-link:active {
        transform: scale(.96) !important;
        background: #F3F4F6 !important;
    }

    /* ── News → horizontal scroll cards ───────────────────────────── */
    .sc-news-row {
        display: flex !important;
        grid-template-columns: none !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 10px !important;
        margin-left: -12px !important;
        margin-right: -12px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        padding-bottom: 4px;
    }
    .sc-news-row::-webkit-scrollbar { display: none; }
    .sc-news-mini {
        flex-shrink: 0 !important;
        width: 240px !important;
        border-radius: 14px !important;
        border-color: rgba(0,0,0,.05) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,.04) !important;
    }
    .sc-news-mini:active {
        transform: scale(.98) !important;
    }

    /* ── Quick tiles (Recent/Activity) — prominent, stacked ──────── */
    .sc-quick-tiles {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .sc-quick-tile {
        border-radius: 16px !important;
        padding: 16px !important;
        border-color: rgba(0,0,0,.05) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,.04) !important;
    }
    .sc-quick-tile:active {
        transform: scale(.98) !important;
    }
    .sc-quick-tile-ic {
        width: 48px !important;
        height: 48px !important;
        border-radius: 14px !important;
    }
    .sc-quick-tile-title {
        font-size: 15px !important;
    }
    .sc-quick-tile-sub {
        font-size: 13px !important;
    }

    /* ── Space cards (sc-view) — rounded, elevated ────────────────── */
    .sc-view.sc-view--tiles {
        gap: 10px !important;
    }
    .sc-view-item {
        border-radius: 14px !important;
        border-color: rgba(0,0,0,.05) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,.04) !important;
        padding: 14px !important;
        background: #FFFFFF !important;
    }
    .sc-view-item:active {
        background: #F9FAFB !important;
        transform: scale(.99);
    }
    .sc-view-item-name {
        font-size: 15px !important;
        font-weight: 600 !important;
    }
    .sc-view-item-sub {
        font-size: 12px !important;
        color: #6B7280 !important;
    }

    /* Shared with me — card style */
    .sc-folder-grid {
        gap: 8px !important;
    }
    .sc-folder {
        border-radius: 14px !important;
        border-color: rgba(0,0,0,.05) !important;
        box-shadow: 0 1px 3px rgba(0,0,0,.04) !important;
    }
    .sc-folder:active {
        transform: scale(.98) !important;
    }

    /* ── Pinned spaces — subtle pin accent ────────────────────────── */
    .sc-view-item.sc-pinned {
        border-left: 3px solid #4F46E5 !important;
    }

    /* ── Quota banner — rounded on mobile ────────────────────────── */
    .sc-banner {
        border-radius: 14px !important;
    }

    /* ── Greeting card — rounded ─────────────────────────────────── */
    .sc-greeting {
        border-radius: 16px !important;
        overflow: hidden;
    }
}

/* ── Extra small phones (< 576px) — tighter dashboard ────────────── */
@media (max-width: 575.98px) {

    .sc-dash-mg-hello {
        font-size: 18px !important;
    }

    /* Space cards — stack better */
    .sc-view-item .sc-view-item-meta,
    .sc-view-item .sc-view-item-aside {
        display: none !important;   /* hide members count + tag on tiny screens */
    }

    /* Pin button smaller */
    .sc-pin-btn {
        width: 32px !important;
        height: 32px !important;
    }
}
