/* =====================================================================
   Providers page (#provider-commissions) — mobile makeover.
   Same pattern as Partners: stats grid pinned at top, search + funnel
   below, table replaced by cards. No FAB — providers are created
   via User Management, not on this page.
   ===================================================================== */

/* Desktop safety net */
#provider-commissions .pv-mobile-header,
#provider-commissions .pv-cards,
#provider-commissions .pv-fab { display: none; }

@media (max-width: 767px) {
    /* Kill the title + filter card, and the section title */
    #provider-commissions > .modern-content-card.u-mb-4,
    #provider-commissions > .modern-content-card .modern-section-header {
        display: none !important;
    }
    /* Flatten the wrapping content card */
    #provider-commissions > .modern-content-card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    /* Hide desktop table + empty state (empty state is inside the table container) */
    #provider-commissions .table-container,
    #provider-commissions #providersDataTable {
        display: none !important;
    }

    /* Stats grid at top — 2×2 tight grid */
    #provider-commissions .stats-grid#providerStatsGrid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
        padding: 0 4px !important;
    }
    /* Stat-card interior sizing/layout lives in shared css/stat-cards-mobile.css */

    /* Search + funnel bar (inline, sits below the stats grid) */
    #provider-commissions .pv-mobile-header {
        display: flex !important;
        gap: 8px;
        padding: 0 4px 12px;
        background: transparent;
        border-bottom: none;
    }
    #provider-commissions .pv-top-search-input {
        flex: 1;
        min-width: 0;
        height: 40px;
        padding: 0.55rem 0.75rem;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 0.9rem;
        background: #fff;
        color: #111827;
        outline: none;
    }
    #provider-commissions .pv-top-search-input:focus {
        border-color: #6366f1;
    }
    #provider-commissions .pv-filter-trigger {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        border: 1px solid #d1d5db;
        background: #fff;
        color: #4b5563;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        position: relative;
    }
    .pv-filter-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 8px;
        background: #ef4444;
        color: #fff;
        font-size: 0.6rem;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }
    .pv-filter-badge[hidden] { display: none; }

    /* Cards container — extra bottom padding to clear the FAB */
    #provider-commissions .pv-cards {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        padding: 0 4px 90px;
    }

    /* FAB — jumps to User Management */
    #provider-commissions .pv-fab {
        display: inline-flex !important;
        position: fixed;
        bottom: 90px;
        right: 16px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: #fff;
        border: 2px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 900;
    }
    #provider-commissions .pv-fab:active { transform: scale(0.95); }

    /* Individual card */
    .pv-card {
        position: relative;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 12px 44px 12px 20px;
        display: flex;
        flex-direction: column;
        gap: 4px;
        overflow: hidden;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }
    .pv-card .pv-strip {
        position: absolute;
        left: 0; top: 0; bottom: 0;
        width: 4px;
    }
    .pv-card .pv-more {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        border: none;
        background: transparent;
        color: #6b7280;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }
    .pv-card .pv-more:active { background: #f3f4f6; }
    .pv-card .pv-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }
    .pv-card .pv-name {
        font-size: 1rem;
        font-weight: 700;
        color: #111827;
    }
    .pv-card .pv-role {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: #6b7280;
        font-weight: 700;
    }
    .pv-card .pv-email {
        font-size: 0.8rem;
        color: #6b7280;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-bottom: 4px;
    }
    .pv-card .pv-meta {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }
    .pv-card .pv-chip {
        padding: 3px 10px;
        border-radius: 999px;
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }
    .pv-chip-comm { background: #fef3c7; color: #78350f; }
    .pv-chip-status.is-active   { background: #d1fae5; color: #065f46; }
    .pv-chip-status.is-inactive { background: #f3f4f6; color: #4b5563; }
    .pv-card .pv-stats {
        display: flex;
        gap: 8px;
        margin-top: 4px;
        padding-top: 8px;
        border-top: 1px solid #f3f4f6;
    }
    .pv-card .pv-stat {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }
    .pv-card .pv-stat-label {
        font-size: 0.6rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #9ca3af;
        font-weight: 600;
    }
    .pv-card .pv-stat-value {
        font-size: 0.85rem;
        font-weight: 700;
        color: #111827;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Filter drawer */
    .pv-drawer-wrap {
        position: fixed;
        inset: 0;
        z-index: 1050;
        pointer-events: none;
    }
    .pv-drawer-wrap.is-open { pointer-events: auto; }
    .pv-drawer-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        transition: background 0.22s;
    }
    .pv-drawer-wrap.is-open .pv-drawer-backdrop { background: rgba(0, 0, 0, 0.45); }
    .pv-drawer {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(85vw, 340px);
        background: #fff;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
        display: flex;
        flex-direction: column;
    }
    .pv-drawer-wrap.is-open .pv-drawer { transform: translateX(0); }
    .pv-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px 12px;
        border-bottom: 1px solid #f3f4f6;
    }
    .pv-drawer-title {
        font-size: 1.1rem;
        font-weight: 700;
        margin: 0;
        color: #111827;
    }
    .pv-drawer-close {
        background: transparent;
        border: none;
        font-size: 1.75rem;
        color: #6b7280;
        cursor: pointer;
        padding: 4px 8px;
        line-height: 1;
    }
    .pv-drawer-body {
        padding: 16px 20px;
        overflow-y: auto;
        flex: 1;
    }
    .pv-drawer-group { margin-bottom: 18px; }
    .pv-drawer-group-label {
        display: block;
        font-size: 0.8rem;
        font-weight: 600;
        color: #374151;
        margin-bottom: 6px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }
    .pv-drawer-pills {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .pv-drawer-pill {
        display: inline-flex;
        align-items: center;
        padding: 8px 14px;
        border-radius: 999px;
        border: 1.5px solid #e5e7eb;
        background: #fff;
        color: #4b5563;
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
    }
    .pv-drawer-pill.selected {
        background: #eef2ff;
        border-color: #6366f1;
        color: #4338ca;
    }
    .pv-drawer-footer {
        display: flex;
        gap: 8px;
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid #f3f4f6;
    }
    .pv-drawer-footer button {
        flex: 1;
        height: 42px;
        border-radius: 10px;
        font-weight: 600;
        font-size: 0.9rem;
        cursor: pointer;
    }
    .pv-clear-btn {
        background: #f3f4f6;
        color: #374151;
        border: 1px solid #e5e7eb;
    }
    .pv-close-btn {
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: #fff;
        border: none;
    }

    /* Bottom action sheet */
    .pv-sheet-wrap {
        position: fixed;
        inset: 0;
        z-index: 1100;
        pointer-events: none;
    }
    .pv-sheet-wrap.is-open { pointer-events: auto; }
    .pv-sheet-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        transition: background 0.2s;
    }
    .pv-sheet-wrap.is-open .pv-sheet-backdrop { background: rgba(0, 0, 0, 0.35); }
    .pv-sheet {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-radius: 20px 20px 0 0;
        padding: 0.5rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
        transform: translateY(100%);
        transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
    }
    .pv-sheet-wrap.is-open .pv-sheet { transform: translateY(0); }
    .pv-sheet-handle {
        width: 40px;
        height: 4px;
        background: #d1d5db;
        border-radius: 2px;
        margin: 8px auto 12px;
    }
    .pv-sheet-title {
        text-align: center;
        font-size: 0.85rem;
        color: #6b7280;
        margin-bottom: 8px;
        font-weight: 600;
    }
    .pv-sheet-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 8px;
        background: transparent;
        border: none;
        cursor: pointer;
        text-align: left;
        width: 100%;
    }
    .pv-sheet-item:active { background: #f3f4f6; }
    .pv-sheet-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    .pv-sheet-label {
        font-size: 0.95rem;
        font-weight: 600;
        color: #111827;
    }
    .pv-sheet-cancel {
        width: 100%;
        margin-top: 8px;
        padding: 12px;
        background: #f3f4f6;
        border: none;
        border-radius: 10px;
        font-size: 0.95rem;
        font-weight: 600;
        color: #374151;
        cursor: pointer;
    }
}
