/**
 * Size Matrix Frontend Styles
 *
 * @package SMatrix_Ordering
 * @since 1.0.0
 */

/* ==========================================================================
   Matrix Container
   ========================================================================== */

.smx-size-matrix {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.smx-matrix-wrapper {
    position: relative;
    overflow-x: auto;
}

.smx-matrix-title {
    margin: 0 0 15px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* ==========================================================================
   Matrix Layout - Grid
   ========================================================================== */

.smx-matrix-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.smx-matrix-grid .smx-matrix-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.smx-matrix-grid .smx-matrix-cell:hover:not(.smx-cell-disabled):not(.smx-cell-out-of-stock) {
    border-color: #333;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Matrix Layout - Table
   ========================================================================== */

.smx-matrix-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.smx-matrix-table th,
.smx-matrix-table td {
    padding: 12px;
    text-align: center;
    border: 1px solid #ddd;
}

.smx-matrix-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.smx-matrix-table .smx-matrix-cell {
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.smx-matrix-table .smx-matrix-cell:hover:not(.smx-cell-disabled):not(.smx-cell-out-of-stock) {
    background: #f9f9f9;
}

/* ==========================================================================
   Matrix Layout - List
   ========================================================================== */

.smx-matrix-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
}

.smx-matrix-list .smx-matrix-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.smx-matrix-list .smx-matrix-cell:hover:not(.smx-cell-disabled):not(.smx-cell-out-of-stock) {
    border-color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Matrix Cells - States
   ========================================================================== */

.smx-matrix-cell {
    position: relative;
}

.smx-matrix-cell.smx-cell-selected {
    background: #333 !important;
    color: #fff;
    border-color: #333 !important;
}

.smx-matrix-cell.smx-cell-disabled,
.smx-matrix-cell.smx-cell-out-of-stock {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.smx-matrix-cell.smx-cell-out-of-stock::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: #e74c3c;
    transform: translateY(-50%) rotate(-15deg);
}

/* ==========================================================================
   Cell Content
   ========================================================================== */

.smx-cell-label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
}

.smx-cell-price {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.smx-cell-selected .smx-cell-price {
    color: #fff;
}

/* ==========================================================================
   Stock Status
   ========================================================================== */

.smx-stock {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.smx-stock.smx-in-stock {
    background: #d4edda;
    color: #155724;
}

.smx-stock.smx-low-stock {
    background: #fff3cd;
    color: #856404;
}

.smx-stock.smx-out-of-stock {
    background: #f8d7da;
    color: #721c24;
}

.smx-stock.smx-backorder {
    background: #d1ecf1;
    color: #0c5460;
}

/* ==========================================================================
   Quantity Input
   ========================================================================== */

.smx-quantity-input {
    width: 60px;
    padding: 5px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

.smx-cell-selected .smx-quantity-input {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* ==========================================================================
   Color Swatches
   ========================================================================== */

.smx-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.smx-swatch {
    position: relative;
    width: 40px;
    height: 40px;
    border: 2px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
}

.smx-swatch:hover {
    transform: scale(1.1);
    border-color: #333;
}

.smx-swatch.selected {
    border-color: #333;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
}

.smx-swatch-inner {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.smx-add-to-cart-btn {
    display: inline-block;
    padding: 12px 24px;
    background: #333;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.smx-add-to-cart-btn:hover:not(:disabled) {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.smx-add-to-cart-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   Actions Bar
   ========================================================================== */

.smx-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.smx-stock-info {
    flex: 1;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.smx-loading {
    position: relative;
    pointer-events: none;
}

.smx-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media screen and (max-width: 768px) {
    .smx-matrix-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }

    .smx-matrix-grid .smx-matrix-cell {
        padding: 8px;
        font-size: 14px;
    }

    .smx-matrix-table {
        font-size: 14px;
    }

    .smx-matrix-table th,
    .smx-matrix-table td {
        padding: 8px;
    }

    .smx-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .smx-add-to-cart-btn {
        width: 100%;
    }
}

@media screen and (max-width: 480px) {
    .smx-size-matrix {
        padding: 15px;
    }

    .smx-matrix-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 5px;
    }

    .smx-matrix-grid .smx-matrix-cell {
        padding: 5px;
        font-size: 12px;
    }

    .smx-color-swatches {
        gap: 8px;
    }

    .smx-swatch {
        width: 35px;
        height: 35px;
    }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.smx-hidden {
    display: none !important;
}

.smx-text-center {
    text-align: center;
}

.smx-text-right {
    text-align: right;
}

.smx-mt-10 {
    margin-top: 10px;
}

.smx-mb-10 {
    margin-bottom: 10px;
}

.smx-clearfix::after {
    content: '';
    display: table;
    clear: both;
}