/* ── WC Quote Request — Frontend Styles ───────────────────────────────────── */

/* ── Variables ─────────────────────────────────────────────────────────────── */
.wcqr-app {
    --wcqr-primary:      #2271b1;
    --wcqr-primary-dark: #135e96;
    --wcqr-secondary:    #50575e;
    --wcqr-border:       #dcdcde;
    --wcqr-bg:           #ffffff;
    --wcqr-bg-alt:       #f6f7f7;
    --wcqr-row-hover:    #f0f6fc;
    --wcqr-row-selected: #eaf3fc;
    --wcqr-disc-color:   #c0392b;
    --wcqr-radius:       6px;
    --wcqr-font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-family: var(--wcqr-font);
    font-size: 14px;
    direction: rtl;
    text-align: right;
}

/* ── Category Tab Bar ──────────────────────────────────────────────────────── */
.wcqr-cat-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0 16px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--wcqr-border);
    margin-bottom: 20px;
}

.wcqr-cat-label {
    font-weight: 600;
    color: var(--wcqr-secondary);
    font-size: 14px;
    white-space: nowrap;
}

.wcqr-cat-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.wcqr-cat-tab {
    padding: 6px 16px;
    border: 1.5px solid var(--wcqr-border);
    border-radius: 20px;
    background: var(--wcqr-bg);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--wcqr-font);
    color: var(--wcqr-secondary);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.wcqr-cat-tab:hover {
    border-color: var(--wcqr-primary);
    color: var(--wcqr-primary);
    background: var(--wcqr-row-hover);
}

.wcqr-cat-tab.active {
    background: var(--wcqr-primary);
    border-color: var(--wcqr-primary);
    color: #fff;
    font-weight: 600;
}

/* ── Table Wrapper ─────────────────────────────────────────────────────────── */
.wcqr-products-wrap,
.wcqr-quote-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--wcqr-border);
    border-radius: var(--wcqr-radius);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    background: var(--wcqr-bg);
    margin-bottom: 20px;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.wcqr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

.wcqr-table thead tr {
    background: var(--wcqr-bg-alt);
    border-bottom: 2px solid var(--wcqr-border);
}

.wcqr-table th {
    padding: 11px 12px;
    font-weight: 600;
    color: var(--wcqr-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
}

.wcqr-table td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--wcqr-border);
    color: #1e1e1e;
    font-size: 14px;
    overflow: hidden;
}

.wcqr-table tbody tr:last-child td {
    border-bottom: none;
}

.wcqr-table tbody tr:hover {
    background: var(--wcqr-row-hover);
}

.wcqr-product-row.wcqr-row-selected {
    background: var(--wcqr-row-selected);
}

/* ── Column widths — balanced layout ──────────────────────────────────────── */
.wcqr-col-image  { width: 72px;  text-align: center; }
.wcqr-col-name   { width: auto;  min-width: 160px; }
.wcqr-col-sku    { width: 100px; }
.wcqr-col-price  { width: 100px; text-align: center; white-space: nowrap; }
.wcqr-col-qty    { width: 80px;  text-align: center; }
.wcqr-col-disc   { width: 110px; text-align: center; white-space: nowrap; }
.wcqr-col-total  { width: 100px; text-align: center; white-space: nowrap; font-weight: 600; }

/* ── Thumbnail ─────────────────────────────────────────────────────────────── */
.wcqr-col-image img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--wcqr-border);
    display: block;
    margin: 0 auto;
}

/* ── Product name ──────────────────────────────────────────────────────────── */
.wcqr-col-name a {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
    display: block;
    word-break: break-word;
}

.wcqr-col-name a:hover {
    color: var(--wcqr-primary);
    text-decoration: underline;
}

/* ── SKU ───────────────────────────────────────────────────────────────────── */
.wcqr-col-sku td,
td.wcqr-col-sku {
    color: var(--wcqr-secondary);
    font-size: 13px;
}

/* ── Qty input ─────────────────────────────────────────────────────────────── */
.wcqr-qty-input {
    width: 60px;
    padding: 6px 8px;
    border: 1.5px solid var(--wcqr-border);
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
    font-family: var(--wcqr-font);
    transition: border-color 0.15s;
    -moz-appearance: textfield;
    display: block;
    margin: 0 auto;
}

.wcqr-qty-input::-webkit-inner-spin-button,
.wcqr-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.wcqr-qty-input:focus {
    outline: none;
    border-color: var(--wcqr-primary);
    box-shadow: 0 0 0 2px rgba(34,113,177,.15);
}

/* ── Discounted price ──────────────────────────────────────────────────────── */
.wcqr-disc-price {
    color: var(--wcqr-disc-color);
    font-weight: 700;
    font-size: 14px;
}

.wcqr-no-disc {
    color: #bbb;
}

.wcqr-price-loading {
    color: #aaa;
    font-style: italic;
    font-size: 13px;
    animation: wcqr-pulse 0.7s ease-in-out infinite alternate;
}

@keyframes wcqr-pulse {
    from { opacity: 0.3; }
    to   { opacity: 1;   }
}

/* ── States ────────────────────────────────────────────────────────────────── */
.wcqr-loading,
.wcqr-empty,
.wcqr-error {
    text-align: center;
    padding: 30px 20px !important;
    color: var(--wcqr-secondary);
    font-style: italic;
    font-size: 14px;
}

.wcqr-error { color: var(--wcqr-disc-color); }

/* ── Actions bar ───────────────────────────────────────────────────────────── */
.wcqr-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 4px 0 8px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.wcqr-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border-radius: var(--wcqr-radius);
    font-size: 14px;
    font-family: var(--wcqr-font);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
    line-height: 1;
}

.wcqr-btn-primary {
    background: var(--wcqr-primary);
    color: #fff;
    border-color: var(--wcqr-primary);
}

.wcqr-btn-primary:hover {
    background: var(--wcqr-primary-dark);
    border-color: var(--wcqr-primary-dark);
}

.wcqr-btn-secondary {
    background: var(--wcqr-secondary);
    color: #fff;
    border-color: var(--wcqr-secondary);
}

.wcqr-btn-secondary:hover {
    background: #3c4247;
    border-color: #3c4247;
}

.wcqr-btn-outline {
    background: transparent;
    color: var(--wcqr-secondary);
    border-color: var(--wcqr-border);
}

.wcqr-btn-outline:hover {
    background: var(--wcqr-bg-alt);
    border-color: var(--wcqr-secondary);
}

/* ── Quote totals ──────────────────────────────────────────────────────────── */
.wcqr-quote-totals {
    padding: 16px 20px;
    border-top: 2px solid var(--wcqr-border);
    background: var(--wcqr-bg-alt);
    border-radius: 0 0 var(--wcqr-radius) var(--wcqr-radius);
}

.wcqr-total-row {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 16px;
}

.wcqr-total-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--wcqr-secondary);
}

.wcqr-total-value {
    font-size: 22px;
    font-weight: 700;
    color: #1e1e1e;
}

.wcqr-no-shipping {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--wcqr-secondary);
    text-align: right;
}

/* ── Quote title ───────────────────────────────────────────────────────────── */
.wcqr-quote-title {
    padding: 18px 20px 14px;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid var(--wcqr-border);
    color: #1e1e1e;
}

/* ── Print ─────────────────────────────────────────────────────────────────── */
@media print {
    .wcqr-cat-bar,
    .wcqr-actions,
    #wcqr-products-view {
        display: none !important;
    }

    #wcqr-quote-view {
        display: block !important;
    }

    .wcqr-table {
        font-size: 12px;
    }

    .wcqr-col-image img {
        width: 44px;
        height: 44px;
    }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .wcqr-table th,
    .wcqr-table td {
        padding: 8px 8px;
        font-size: 12px;
    }

    .wcqr-col-image img {
        width: 44px;
        height: 44px;
    }

    .wcqr-qty-input {
        width: 50px;
        font-size: 13px;
    }

    .wcqr-btn {
        padding: 9px 16px;
        font-size: 13px;
    }
}

/* ── Sticky Summary Bar ────────────────────────────────────────────────────── */
.wcqr-sticky-bar {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    z-index: 9999;
    background: #1e2227;
    color: #fff;
    box-shadow: 0 -3px 16px rgba(0,0,0,0.22);
    padding: 14px 24px;
    direction: rtl;
}

.wcqr-sticky-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 16px;
    flex-wrap: wrap;
}

.wcqr-sticky-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wcqr-sticky-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    flex-wrap: wrap;
}

.wcqr-sticky-count {
    font-weight: 700;
    color: #7dd3fc;
}

.wcqr-sticky-sep {
    color: #555;
}

.wcqr-sticky-label {
    color: #cbd5e1;
}

.wcqr-sticky-total {
    font-weight: 700;
    font-size: 18px;
    color: #fff;
}

.wcqr-sticky-bar .wcqr-btn-primary {
    background: #2271b1;
    border-color: #2271b1;
    font-size: 15px;
    padding: 11px 28px;
    white-space: nowrap;
}

.wcqr-sticky-bar .wcqr-btn-primary:hover {
    background: #135e96;
    border-color: #135e96;
}

/* ── Larger thumbnails ─────────────────────────────────────────────────────── */
.wcqr-col-image  { width: 82px; }

.wcqr-col-image img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--wcqr-border);
    display: block;
    margin: 0 auto;
}

/* ── Tighter name column ───────────────────────────────────────────────────── */
.wcqr-col-name  { width: auto; min-width: 120px; max-width: 260px; }
.wcqr-col-sku   { width: 90px; color: var(--wcqr-secondary); font-size: 13px; }

/* Padding for bottom sticky bar */
#wcqr-products-view {
    padding-bottom: 72px;
}

/* ── Print — hide sticky ───────────────────────────────────────────────────── */
@media print {
    .wcqr-sticky-bar { display: none !important; }
    #wcqr-products-view { padding-bottom: 0; }
}

/* ── Mobile sticky ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .wcqr-sticky-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .wcqr-sticky-bar .wcqr-btn-primary {
        width: 100%;
        justify-content: center;
    }
}

/* ── Clear row (X) button ──────────────────────────────────────────────────── */
.wcqr-col-clear {
    width: 36px;
    text-align: center;
    padding: 0 4px !important;
}

.wcqr-clear-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #ccc;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    visibility: hidden;
}

.wcqr-product-row:hover .wcqr-clear-row,
.wcqr-row-selected .wcqr-clear-row {
    visibility: visible;
}

.wcqr-clear-row:hover {
    background: #fde8e8;
    color: #c0392b;
}

/* ── Clear all button in sticky bar ───────────────────────────────────────── */
.wcqr-btn-clear-all {
    background: transparent;
    border: 1.5px solid #555;
    color: #ccc;
    font-size: 13px;
    padding: 8px 16px;
}

.wcqr-btn-clear-all:hover {
    border-color: #e74c3c;
    color: #e74c3c;
    background: transparent;
}

/* ── Validity note ─────────────────────────────────────────────────────────── */
.wcqr-validity {
    margin: 12px 0 0;
    font-size: 14px;
    font-weight: 700;
    color: #1e1e1e;
    text-align: right;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE — Card layout (replaces table on small screens)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {

    /* Hide the table entirely */
    .wcqr-products-wrap,
    .wcqr-quote-wrap {
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .wcqr-table thead { display: none; }

    .wcqr-table,
    .wcqr-table tbody,
    .wcqr-table tr,
    .wcqr-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    /* Each product row = card */
    .wcqr-product-row {
        background: #fff;
        border: 1px solid var(--wcqr-border);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 12px;
        position: relative;
        display: grid !important;
        grid-template-columns: 72px 1fr;
        grid-template-rows: auto;
        gap: 0 12px;
        align-items: start;
    }

    .wcqr-product-row.wcqr-row-selected {
        border-color: #2271b1;
        background: var(--wcqr-row-selected);
    }

    /* Image — spans rows on the right */
    .wcqr-product-row .wcqr-col-image {
        grid-column: 1;
        grid-row: 1 / 5;
        padding: 0;
        border: none;
        width: 72px;
    }

    .wcqr-product-row .wcqr-col-image img {
        width: 68px;
        height: 68px;
        margin: 0;
    }

    /* Name */
    .wcqr-product-row .wcqr-col-name {
        grid-column: 2;
        grid-row: 1;
        padding: 0 0 4px 0;
        border: none;
        font-size: 14px;
        font-weight: 600;
    }

    /* SKU */
    .wcqr-product-row .wcqr-col-sku {
        grid-column: 2;
        grid-row: 2;
        padding: 0 0 6px 0;
        border: none;
        font-size: 12px;
        color: #888;
    }

    /* Price row — price + qty inline */
    .wcqr-product-row .wcqr-col-price {
        grid-column: 2;
        grid-row: 3;
        padding: 0 0 6px 0;
        border: none;
        font-size: 13px;
        color: #555;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .wcqr-product-row .wcqr-col-price::before {
        content: 'מחיר: ';
        font-size: 12px;
        color: #999;
    }

    /* Qty */
    .wcqr-product-row .wcqr-col-qty {
        grid-column: 2;
        grid-row: 4;
        padding: 0 0 6px 0;
        border: none;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .wcqr-product-row .wcqr-col-qty::before {
        content: 'כמות: ';
        font-size: 12px;
        color: #999;
        white-space: nowrap;
    }

    .wcqr-product-row .wcqr-qty-input {
        width: 72px;
        margin: 0;
    }

    /* Discounted price */
    .wcqr-product-row .wcqr-col-disc {
        grid-column: 2;
        grid-row: 5;
        padding: 0 0 4px 0;
        border: none;
        font-size: 13px;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .wcqr-product-row .wcqr-col-disc::before {
        content: 'מחיר לאחר הנחה: ';
        font-size: 12px;
        color: #999;
        white-space: nowrap;
    }

    /* Line total */
    .wcqr-product-row .wcqr-col-total {
        grid-column: 2;
        grid-row: 6;
        padding: 6px 0 0 0;
        border: none;
        border-top: 1px solid var(--wcqr-border);
        font-size: 15px;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .wcqr-product-row .wcqr-col-total::before {
        content: 'סה"כ: ';
        font-size: 12px;
        color: #999;
        font-weight: 400;
    }

    /* Clear (X) button */
    .wcqr-product-row .wcqr-col-clear {
        position: absolute;
        top: 10px;
        left: 10px;
        width: auto;
        padding: 0;
        border: none;
    }

    .wcqr-clear-row {
        visibility: visible !important;
    }

    /* Quote view cards */
    .wcqr-quote-table .wcqr-product-row,
    .wcqr-quote-table tr {
        background: #fff;
        border: 1px solid var(--wcqr-border);
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 12px;
        display: grid !important;
        grid-template-columns: 64px 1fr;
        gap: 0 12px;
    }

    /* Totals */
    .wcqr-quote-totals {
        border-radius: var(--wcqr-radius);
        margin-top: 4px;
    }

    .wcqr-total-value {
        font-size: 20px;
    }

    /* Sticky bar — stack on mobile */
    .wcqr-sticky-inner {
        flex-direction: column;
        gap: 10px;
        padding: 10px 16px;
    }

    .wcqr-sticky-actions {
        width: 100%;
        justify-content: stretch;
    }

    .wcqr-sticky-actions .wcqr-btn {
        flex: 1;
        justify-content: center;
    }

    .wcqr-sticky-summary {
        font-size: 13px;
    }

    /* Category tabs — scrollable row */
    .wcqr-cat-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .wcqr-cat-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* More padding for sticky bar */
    #wcqr-products-view {
        padding-bottom: 110px;
    }
}
