/**
 * Bulk Order Matrix Styles
 *
 * @package PrintShopStudio
 */

/* Order Mode Toggle */
.pss-order-mode-toggle {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.pss-toggle-buttons {
    display: flex;
    gap: 10px;
}

.pss-mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: 2px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.pss-mode-btn:hover {
    border-color: #2271b1;
    color: #2271b1;
}

.pss-mode-btn.active {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.pss-mode-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.pss-mode-description {
    margin-top: 10px;
    color: #666;
    font-size: 13px;
}

/* Matrix Container */
.pss-bulk-order-matrix {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e2e4e7;
}

.pss-matrix-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pss-matrix-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1d2327;
}

.pss-volume-hint {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #00a32a;
    font-size: 13px;
    font-weight: 500;
}

/* Colour Selector */
.pss-matrix-colour-selector {
    margin-bottom: 20px;
}

.pss-matrix-colour-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
}

.pss-matrix-colours {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pss-matrix-colour-btn {
    padding: 4px;
    border: 2px solid transparent;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pss-matrix-colour-btn:hover,
.pss-matrix-colour-btn.active {
    border-color: #2271b1;
}

.pss-matrix-colour-btn.active {
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.3);
}

.pss-colour-label {
    display: block;
    padding: 8px 12px;
    background: #fff;
    border-radius: 4px;
    font-size: 12px;
}

/* Matrix Table */
.pss-matrix-table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

.pss-matrix-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.pss-matrix-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.pss-matrix-table th {
    background: #1d2327;
    color: #fff;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.pss-matrix-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.pss-matrix-table tbody tr:last-child td {
    border-bottom: none;
}

.pss-matrix-table tbody tr:hover {
    background: #f8f9fa;
}

.pss-matrix-table tbody tr.out-of-stock {
    opacity: 0.5;
    background: #f9f9f9;
}

.pss-matrix-table tbody tr.out-of-stock .pss-qty-input-wrapper {
    display: none;
}

.pss-matrix-table tbody tr.has-qty {
    background: #e8f5e9;
}

.pss-matrix-table tbody.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Size Cell */
.pss-size-cell {
    font-weight: 600;
}

.pss-size-name {
    display: block;
}

.pss-size-group {
    display: block;
    font-size: 11px;
    color: #666;
    font-weight: normal;
}

/* Price Cell */
.pss-price-cell {
    font-weight: 500;
    color: #2271b1;
}

/* Stock Cell */
.pss-in-stock {
    color: #00a32a;
    font-size: 12px;
}

.pss-low-stock {
    color: #dba617;
    font-size: 12px;
}

.pss-out-of-stock {
    color: #d63638;
    font-size: 12px;
}

/* Quantity Cell */
.pss-qty-cell {
    width: 140px;
}

.pss-qty-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.pss-qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pss-qty-btn:hover {
    background: #2271b1;
    color: #fff;
}

.pss-qty-btn:active {
    transform: scale(0.95);
}

.pss-matrix-qty {
    width: 50px;
    padding: 8px;
    border: none;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    -moz-appearance: textfield;
}

.pss-matrix-qty::-webkit-outer-spin-button,
.pss-matrix-qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pss-matrix-qty:focus {
    outline: none;
    background: #f0f6fc;
}

/* Subtotal Cell */
.pss-subtotal-cell {
    font-weight: 600;
    color: #1d2327;
}

/* Notify Link */
.pss-notify-link a {
    color: #2271b1;
    text-decoration: none;
    font-size: 12px;
}

.pss-notify-link a:hover {
    text-decoration: underline;
}

/* Totals */
.pss-matrix-totals td {
    background: #f0f0f0;
    padding: 15px;
}

.pss-total-items,
.pss-total-price {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pss-total-qty {
    font-size: 18px;
    font-weight: 700;
    color: #2271b1;
}

.pss-grand-total {
    font-size: 20px;
    font-weight: 700;
    color: #00a32a;
}

/* Discount Row */
.pss-discount-row td {
    background: #e8f5e9;
    padding: 10px 15px;
}

.pss-discount-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #00a32a;
    font-weight: 500;
}

.pss-discount-info .dashicons {
    font-size: 16px;
}

/* Volume Discount Preview */
.pss-volume-discount-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 15px;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e2e4e7;
}

.pss-volume-discount-preview.has-discount {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-color: #4caf50;
}

.pss-current-tier,
.pss-savings-display {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pss-tier-label,
.pss-savings-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pss-tier-value {
    font-size: 24px;
    font-weight: 700;
    color: #2271b1;
}

.pss-savings-value {
    font-size: 24px;
    font-weight: 700;
    color: #00a32a;
}

.pss-next-tier-hint {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #fff3cd;
    border-radius: 6px;
    color: #856404;
    font-size: 13px;
}

.pss-next-tier-hint .dashicons {
    color: #ffc107;
}

.pss-tier-progress {
    grid-column: 1 / -1;
}

.pss-tier-progress-bar {
    height: 8px;
    background: #e2e4e7;
    border-radius: 4px;
    overflow: hidden;
}

.pss-tier-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2271b1 0%, #00a32a 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Validation Warning */
.pss-bulk-validation-warning {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    margin-bottom: 15px;
    color: #856404;
}

.pss-bulk-validation-warning .dashicons {
    font-size: 20px;
}

.pss-bulk-validation-warning.shake {
    animation: pss-shake 0.5s ease-in-out;
}

@keyframes pss-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Actions */
.pss-matrix-actions {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pss-matrix-actions-left,
.pss-matrix-actions-right {
    display: flex;
    gap: 10px;
}

.pss-clear-matrix,
.pss-fill-equally {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #666;
}

.pss-clear-matrix .dashicons,
.pss-fill-equally .dashicons {
    font-size: 16px;
}

.pss-bulk-add-to-cart {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
}

.pss-bulk-add-to-cart .dashicons {
    font-size: 18px;
}

.pss-bulk-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading State */
.pss-bulk-order-matrix.loading {
    position: relative;
    pointer-events: none;
}

.pss-bulk-order-matrix.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pss-spin {
    animation: pss-rotate 1s linear infinite;
}

@keyframes pss-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Success Message */
.pss-bulk-success {
    position: fixed;
    top: 100px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #00a32a;
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    animation: pss-slide-in 0.3s ease-out;
}

.pss-bulk-success .dashicons {
    font-size: 24px;
}

.pss-bulk-success a {
    color: #fff;
    font-weight: 600;
    margin-left: 10px;
}

@keyframes pss-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Notify Modal */
.pss-notify-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.pss-notify-modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    position: relative;
}

.pss-notify-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.pss-notify-modal h3 {
    margin: 0 0 10px;
}

.pss-notify-modal p {
    color: #666;
    margin-bottom: 20px;
}

.pss-notify-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pss-notify-form input[type="email"] {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.pss-notify-form button {
    padding: 12px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .pss-toggle-buttons {
        flex-direction: column;
    }

    .pss-mode-btn {
        justify-content: center;
    }

    .pss-matrix-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .pss-matrix-table th,
    .pss-matrix-table td {
        padding: 10px;
        font-size: 13px;
    }

    .pss-stock-header,
    .pss-stock-cell {
        display: none;
    }

    /* Mobile: Show +/- buttons larger */
    .pss-qty-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .pss-matrix-qty {
        width: 44px;
        padding: 10px 5px;
    }

    .pss-volume-discount-preview {
        grid-template-columns: 1fr;
    }

    .pss-matrix-actions {
        flex-direction: column;
    }

    .pss-matrix-actions-left,
    .pss-matrix-actions-right {
        width: 100%;
    }

    .pss-matrix-actions button {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .pss-bulk-order-matrix {
        padding: 15px;
        margin: 15px -15px;
        border-radius: 0;
    }

    .pss-price-header,
    .pss-price-cell {
        display: none;
    }

    /* Mobile List View */
    .pss-matrix-table,
    .pss-matrix-table thead,
    .pss-matrix-table tbody,
    .pss-matrix-table th,
    .pss-matrix-table td,
    .pss-matrix-table tr {
        display: block;
    }

    .pss-matrix-table thead {
        display: none;
    }

    .pss-matrix-row {
        padding: 15px;
        margin-bottom: 10px;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }

    .pss-matrix-row td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }

    .pss-matrix-row td:last-child {
        border-bottom: none;
    }

    .pss-matrix-row td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
        font-size: 12px;
    }

    .pss-size-cell {
        font-size: 16px;
    }

    .pss-qty-cell {
        width: 100%;
        justify-content: center !important;
    }

    .pss-qty-input-wrapper {
        width: 100%;
        max-width: 200px;
    }

    .pss-subtotal-cell {
        font-size: 16px;
        color: #00a32a;
    }

    /* Mobile totals */
    .pss-matrix-totals td {
        display: block;
        text-align: center;
    }

    .pss-total-items,
    .pss-total-price {
        justify-content: center;
        margin: 10px 0;
    }
}
