/* ============================================================
   UNF B2B Stock Matrix — CSS
   ============================================================ */

/* ---- Trigger Button ---------------------------------------- */
.unf-stock-matrix-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 7px 14px;
    background: #fff;
    color: #333;
    border: 1.5px solid #28462F;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    width: 100%;
    justify-content: center;
    line-height: 1.4;
    font-family: "Noto Sans Armenian", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.unf-stock-matrix-btn:hover {
background:#28462F;
    color: #fff;
}

.unf-stock-matrix-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.unf-stock-matrix-btn--single {
    width: auto;
    padding: 10px 20px;
    font-size: 13px;
}

.unf-stock-matrix-single-wrap {
    margin: 10px 0;
}

/* ---- Overlay / Backdrop ------------------------------------ */
.unf-sm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.unf-sm-overlay.unf-sm-open {
    display: flex;
}

/* Prevent body scroll when modal is open */
body.unf-sm-body-lock {
    overflow: hidden;
}

/* ---- Modal Box --------------------------------------------- */
.unf-sm-wrap {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 900px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: unfSmSlideIn 0.25s ease;
}

@keyframes unfSmSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* ---- Modal Header ------------------------------------------ */
.unf-sm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.unf-sm-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    font-family: "Noto Sans Armenian", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.unf-sm-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.unf-sm-close:hover {
    color: #B30A08;
    background: #fff0f0;
}

/* ---- Modal Body -------------------------------------------- */
.unf-sm-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}

/* ---- Loader ------------------------------------------------ */
.unf-sm-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 50px 20px;
    color: #666;
    font-size: 14px;
}

.unf-sm-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #B30A08;
    border-radius: 50%;
    animation: unfSmSpin 0.75s linear infinite;
}

@keyframes unfSmSpin {
    to { transform: rotate(360deg); }
}

/* ---- Error ------------------------------------------------- */
.unf-sm-error {
    text-align: center;
    color: #B30A08;
    padding: 30px 20px;
    font-size: 14px;
}

/* ---- Table Wrapper (horizontal scroll on mobile) ----------- */
.unf-sm-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
}

/* ---- Matrix Table ------------------------------------------ */
.unf-sm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 400px;
    font-family: "Noto Sans Armenian", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.unf-sm-table thead th {
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    padding: 10px 14px;
    font-weight: 700;
    text-align: center;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.unf-sm-th-color {
    text-align: left !important;
    min-width: 120px;
    width: 130px;
}

.unf-sm-table tbody tr {
    transition: background 0.1s;
}

.unf-sm-table tbody tr:hover {
    background: #fafafa;
}

.unf-sm-table tbody td {
    border: 1px solid #e8e8e8;
    padding: 8px 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    vertical-align: middle;
    white-space: nowrap;
}

/* ---- Color Cell (first column) ----------------------------- */
.unf-sm-td-color {
    text-align: left !important;
    padding: 6px 10px !important;
    background: #fafafa;
    border-right: 2px solid #e0e0e0 !important;
}

.unf-sm-color-img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #ddd;
    display: block;
    flex-shrink: 0;
}

.unf-sm-td-color {
    display: table-cell; /* override for flex below */
}

/* We need flex inside the td — use a wrapper span */
.unf-sm-table tbody .unf-sm-td-color {
    vertical-align: middle;
}

/* Wrap image + name together */
.unf-sm-td-color img,
.unf-sm-td-color .unf-sm-color-name {
    display: block;
}

.unf-sm-color-name {
    font-size: 10px;
    color: #777;
    margin-top: 3px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
}

/* ---- Stock Cell States ------------------------------------- */
.unf-sm-table td.unf-sm-instock {
    color: #2e7d32;
    background: #f1f9f1;
    font-weight: 700;
}

.unf-sm-table td.unf-sm-zero {
    color: #c62828;
    background: #fff5f5;
    font-weight: 600;
}

.unf-sm-table td.unf-sm-infinite {
    color: #1565c0;
    background: #f0f4ff;
    font-size: 15px;
    font-weight: 700;
}

/* ---- Mobile adjustments ------------------------------------ */
@media (max-width: 600px) {
    .unf-sm-wrap {
        border-radius: 10px;
        max-height: calc(100vh - 20px);
    }

    .unf-sm-header {
        padding: 12px 16px;
    }

    .unf-sm-title {
        font-size: 14px;
    }

    .unf-sm-table-wrap {
        padding: 10px;
    }

    .unf-sm-table td,
    .unf-sm-table th {
        padding: 6px 8px;
        font-size: 11px;
    }

    .unf-sm-color-img {
        width: 36px;
        height: 36px;
    }

    .unf-sm-color-name {
        font-size: 9px;
        max-width: 80px;
    }

    .unf-stock-matrix-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
}
