/* === GRID === */
.wcrm-products-grid {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    min-width: 0;
}

@media screen and (max-width: 520px) {
    .wcrm-products-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }
}

@media screen and (min-width: 521px) and (max-width: 1024px) {
    .wcrm-products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }
}

@media screen and (min-width: 900px) and (max-width: 1024px) {
    .wcrm-products-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 18px;
    }
}

@media screen and (min-width: 1025px) {
    .wcrm-products-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 20px;
    }
}

/* === ПРОДУКТИ === */
.wcrm-product-card {
    background: white;
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    isolation: isolate;
}


.wcrm-products-grid > * ,
.wcrm-product-card,
.wcrm-product-image,
.wcrm-product-content,
.wcrm-product-title,
.wcrm-product-description,
.wcrm-product-price,
.wcrm-product-actions,
.wcrm-product-actions-row,
.wcrm-product-actions-row .button {
    min-width: 0;
    box-sizing: border-box;
}

.wcrm-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.wcrm-out-of-stock { opacity: 0.7; }

.wcrm-out-of-stock-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #e74c3c;
    color: white;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    z-index: 2000;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.wcrm-out-of-stock-btn {
    background: #bdc3c7 !important;
    cursor: not-allowed !important;
    opacity: 0.8;
}

.wcrm-product-image {
    width: 100%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    border-radius: 10px 10px 0 0;
}

.wcrm-product-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.wcrm-product-card:hover .wcrm-product-image img {
    transform: scale(1.05);
}

.wcrm-product-content {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.wcrm-product-card-no-image .wcrm-product-content {
    padding-top: 18px;
}

.wcrm-product-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.wcrm-product-price {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 12px 0;
    width: 100%;
    text-align: center;
    line-height: 1.3;
    font-family: inherit;
}

.wcrm-product-price .woocommerce-Price-amount,
.wcrm-product-price .amount,
.wcrm-product-price bdi,
.wcrm-product-price .woocommerce-Price-currencySymbol,
.wcrm-product-price .eur-price,
.wcrm-product-price span {
    font-family: inherit !important;
}

.wcrm-product-description {
    font-size: 13px;
    line-height: 1.4;
    margin: 0 0 15px 0;
    flex-grow: 1;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.wcrm-product-actions { text-align: center; margin-top: auto; }
.wcrm-product-actions .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    padding: 10px 20px;
    text-decoration: none;
    text-align: center;
    line-height: 1.2;
    vertical-align: middle;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 22px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
}

.wcrm-product-actions .button.loading { opacity: 0.7; pointer-events: none; }
.wcrm-product-actions .button.added { background: #2ecc71 !important; }

.wcrm-product-actions .button > span,
.wcrm-product-actions .button > strong,
.wcrm-product-actions .button > em {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.wcrm-product-actions .wcrm-add-to-cart {
    justify-content: center;
}

.wcrm-out-of-stock-btn {
    justify-content: center !important;
    text-align: center !important;
}

/* Описание с бутон "още" (стабилно на мобилни) */
.wcrm-product-description {
    font-size: 13px;
    line-height: 1.4;
    margin: 5px 0 10px 0;
    color: #666;
    word-wrap: break-word;
}

.wcrm-desc-text {
    display: block;
}

/* По подразбиране е "свито" (ако има бутон още). Показваме N реда чрез max-height.
   N идва от inline CSS variable --wcrm-desc-lines (1..10). */
.wcrm-product-description.wcrm-collapsed .wcrm-desc-text {
    max-height: calc(var(--wcrm-desc-lines, 3) * 1.4em);
    overflow: hidden;
}

.wcrm-product-description.wcrm-expanded .wcrm-desc-text {
    max-height: none;
    overflow: visible;
}

.wcrm-read-more {
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    margin-top: 6px;
    display: inline-block;
    font-size: 12px;
    user-select: none;
}

.wcrm-read-more:hover { opacity: 0.8; }

.wcrm-read-more.less {
    display: inline-block;
    margin-top: 8px;
}

/* === КАТЕГОРИИ - Основни стилове (ще се презаписват от динамичния CSS) === */
.wcrm-category-filter {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

/* Placeholder-ът е оставен за backward-compat / sticky експерименти,
   но не трябва да влияе на подравняването на бутоните. */
.wcrm-category-filter-placeholder {
    display: none;
}

.wcrm-category-filter::-webkit-scrollbar { display: none; }

.wcrm-category-btn {
    flex: 0 0 auto;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
    min-width: fit-content;
    user-select: none;
    font-family: inherit;
}

/* === КОНТЕЙНЕР === */
.wcrm-restaurant-menu-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    border-radius: 10px;
    position: relative;
    isolation: isolate;
}

.wcrm-page-bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-repeat: no-repeat;
    background-position: center top;
    background-size: cover;
    -webkit-background-size: cover;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform;
}

.wcrm-restaurant-menu-wrapper.wcrm-has-page-bg {
    background: transparent;
}

/* === МОБИЛНИ === */
@media screen and (max-width: 375px) {
    .wcrm-products-grid { gap: 12px; }
    .wcrm-out-of-stock-badge { top: 8px; right: 8px; font-size: 11px; padding: 5px 10px; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; }
    .wcrm-product-content { padding: 10px; }
    .wcrm-product-title { font-size: 14px; margin: 0 0 6px 0; }
    .wcrm-product-price { font-size: 16px; }
    .wcrm-product-description { font-size: 12px; margin: 4px 0 8px 0; }
    .wcrm-product-actions-row { flex-direction: column; }
    .wcrm-product-actions-row .button { width: 100%; flex: 1 1 auto; }
    .wcrm-product-actions .button { min-height: 40px; padding: 9px 12px; }
    .wcrm-restaurant-menu-wrapper { padding: 10px; }
}

@media screen and (min-width: 376px) and (max-width: 520px) {
    .wcrm-product-content { padding: 12px; }
    .wcrm-product-title { margin: 0 0 6px 0; }
    .wcrm-product-description { margin: 4px 0 8px 0; }
    .wcrm-product-actions-row { flex-direction: column; }
    .wcrm-product-actions-row .button { width: 100%; flex: 1 1 auto; }
    .wcrm-product-actions .button { min-height: 40px; padding: 10px 14px; }
    .wcrm-restaurant-menu-wrapper { padding: 12px; }
}

@media screen and (min-width: 521px) and (max-width: 768px) {
    .wcrm-product-content { padding: 14px; }
    .wcrm-restaurant-menu-wrapper { padding: 14px; }
}

@media screen and (max-width: 767px) {
    .wcrm-page-bg-layer {
        background-position: left top;
    }
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
    .wcrm-page-bg-layer {
        background-position: center top;
    }
}

@media screen and (min-width: 1025px) {
    .wcrm-page-bg-layer {
        background-position: center center;
    }
}

/* === ДЕСКТОП === */
@media screen and (min-width: 769px) {
    .wcrm-category-filter {
        scroll-behavior: smooth;
    }
}
@media screen and (max-width: 375px) {
    .wcrm-product-description {
        font-size: 11px;
        margin: 3px 0 8px 0 !important;
        
    }
}

@media screen and (max-width: 520px) {
    .wcrm-product-card:not(.wcrm-product-card-no-image) {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .wcrm-product-card:not(.wcrm-product-card-no-image) .wcrm-product-image {
        width: 100%;
        height: auto !important;
        min-height: 0;
        padding: 0;
        display: block;
        border-radius: 10px 10px 0 0;
        overflow: hidden;
    }

    .wcrm-product-card:not(.wcrm-product-card-no-image) .wcrm-product-image img {
        display: block;
        width: 100%;
        height: auto;
        max-width: 100%;
        max-height: none;
        object-fit: contain;
        transform: none !important;
    }

    .wcrm-product-card:not(.wcrm-product-card-no-image):hover .wcrm-product-image img {
        transform: none !important;
    }

    .wcrm-product-card:not(.wcrm-product-card-no-image) .wcrm-product-content {
        width: 100%;
        min-width: 0;
        padding: 10px 12px 12px;
    }

    .wcrm-product-card:not(.wcrm-product-card-no-image) .wcrm-product-meta-row {
        align-items: center;
        gap: 8px;
    }
}

/* Sticky menu fallback */
.wcrm-category-filter {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* За мобилни - по-малък z-index ако има проблеми */
@media screen and (max-width: 768px) {
    .wcrm-category-filter {
        z-index: 999;
    }
}
/* === ДЕЙСТВИЯ (Добави + Коментар) === */
.wcrm-product-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    position: relative;
}

.wcrm-product-actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.wcrm-product-actions-row .button {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: 100%;
}

/* Вторичен бутон "Коментар" (по подразбиране) */
.wcrm-comment-btn {
    background: transparent !important;
    border: 2px solid rgba(0, 0, 0, 0.18) !important;
}

.wcrm-comment-btn:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

/* Индикатор, че има въведен коментар */
.wcrm-comment-btn.has-comment {
    position: relative;
}

.wcrm-comment-btn.has-comment::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 10px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.9;
}

/* Балон с текстово поле */
.wcrm-comment-popover {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.wcrm-comment-textarea {
    width: 100%;
    min-height: 70px;
    resize: vertical;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.16);
    font-size: 13px;
    line-height: 1.35;
    box-sizing: border-box;
}

.wcrm-comment-popover-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.wcrm-comment-save,
.wcrm-comment-close {
    flex: 1 1 0;
    padding: 8px 10px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.wcrm-comment-close {
    background: rgba(0, 0, 0, 0.06);
}

.wcrm-comment-close:hover {
    background: rgba(0, 0, 0, 0.10);
}

/* Бейдж за бройките в бутона "Добави" */
.wcrm-qty-badge {
    display: none;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    background: rgba(0, 0, 0, 0.14);
    border: 1px solid rgba(0, 0, 0, 0.18);
}


/* Съобщения при липса на активни категории (по график) */
.wcrm-no-active-category,
.wcrm-no-active-categories {
    text-align: center;
    padding: 18px 12px;
    font-weight: 600;
    opacity: 0.9;
}

/* Sommelier */
.wcrm-product-meta-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0 0 10px 0;
    min-height: 42px;
}

.wcrm-product-meta-row.has-sommelier {
    padding-left: 52px;
    padding-right: 52px;
}

.wcrm-product-meta-row .wcrm-product-price {
    width: 100%;
    margin: 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    line-height: 1.3;
    font-family: inherit;
}

.wcrm-product-meta-row .wcrm-product-price,
.wcrm-product-meta-row .wcrm-product-price *,
.wcrm-product-meta-row .wcrm-product-price .woocommerce-Price-amount,
.wcrm-product-meta-row .wcrm-product-price .amount,
.wcrm-product-meta-row .wcrm-product-price bdi,
.wcrm-product-meta-row .wcrm-product-price .woocommerce-Price-currencySymbol,
.wcrm-product-meta-row .wcrm-product-price .eur-price,
.wcrm-product-meta-row .wcrm-product-price span {
    font-family: inherit !important;
    text-align: center;
}

.wcrm-sommelier-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 999px !important;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    background: #fff7f0 !important;
    border: 1px solid rgba(120,30,45,.18) !important;
    color: #7a2232 !important;
}

.wcrm-product-meta-row.has-sommelier .wcrm-sommelier-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}
.wcrm-sommelier-btn:hover{background:#7a2232 !important;color:#fff !important}
.wcrm-sommelier-modal{position:fixed;inset:0;z-index:99999}
.wcrm-sommelier-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.45)}
.wcrm-sommelier-dialog{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:min(92vw,560px);max-height:86vh;overflow:auto;background:#fff;border-radius:18px;padding:18px;box-shadow:0 20px 50px rgba(0,0,0,.22)}
.wcrm-sommelier-close{position:absolute;top:8px;right:10px;border:0;background:#fff;color:#111;font-size:30px;line-height:1;cursor:pointer;z-index:2}
.wcrm-sommelier-content{padding-top:10px}
.wcrm-sommelier-heading{font-size:20px;font-weight:700;margin-bottom:14px;padding-right:34px}
.wcrm-sommelier-item{display:flex;gap:12px;padding:12px 0;border-top:1px solid #eee}.wcrm-sommelier-item:first-child{border-top:0;padding-top:0}.wcrm-sommelier-item.is-primary{padding-bottom:16px}.wcrm-sommelier-thumb img{width:72px;height:72px;object-fit:cover;border-radius:12px}.wcrm-sommelier-body{flex:1;min-width:0}.wcrm-sommelier-name-row{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.wcrm-sommelier-name{font-weight:700}.wcrm-sommelier-note{margin-top:6px;font-size:14px;line-height:1.45}.wcrm-sommelier-actions{margin-top:10px}.wcrm-sommelier-alt-title{margin-top:8px;font-weight:700;font-size:14px;color:#666}.wcrm-sommelier-empty,.wcrm-sommelier-loading{padding:24px 6px 10px;text-align:center}
@media (max-width:768px){.wcrm-sommelier-dialog{left:0;right:0;bottom:0;top:auto;transform:none;width:100%;max-height:88vh;border-radius:18px 18px 0 0}}



@media (max-width: 520px) {
    .wcrm-product-meta-row.has-sommelier {
        padding-left: 46px;
        padding-right: 46px;
    }
}

/* Checkout product comments */
.wcrm-checkout-comment-wrap { margin-top: 8px; }
.wcrm-checkout-comment-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.wcrm-checkout-comment { display: block; width: 100%; max-width: 100%; min-height: 72px; resize: vertical; box-sizing: border-box; padding: 10px 12px; line-height: 1.4; border: 1px solid #d0d5dd; border-radius: 10px; background: #fff; }
.woocommerce-checkout-review-order .product-name .wcrm-checkout-comment-wrap { max-width: 420px; }
@media (max-width: 767px) { .wcrm-checkout-comment { min-height: 64px; } }

.woocommerce-checkout-review-order-table .wcrm-checkout-comment-wrap { margin-top: 8px; }
.woocommerce-checkout-review-order-table .wcrm-checkout-comment { width: 100%; }
