/* --- SCOPED CSS FOR PRODUCT-WISE STOCK AVAILABILITY --- */
.psa-wrapper {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    margin-bottom: 32px;
}

/* ── Page Header ── */
.psa-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.psa-title-block h1 {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px 0;
}

.psa-title-block p {
    font-size: 13px;
    color: #6B7280;
    margin: 0;
}

.psa-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Buttons ── */
.psa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.psa-btn-outline, .psa-btn-ghost {
    background-color: #FFFFFF;
    border-color: #E5E7EB;
    color: #4B5563;
}

    .psa-btn-outline:hover, .psa-btn-ghost:hover {
        background-color: #F9FAFB;
        color: #1F2937;
    }

.psa-btn-primary {
    background-color: #2563EB;
    color: #FFFFFF;
    border-color: #2563EB;
}

    .psa-btn-primary:hover {
        background-color: #1D4ED8;
        border-color: #1D4ED8;
    }

/* ── KPI Cards ── */
.psa-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.psa-kpi-card {
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid #E5E7EB;
    border-left-width: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
    min-width: 0;
    min-height: 110px;
}

/* KPI variants — gradient background + colored left border */
.psa-kpi-green {
    border-left-color: #22C55E;
    background: linear-gradient(135deg, #F0FDF4 0%, #FFFFFF 75%);
}

.psa-kpi-purple {
    border-left-color: #A855F7;
    background: linear-gradient(135deg, #FAF5FF 0%, #FFFFFF 75%);
}

.psa-kpi-blue {
    border-left-color: #3B82F6;
    background: linear-gradient(135deg, #EFF6FF 0%, #FFFFFF 75%);
}

.psa-kpi-lime {
    border-left-color: #84CC16;
    background: linear-gradient(135deg, #F7FEE7 0%, #FFFFFF 75%);
}

.psa-kpi-red {
    border-left-color: #EF4444;
    background: linear-gradient(135deg, #FEF2F2 0%, #FFFFFF 75%);
}

.psa-kpi-content {
    min-width: 0;
    flex: 1;
}

.psa-kpi-label {
    font-size: 12px;
    color: #6B7280;
    font-weight: 500;
    margin-bottom: 6px;
}

.psa-kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    line-height: 1.1;
    margin-bottom: 4px;
    word-break: break-word;
}

.psa-kpi-value-sm {
    font-size: 19px;
}

.psa-kpi-sub {
    font-size: 11px;
    color: #6B7280;
    font-weight: 500;
}

.psa-kpi-green .psa-kpi-sub {
    color: #15803D;
}

.psa-kpi-purple .psa-kpi-sub {
    color: #9333EA;
}

.psa-kpi-blue .psa-kpi-sub {
    color: #2563EB;
}

.psa-kpi-lime .psa-kpi-sub {
    color: #65A30D;
}

.psa-kpi-red .psa-kpi-sub {
    color: #DC2626;
}

.psa-kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    border: 1px solid transparent;
}

.psa-icon-green {
    background-color: #DCFCE7;
    color: #16A34A;
    border-color: #BBF7D0;
}

.psa-icon-purple {
    background-color: #F3E8FF;
    color: #9333EA;
    border-color: #E9D5FF;
}

.psa-icon-blue {
    background-color: #DBEAFE;
    color: #2563EB;
    border-color: #BFDBFE;
}

.psa-icon-lime {
    background-color: #ECFCCB;
    color: #65A30D;
    border-color: #D9F99D;
}

.psa-icon-red {
    background-color: #FEE2E2;
    color: #DC2626;
    border-color: #FECACA;
}

/* ── Generic Card ── */
.psa-card {
    background-color: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* ── Filters Header  ── */
.psa-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: #1F2937;
    background-color: #EBEEEA;
    padding: 14px 20px;
    margin: -18px -20px 18px -20px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    border-bottom: 1px solid #E5E7EB;
}

    .psa-filters-header > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

        .psa-filters-header > span i {
            font-size: 16px;
            color: #6B7280;
        }

.psa-toggle-icon {
    color: #6B7280;
    cursor: pointer;
    font-size: 14px;
}

/* ── Filter Grid ── */
.psa-filters-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.psa-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

    .psa-form-group > label {
        font-size: 12px;
        font-weight: 600;
        color: #374151;
    }

.psa-filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

/* ── Form Controls ── */
.psa-control {
    appearance: none;
    background-color: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    color: #374151;
    font-family: inherit;
    outline: none;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}

    .psa-control::placeholder {
        color: #9CA3AF;
    }

    .psa-control:focus {
        border-color: #3B82F6;
        background-color: #FFFFFF;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

.psa-input-with-icon {
    position: relative;
}

    .psa-input-with-icon .psa-control {
        padding-right: 32px;
    }

.psa-input-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    pointer-events: none;
    font-size: 14px;
}

.psa-select {
    padding-right: 32px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* ── Table Head ── */
.psa-table-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 14px;
}

.psa-table-title {
    font-size: 15px;
    font-weight: 700;
    color: #1F2937;
    margin: 0;
}

.psa-search {
    position: relative;
    width: 240px;
}

    .psa-search i {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: #9CA3AF;
        font-size: 13px;
    }

    .psa-search input {
        width: 100%;
        background-color: #F9FAFB;
        border: 1px solid #E5E7EB;
        border-radius: 6px;
        padding: 8px 12px 8px 32px;
        font-size: 12px;
        color: #374151;
        outline: none;
    }

        .psa-search input::placeholder {
            color: #9CA3AF;
        }

        .psa-search input:focus {
            border-color: #3B82F6;
            background-color: #FFFFFF;
        }

/* ── Table ── */
.psa-table-wrap {
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.psa-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

    .psa-table thead th {
        font-size: 12px;
        font-weight: 700;
        padding: 12px 10px;
        text-align: center;
        border-bottom: 1px solid #E5E7EB;
        white-space: nowrap;
    }

.psa-thead-group th {
    font-size: 13px;
}

.psa-th-state {
    background-color: #F2F3F3;
    color: #374151;
    text-align: center !important;
    width: 16%;
}

.psa-th-group-green {
    background-color: #ECFDF5 !important;
    color: #047857;
}

.psa-th-group-blue {
    background-color: #EFF6FF !important;
    color: #1D4ED8;
}

.psa-th-group-pink {
    background-color: #FDF4FF;
}

.psa-table thead tr:nth-child(2) th {
    background-color: #F2F3F3;
    color: #6B7280;
    font-weight: 600;
    font-size: 11px;
}

.psa-table tbody td {
    font-size: 13px;
    color: #1F2937;
    padding: 14px 10px;
    text-align: center;
    border-bottom: 1px solid #F3F4F6;
}

.psa-state-cell {
    text-align: left !important;
    font-weight: 500;
    color: #374151 !important;
    padding-left: 18px !important;
}

.psa-table tbody tr:last-child td {
    border-bottom: none;
}

.psa-table tbody tr:not(.psa-grand-total):hover {
    background-color: #FAFAFA;
}

.psa-cell-divider {
    border-right: 1px solid #E5E7EB;
}

.psa-table thead tr:first-child th:first-child {
    border-right: 1px solid #E5E7EB;
}

.psa-table thead tr:first-child th:nth-child(2),
.psa-table thead tr:first-child th:nth-child(3) {
    border-right: 1px solid #E5E7EB;
}

/* Grand Total Row */
.psa-grand-total td {
    background-color: #F5F9F6 !important;
    color: #15803D !important;
    font-weight: 700;
    border-bottom: none;
}

.psa-grand-total .psa-state-cell {
    color: #15803D !important;
}

/* ── Pagination ── */
.psa-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.psa-page-size {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6B7280;
}

.psa-page-select {
    width: 70px;
    padding: 6px 26px 6px 10px;
    font-size: 12px;
}

.psa-page-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.psa-page-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    background-color: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    font-size: 12px;
    color: #4B5563;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

    .psa-page-btn:hover {
        background-color: #F9FAFB;
    }

.psa-page-active {
    border-color: #2563EB;
    color: #2563EB;
    font-weight: 700;
}

.psa-page-ellipsis {
    color: #9CA3AF;
    padding: 0 4px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 1280px) {
    .psa-kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .psa-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .psa-filters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .psa-actions {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .psa-page-header {
        flex-direction: column;
    }

    .psa-title-block h1 {
        font-size: 17px;
    }

    .psa-actions .psa-btn {
        flex: 1;
        min-width: 110px;
    }

    .psa-filters-grid {
        grid-template-columns: 1fr;
    }

    .psa-card {
        padding: 14px;
    }

    .psa-filters-header {
        margin: -14px -14px 14px -14px;
        padding: 12px 16px;
    }

    .psa-table-head {
        flex-direction: column;
        align-items: stretch;
    }

    .psa-search {
        width: 100%;
    }

    .psa-filter-actions {
        flex-direction: column-reverse;
    }

        .psa-filter-actions .psa-btn {
            width: 100%;
        }

    .psa-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .psa-page-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .psa-kpi-grid {
        grid-template-columns: 1fr;
    }

    .psa-kpi-value {
        font-size: 22px;
    }
}
