/* Multi Warehouse – Frontend Styles */

/* Zabezpečí že WooCommerce form umožní zalomenie */
form.cart {
    flex-wrap: wrap !important;
}

.mwh-warehouse-selector {
    margin: 15px 0 20px;
    padding: 0;
    /* Zabezpečí plnú šírku v flex kontajneri (WooCommerce form) */
    width: 100%;
    flex-basis: 100%;
    flex-shrink: 0;
    order: -1; /* Posunie selektor na začiatok */
}

.mwh-warehouse-selector > label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
}

.mwh-warehouse-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mwh-warehouse-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.mwh-warehouse-option:hover:not(.mwh-out-of-stock) {
    border-color: #999;
    background: #fafafa;
}

.mwh-warehouse-option.mwh-selected {
    border-color: #2196f3;
    background: #e3f2fd;
}

.mwh-warehouse-option.mwh-out-of-stock {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.mwh-option-radio {
    flex-shrink: 0;
}

.mwh-option-radio input[type="radio"] {
    margin: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.mwh-option-details {
    flex: 1;
    min-width: 0;
}

.mwh-option-name label {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    display: block;
}

.mwh-option-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* WooCommerce stock štýly v rámci selektora */
.mwh-option-meta .stock {
    font-weight: 500;
    margin: 0;
    padding: 0;
    font-size: inherit;
}

.mwh-option-meta .stock.in-stock {
    color: #7ad03a;
}

.mwh-option-meta .stock.out-of-stock {
    color: #a44;
}

.mwh-option-meta .stock.low-stock {
    color: #e65100;
}

.mwh-delivery {
    color: #666;
}

.mwh-option-price {
    flex-shrink: 0;
    text-align: right;
    font-size: 16px;
}

.mwh-option-price strong {
    color: #333;
}

.mwh-option-price del {
    display: block;
    font-size: 12px;
    color: #999;
    font-weight: normal;
}

/* Price range na archive/listing */
.mwh-price-range {
    font-size: inherit;
}

/* =============================================
   Auto-alokácia sumár
   ============================================= */

.mwh-allocation-summary {
    margin: 15px 0 20px;
    padding: 0;
    width: 100%;
    flex-basis: 100%;
    flex-shrink: 0;
    order: -1;
    transition: opacity 0.2s ease;
}

.mwh-allocation-summary > label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
}

.mwh-allocation-loading {
    opacity: 0.5;
    pointer-events: none;
}

.mwh-allocation-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    margin-bottom: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.mwh-allocation-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.mwh-allocation-table th:last-child,
.mwh-allocation-table td:last-child {
    text-align: right;
}

.mwh-allocation-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    color: #374151;
}

.mwh-allocation-row:hover td {
    background: #f9fafb;
}

.mwh-allocation-row td:first-child {
    font-weight: 500;
}

.mwh-allocation-total td {
    font-weight: 700;
    color: #111827;
    background: #f9fafb;
    border-bottom: none;
    border-top: 2px solid #e5e7eb;
}

.mwh-allocation-delivery {
    font-size: 13px;
    color: #1e40af;
    margin-top: 10px;
    padding: 10px 14px;
    background: #eff6ff;
    border-radius: 8px;
    border: 1px solid #bfdbfe;
}

.mwh-allocation-warning {
    font-size: 13px;
    color: #9a3412;
    margin-top: 10px;
    padding: 10px 14px;
    background: #fff7ed;
    border-radius: 8px;
    border: 1px solid #fed7aa;
    font-weight: 500;
}

/* =============================================
   Warehouse Table mód (CSS Grid)
   ============================================= */

.mwh-warehouse-table-wrap {
    margin: 10px 0 15px;
    padding: 0;
    width: 100%;
    flex-basis: 100%;
    flex-shrink: 0;
    order: -1;
}

.mwh-warehouse-table {
    display: grid;
    grid-template-columns: auto auto auto auto;
    align-items: center;
    column-gap: 10px;
    width: 100%;
    font-size: 13px;
}

.mwh-wt-header,
.mwh-wt-row {
    display: contents;
}

/* Header */
.mwh-wt-header > div {
    padding: 0 0 6px;
    white-space: nowrap;
}

/* Row cells */
.mwh-wt-row > div {
    padding: 7px 0;
    border-bottom: 1px solid #f3f4f6;
}

.mwh-wt-row:last-child > div {
    border-bottom: none;
}


.mwh-wt-cart-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mwh-wt-row.mwh-out-of-stock > div {
    opacity: 0.4;
}

/* Quantity input with +/- buttons */
.mwh-warehouse-table .mwh-wt-qty-wrap {
    display: inline-flex !important;
    align-items: center;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    overflow: hidden;
}

.mwh-warehouse-table button.mwh-wt-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px !important;
    height: 28px !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: #f9fafb !important;
    color: #374151 !important;
    font-size: 15px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.mwh-warehouse-table button.mwh-wt-qty-btn:hover:not(:disabled) {
    background: #e5e7eb !important;
}

.mwh-warehouse-table button.mwh-wt-qty-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mwh-warehouse-table input[type="number"].mwh-wt-qty {
    width: 38px !important;
    height: 28px !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-left: 1px solid #d1d5db !important;
    border-right: 1px solid #d1d5db !important;
    border-radius: 0 !important;
    font-size: 13px !important;
    text-align: center;
    -moz-appearance: textfield;
    box-shadow: none !important;
    background: #fff !important;
}

.mwh-warehouse-table input[type="number"].mwh-wt-qty:focus {
    outline: none;
    box-shadow: none !important;
}

.mwh-warehouse-table input[type="number"].mwh-wt-qty::-webkit-inner-spin-button,
.mwh-warehouse-table input[type="number"].mwh-wt-qty::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mwh-warehouse-table input[type="number"].mwh-wt-qty:disabled {
    background: #f9fafb !important;
    cursor: not-allowed;
}

/* Add-to-cart button */
.mwh-warehouse-table button.mwh-wt-add-to-cart {
    white-space: nowrap;
    padding: 4px 12px !important;
    font-size: 12px !important;
    line-height: 1.5 !important;
    border-radius: 4px !important;
    cursor: pointer;
    position: relative;
    min-width: 80px;
    min-height: 0 !important;
    height: auto !important;
    transition: opacity 0.2s ease;
}

.mwh-warehouse-table button.mwh-wt-add-to-cart:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.mwh-warehouse-table button.mwh-wt-add-to-cart.loading {
    color: transparent !important;
    pointer-events: none;
}

.mwh-wt-add-to-cart.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid #999;
    border-top-color: transparent;
    border-radius: 50%;
    animation: mwh-spin 0.6s linear infinite;
}

@keyframes mwh-spin {
    to { transform: rotate(360deg); }
}

/* Notice */
.mwh-wt-notice {
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 8px;
}

.mwh-wt-notice-success {
    color: #065f46;
    background: #ecfdf5;
}

.mwh-wt-notice-error {
    color: #9a3412;
    background: #fff7ed;
}

/* Skryť WC default quantity+button keď je warehouse table mód */
.mwh-warehouse-table-wrap ~ .quantity,
.mwh-warehouse-table-wrap ~ .single_add_to_cart_button {
    display: none !important;
}

/* Stock štýly */
.mwh-warehouse-table .stock,
.mwh-wt-row .stock {
    font-weight: 500;
    margin: 0;
    padding: 0;
    font-size: inherit;
}

.mwh-warehouse-table .stock.in-stock {
    color: #16a34a;
}

.mwh-warehouse-table .stock.out-of-stock {
    color: #a44;
}

.mwh-warehouse-table .stock.low-stock {
    color: #ea580c;
}

/* Responsive */
@media (max-width: 480px) {
    .mwh-warehouse-option {
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    .mwh-option-price {
        width: 100%;
        text-align: left;
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px solid #eee;
    }

    .mwh-allocation-table {
        font-size: 13px;
    }

    .mwh-allocation-table th,
    .mwh-allocation-table td {
        padding: 8px 8px;
    }

    .mwh-allocation-table th:nth-child(3),
    .mwh-allocation-table td:nth-child(3) {
        display: none;
    }

    /* Warehouse table – responsive */
    .mwh-warehouse-table {
        display: block;
    }

    .mwh-wt-header {
        display: none;
    }

    .mwh-wt-row {
        display: flex;
        flex-wrap: wrap;
        gap: 2px 0;
        padding: 10px 0;
    }

    .mwh-wt-row:not(:last-child) {
        border-bottom: 1px solid #f3f4f6;
    }

    .mwh-wt-row > div {
        padding: 2px 0;
        border-bottom: none !important;
    }

    .mwh-wt-row > div[data-label]::before {
        content: attr(data-label);
        display: inline-block;
        font-weight: 500;
        font-size: 11px;
        color: #9ca3af;
        text-transform: uppercase;
        margin-right: 8px;
        min-width: 75px;
    }

    .mwh-wt-col-price,
    .mwh-wt-col-stock,
    .mwh-wt-col-delivery,
    .mwh-wt-col-cart {
        width: 100%;
    }

    .mwh-wt-cart-wrap {
        flex-wrap: wrap;
    }

    .mwh-warehouse-table-wrap button.mwh-wt-add-to-cart {
        flex: 1;
    }
}
