/* ═══════════════════════════════════════════════════════
   Rebost Carrito Ràpid — Styles
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────── */
:root {
    --rcr-primary: #527F40;
    --rcr-primary-light: #6a9a54;
    --rcr-primary-lighter: #93C356;
    --rcr-primary-bg: #e2f0d9;
    --rcr-primary-bg-subtle: #f4f9f0;
    --rcr-accent: #e76f51;
    --rcr-accent-light: #f4a261;

    --rcr-text: #1b1b1b;
    --rcr-text-secondary: #555;
    --rcr-text-muted: #888;
    --rcr-border: #e0e0e0;
    --rcr-border-light: #f0f0f0;
    --rcr-bg: #ffffff;
    --rcr-bg-subtle: #fafafa;
    --rcr-bg-hover: #f5f9f6;
    --rcr-shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --rcr-shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --rcr-shadow-lg: 0 8px 24px rgba(0,0,0,.12);
    --rcr-radius: 10px;
    --rcr-radius-sm: 6px;
    --rcr-radius-xs: 4px;
    --rcr-transition: .2s ease;
    --rcr-font: 'Tipo', sans-serif;
}

/* ── Reset & Container ─────────────────────────────── */
.rcr-app {
    font-family: var(--rcr-font);
    color: var(--rcr-text);
    /*max-width: 1200px;*/
    max-width: 1386px;
    margin: 0 auto;
    padding: 24px 16px 120px;
    -webkit-font-smoothing: antialiased;
}

.rcr-app *, .rcr-app *::before, .rcr-app *::after {
    box-sizing: border-box;
}

/* ── Header ────────────────────────────────────────── */
.rcr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.rcr-header__title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rcr-header__icon {
    font-size: 28px;
}

.rcr-header__title h2 {
    margin: 0;
    /*font-size: 24px;*/
    font-weight: 700;
    color: var(--rcr-primary);
    letter-spacing: -0.02em;
}

.rcr-header__subtitle {
    /*font-size: 14px;*/
    color: var(--rcr-text-muted);
    margin-left: 4px;
}

.rcr-header__search {
    position: relative;
    flex: 0 1 320px;
    min-width: 200px;
}

.rcr-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--rcr-text-muted);
    pointer-events: none;
}

.rcr-search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1.5px solid var(--rcr-border);
    border-radius: var(--rcr-radius);
    /*font-size: 14px;*/
    font-family: var(--rcr-font);
    color: var(--rcr-text);
    background: var(--rcr-bg);
    transition: border-color var(--rcr-transition), box-shadow var(--rcr-transition);
    outline: none;
}
#rcr-search {
	padding-left: 40px;
}

.rcr-search-input:focus {
    border-color: var(--rcr-primary-light);
    box-shadow: 0 0 0 3px rgba(82,127,64,.1);
}

.rcr-search-input:disabled {
    background: var(--rcr-bg-subtle);
    cursor: not-allowed;
}

/* ── Macro-category Tabs ───────────────────────────── */
.rcr-tabs-wrapper {
    margin-bottom: 20px;
}

.rcr-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.rcr-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1.5px solid var(--rcr-border);
    border-radius: 50px;
    background: var(--rcr-bg);
    cursor: pointer;
    font-family: var(--rcr-font);
    font-size: 21px;
    font-weight: 500;
    color: var(--rcr-text-secondary);
    transition: all var(--rcr-transition);
    white-space: nowrap;
    user-select: none;
}

.rcr-tab:hover {
    border-color: var(--rcr-primary-light);
    color: var(--rcr-primary);
    background: var(--rcr-primary-bg-subtle);
    transform: translateY(-1px);
    box-shadow: var(--rcr-shadow-sm);
}

.rcr-tab[aria-selected="true"] {
    background: var(--rcr-primary);
    color: #fff;
    border-color: var(--rcr-primary);
    box-shadow: var(--rcr-shadow-md);
}

.rcr-tab[aria-selected="true"] .rcr-tab__count {
    background: rgba(255,255,255,.2);
    color: #fff;
}

.rcr-tab__icon {
    /*font-size: 16px;*/
    line-height: 1;
}

.rcr-tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 50px;
    background: var(--rcr-border-light);
    /*font-size: 11px;*/
    font-weight: 600;
    color: var(--rcr-text-muted);
    transition: all var(--rcr-transition);
}

/* ── Sub-family pills ──────────────────────────────── */
.rcr-subfamilies {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--rcr-primary-bg-subtle);
    border-radius: var(--rcr-radius);
    border: 1px solid var(--rcr-primary-bg);
}

.rcr-subfamily-pill {
    padding: 6px 14px;
    border: 1.5px solid var(--rcr-primary-bg);
    border-radius: 50px;
    background: var(--rcr-bg);
    cursor: pointer;
    font-family: var(--rcr-font);
    /*font-size: 12px;*/
    font-weight: 500;
    color: var(--rcr-primary);
    transition: all var(--rcr-transition);
    white-space: nowrap;
}

.rcr-subfamily-pill:hover {
    background: var(--rcr-primary-bg);
    border-color: var(--rcr-primary-lighter);
}

.rcr-subfamily-pill.active {
    background: var(--rcr-primary-lighter);
    color: #fff;
    border-color: var(--rcr-primary-lighter);
}

.rcr-subfamily-all {
    font-weight: 600;
}

/* ── Table Wrapper ─────────────────────────────────── */
.rcr-table-wrapper {
    min-height: 300px;
}

/* ── Empty state ───────────────────────────────────── */
.rcr-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--rcr-text-muted);
}

.rcr-empty-state__icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: .6;
}

.rcr-empty-state p {
    /*font-size: 15px;*/
    margin: 0;
}

/* ── Loading ───────────────────────────────────────── */
.rcr-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--rcr-text-muted);
}

.rcr-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--rcr-border);
    border-top-color: var(--rcr-primary);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: rcr-spin .7s linear infinite;
}

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

.rcr-loading p {
    /*font-size: 14px;*/
    margin: 0;
}

/* ── No results ────────────────────────────────────── */
.rcr-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--rcr-text-muted);
    /*font-size: 14px;*/
}

/* ── Product Table ─────────────────────────────────── */
.rcr-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--rcr-border);
    border-radius: var(--rcr-radius);
    overflow: hidden;
    background: var(--rcr-bg);
    box-shadow: var(--rcr-shadow-sm);
}

.rcr-table thead {
    background: var(--rcr-bg-subtle);
}

.rcr-table th {
    padding: 12px 14px;
    text-align: left;
    /*font-size: 11px;*/
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--rcr-text-muted);
    border-bottom: 1.5px solid var(--rcr-border);
    white-space: nowrap;
    font-family: "Tipo";
}

.rcr-table td {
    padding: 10px 14px;
    /*font-size: 14px;*/
    border-bottom: 1px solid var(--rcr-border-light);
    vertical-align: middle;
    transition: background var(--rcr-transition);
}

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

.rcr-table tbody tr:hover td {
    background: var(--rcr-bg-hover);
}

.rcr-table tbody tr.rcr-row--in-cart td {
    background: var(--rcr-primary-bg-subtle);
}

.rcr-table tbody tr.rcr-row--in-cart:hover td {
    background: var(--rcr-primary-bg);
}

/* Column widths */
.rcr-th-img { width: 60px; }
.rcr-th-sku { width: 80px; }
.rcr-th-price { width: 100px; }
.rcr-th-weight { width: 150px; }
.rcr-th-qty { width: 130px; text-align: center; }

/* ── Product image ─────────────────────────────────── */
.rcr-product-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--rcr-radius-sm);
    border: 1px solid var(--rcr-border-light);
}

/* ── Product name ──────────────────────────────────── */
.rcr-product-name {
    font-weight: 500;
    color: var(--rcr-text);
    text-decoration: none;
    transition: color var(--rcr-transition);
    line-height: 1.35;
}

.rcr-product-name:hover {
    color: var(--rcr-primary);
}

/* ── SKU ───────────────────────────────────────────── */
.rcr-product-sku {
    /*font-size: 12px;*/
    color: var(--rcr-text-muted);
    font-weight: 500;
}

/* ── Price ──────────────────────────────────────────── */
.rcr-product-price {
    font-weight: 600;
    color: var(--rcr-primary);
    /*font-size: 14px;*/
    white-space: nowrap;
}

/* ── Weight/format dropdown ────────────────────────── */
.rcr-weight-select {
    padding: 7px 28px 7px 10px;
    border: 1.5px solid var(--rcr-border);
    border-radius: var(--rcr-radius-sm);
    /*font-size: 13px;*/
    font-family: var(--rcr-font);
    color: var(--rcr-text);
    background: var(--rcr-bg);
    cursor: pointer;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--rcr-transition);
    outline: none;
}

.rcr-weight-select:focus {
    border-color: var(--rcr-primary-light);
}

.rcr-unit-label {
    /*font-size: 13px;*/
    color: var(--rcr-text-muted);
    font-style: italic;
}

/* ── Quantity control ──────────────────────────────── */
.rcr-qty-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border: 1.5px solid var(--rcr-border);
    border-radius: var(--rcr-radius-sm);
    overflow: hidden;
    transition: border-color var(--rcr-transition), box-shadow var(--rcr-transition);
    max-width: 120px;
    margin: 0 auto;
}

.rcr-qty-control:focus-within {
    border-color: var(--rcr-primary-light);
    box-shadow: 0 0 0 2px rgba(82,127,64,.1);
}

.rcr-qty-control.rcr-qty--active {
    border-color: var(--rcr-primary-lighter);
    background: var(--rcr-primary-bg-subtle);
}

.rcr-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    cursor: pointer;
    /*font-size: 16px;*/
    font-weight: 600;
    color: var(--rcr-text-muted);
    transition: all var(--rcr-transition);
    padding: 0;
    line-height: 1;
    user-select: none;
}

.rcr-qty-btn:hover {
    background: var(--rcr-primary-bg);
    color: var(--rcr-primary);
}

.rcr-qty-btn:active {
    transform: scale(.92);
}

.rcr-qty-input {
    width: 46px;
    height: 34px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--rcr-border-light);
    border-right: 1px solid var(--rcr-border-light);
    /*font-size: 14px;*/
    font-weight: 600;
    font-family: var(--rcr-font);
    color: var(--rcr-text);
    background: transparent;
    outline: none;
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

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

.rcr-qty-control.rcr-qty--disabled {
    opacity: .4;
    pointer-events: none;
}

/* ── Feedback toast ────────────────────────────────── */
.rcr-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--rcr-radius);
    /*font-size: 13px;*/
    font-weight: 500;
    font-family: var(--rcr-font);
    color: #fff;
    z-index: 99999;
    animation: rcr-toast-in .3s ease, rcr-toast-out .3s ease 2.2s forwards;
    box-shadow: var(--rcr-shadow-lg);
}

.rcr-toast--success { background: var(--rcr-primary); }
.rcr-toast--error   { background: var(--rcr-accent); }

@keyframes rcr-toast-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes rcr-toast-out {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-12px); }
}

/* ── Sticky Cart Bar ───────────────────────────────── */
.rcr-cart-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--rcr-bg);
    border-top: 1px solid var(--rcr-border);
    z-index: 9990;
    box-shadow: 0 -4px 20px rgba(0,0,0,.08);
    transform: translateY(100%);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
}

.rcr-cart-bar.rcr-cart-bar--visible {
    transform: translateY(0);
}

.rcr-cart-bar__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.rcr-cart-bar__info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rcr-cart-bar__icon {
    /*font-size: 22px;*/
}

.rcr-cart-bar__text {
    /*font-size: 15px;*/
    font-weight: 500;
    color: var(--rcr-text);
}

.rcr-cart-bar__sep {
    color: var(--rcr-text-muted);
    margin: 0 4px;
}

.rcr-cart-bar__total {
    font-weight: 700;
    color: var(--rcr-primary);
    /*font-size: 17px;*/
}

.rcr-cart-bar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Buttons ───────────────────────────────────────── */
.rcr-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--rcr-radius-sm);
    font-family: var(--rcr-font);
    /*font-size: 14px;*/
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--rcr-transition);
    white-space: nowrap;
}

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

.rcr-btn--primary:hover {
    background: var(--rcr-primary-light);
    transform: translateY(-1px);
    box-shadow: var(--rcr-shadow-md);
    color: #fff;
}

.rcr-btn--ghost {
    background: transparent;
    color: var(--rcr-text-secondary);
    padding: 10px 12px;
}

.rcr-btn--ghost:hover {
    background: var(--rcr-bg-subtle);
    color: var(--rcr-primary);
}

/* ── Cart Detail Panel ─────────────────────────────── */
.rcr-cart-detail {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 14px;
    border-top: 1px solid var(--rcr-border-light);
    max-height: 280px;
    overflow-y: auto;
}

.rcr-cart-detail__list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
}

.rcr-cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--rcr-radius-sm);
    background: var(--rcr-bg-subtle);
    /*font-size: 13px;*/
}

.rcr-cart-item__img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: var(--rcr-radius-xs);
    flex-shrink: 0;
}

.rcr-cart-item__name {
    flex: 1;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rcr-cart-item__qty {
    color: var(--rcr-text-muted);
    white-space: nowrap;
}

.rcr-cart-item__subtotal {
    font-weight: 600;
    color: var(--rcr-primary);
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

.rcr-cart-item__delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--rcr-radius-xs);
    background: transparent;
    color: var(--rcr-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: all var(--rcr-transition);
}

.rcr-cart-item__delete:hover {
    background: #fde8e8;
    color: #c0392b;
}

.rcr-cart-item__delete:active {
    transform: scale(0.9);
}

.rcr-cart-item__delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--rcr-radius-xs);
    background: transparent;
    color: var(--rcr-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: all var(--rcr-transition);
}

.rcr-cart-item__delete:hover {
    background: #fde8e8;
    color: #c0392b;
}

.rcr-cart-item__delete:active {
    transform: scale(0.9);
}

.rcr-cart-empty {
    text-align: center;
    padding: 20px;
    color: var(--rcr-text-muted);
    /*font-size: 13px;*/
}

/* ── Updating indicator on row ─────────────────────── */
.rcr-row--updating td {
    opacity: .5;
    pointer-events: none;
}

/* ── RESPONSIVE ════════════════════════════════════════ */

/* Tablet */
@media (max-width: 900px) {
    .rcr-header {
        flex-direction: column;
        align-items: stretch;
    }

    .rcr-header__search {
        flex: 1 1 100%;
    }

    .rcr-th-img,
    .rcr-table td:first-child {
        display: none;
    }
}

/* Mobile — Convert table to cards */
@media (max-width: 640px) {
    .rcr-app {
        padding: 16px 12px 130px;
    }

    .rcr-header__title h2 {
        font-size: 20px;
    }

    .rcr-header__subtitle {
        display: none;
    }

    .rcr-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    /* Card layout */
    .rcr-table thead {
        display: none;
    }

    .rcr-table,
    .rcr-table tbody,
    .rcr-table tr,
    .rcr-table td {
        display: block;
    }

    .rcr-table {
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .rcr-table tbody tr {
        background: var(--rcr-bg);
        border: 1px solid var(--rcr-border);
        border-radius: var(--rcr-radius);
        margin-bottom: 10px;
        padding: 14px;
        box-shadow: var(--rcr-shadow-sm);
        display: grid;
        grid-template-columns: 50px 1fr;
        grid-template-rows: auto auto auto;
        gap: 6px 12px;
        align-items: center;
    }

    .rcr-table tbody tr.rcr-row--in-cart {
        border-color: var(--rcr-primary-lighter);
    }

    .rcr-table td {
        padding: 0;
        border: none;
    }

    .rcr-table td:first-child {
        display: block;
        grid-row: 1 / 3;
    }

    /* Name + SKU */
    .rcr-table td:nth-child(2) { /* SKU */
        grid-column: 2;
        grid-row: 1;
    }

    .rcr-table td:nth-child(3) { /* Name */
        grid-column: 2;
        grid-row: 1;
        font-weight: 600;
    }

    /* Rearrange: img | name+sku row, then price | weight | qty row */
    .rcr-table tbody tr {
        grid-template-columns: 50px 1fr 1fr;
        grid-template-rows: auto auto;
    }

    .rcr-table td:first-child { /* img */
        grid-row: 1 / 3;
        grid-column: 1;
    }

    .rcr-table td:nth-child(2) { /* sku */
        grid-row: 2;
        grid-column: 2;
        font-size: 11px;
    }

    .rcr-table td:nth-child(3) { /* name */
        grid-row: 1;
        grid-column: 2 / 4;
        font-size: 14px;
    }

    .rcr-table td:nth-child(4) { /* price */
        grid-row: 2;
        grid-column: 3;
        text-align: right;
    }

    .rcr-table td:nth-child(5) { /* weight */
        grid-row: 3;
        grid-column: 1 / 3;
    }

    .rcr-table td:nth-child(6) { /* qty */
        grid-row: 3;
        grid-column: 3;
    }

    .rcr-weight-select {
        font-size: 12px;
    }

    .rcr-qty-control {
        margin: 0;
        max-width: 110px;
    }

    /* Cart bar mobile */
    .rcr-cart-bar__inner {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    .rcr-cart-bar__actions {
        width: 100%;
    }

    .rcr-btn--primary {
        flex: 1;
        justify-content: center;
    }
}

/* ── Print styles ──────────────────────────────────── */
@media print {
    .rcr-cart-bar,
    .rcr-header__search,
    .rcr-tabs-wrapper,
    .rcr-subfamilies,
    .rcr-qty-btn {
        display: none !important;
    }

    .rcr-app {
        padding: 0;
    }
}
