/* Restaurant Manager Pro - Frontend Styles */

.rmp-container {
    max-width: 1200px;
    margin: 0 auto;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}

/* Every grid product cell can shrink; prevents clipped buttons in multi-column layouts */
.rmp-products-wrapper {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}
.rmp-container .rmp-product-item {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
}
.rmp-container .rmp-details {
    min-width: 0;
    flex: 1 1 auto;
    max-width: 100%;
}

/* Category Filter — horizontal scroll when many categories */
.rmp-category-filter {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    margin: 0 auto 30px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    padding: 4px 2px 14px;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--rmp-primary) rgba(0, 0, 0, 0.05);
}
.rmp-category-filter::-webkit-scrollbar {
    height: 6px;
}
.rmp-category-filter::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}
.rmp-category-filter::-webkit-scrollbar-thumb {
    background: var(--rmp-primary);
    border-radius: 3px;
}
.rmp-filter-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    background: transparent;
    border: 2px solid var(--rmp-primary);
    color: var(--rmp-primary);
    padding: 8px 20px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    scroll-snap-align: start;
}
.rmp-filter-btn:hover, .rmp-filter-btn.active {
    background: var(--rmp-primary);
    color: #fff;
}
.rmp-product-item {
    transition: opacity 0.3s ease;
}

/* Actions row: quantity + buttons on one line */
.rmp-template-2 .rmp-actions-row {
    margin-top: 15px;
}
.rmp-template-5 .rmp-tpl5-right {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px 12px;
    flex: 1 1 auto;
    min-width: 0;
}
.rmp-template-5 .rmp-actions-row {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
}

/* Template 1: Minimal */
.rmp-template-1 {
    display: grid;
    gap: 40px;
}
.rmp-columns-2.rmp-template-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rmp-columns-3.rmp-template-1 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rmp-columns-4.rmp-template-1 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.rmp-template-1 .rmp-product-item {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.rmp-template-1 .rmp-image img {
    width: var(--rmp-image-size);
    height: var(--rmp-image-size);
    border-radius: var(--rmp-image-radius);
    object-fit: cover;
}
.rmp-template-1 .rmp-details {
    flex: 1;
}
.rmp-template-1 .rmp-header {
    display: flex;
    align-items: baseline;
    gap: 15px;
    margin-bottom: 5px;
}
.rmp-template-1 .rmp-title {
    margin: 0;
    font-weight: 600;
}
.rmp-template-1 .rmp-divider-line {
    flex: 1;
    margin-top: 15px;
}
.rmp-template-1 .rmp-price,
.rmp-template-1 .rmp-price-group .rmp-price {
    font-weight: bold;
}
.rmp-template-1 .rmp-desc {
    margin-bottom: 10px;
    line-height: 1.4;
}

/* Template 2: Card Layout */
.rmp-template-2 {
    display: grid;
    gap: 30px;
}
.rmp-columns-2.rmp-template-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rmp-columns-3.rmp-template-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rmp-columns-4.rmp-template-2 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.rmp-template-2 .rmp-product-item {
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}
.rmp-template-2 .rmp-product-item:hover {
    transform: translateY(-5px);
}
.rmp-template-2 .rmp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.rmp-template-2 .rmp-title {
    margin: 0;
    font-size: 1.2em;
}
.rmp-template-2 .rmp-price {
    font-weight: bold;
    font-size: 1.1em;
}

/* Template 3: Grid Modern */
.rmp-template-3 {
    display: grid;
    gap: 30px;
}
.rmp-columns-2.rmp-template-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rmp-columns-3.rmp-template-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rmp-columns-4.rmp-template-3 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Template 4: Elegant Dark */
.rmp-template-4 {
    display: grid;
    gap: 30px;
}
.rmp-columns-2.rmp-template-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rmp-columns-3.rmp-template-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rmp-columns-4.rmp-template-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Template 5: Compact list */
.rmp-template-5 {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.rmp-template-5 .rmp-details-left,
.rmp-template-5 .rmp-details-right {
    min-width: 0;
}

.rmp-template-1 .rmp-image {
    flex-shrink: 0;
}
.rmp-template-3 .rmp-grid-inner {
    min-width: 0;
    max-width: 100%;
}
.rmp-template-4.rmp-product-item {
    min-width: 0;
    max-width: 100%;
}

/* Desktop / laptop: keep quantity + both buttons on one line (see compact rules below) */
.rmp-actions-row {
    flex-wrap: nowrap;
    align-items: center;
    align-content: center;
}
/* Slightly smaller controls on wider screens so the row fits narrow cards */
@media (min-width: 769px) {
    .rmp-container .rmp-actions-row {
        gap: 5px 6px;
    }
    .rmp-container .rmp-actions-row .rmp-btn {
        font-size: clamp(0.7rem, 0.8vw, 0.88rem);
        padding: 5px 9px;
        line-height: 1.2;
    }
    .rmp-container .rmp-qty {
        height: min(var(--rmp-qty-height, 40px), 34px);
        flex: 0 0 auto;
    }
    .rmp-container .rmp-qty-input {
        width: min(var(--rmp-qty-input-width, 44px), 36px);
        min-width: 24px;
        font-size: 0.8em;
    }
    .rmp-container .rmp-qty-btn {
        min-width: 28px;
        padding: 0 5px;
        font-size: 1.05em;
    }
}
@media (max-width: 768px) {
    .rmp-actions-row {
        flex-wrap: wrap;
        align-content: flex-start;
    }
}

/* Tablets, Nest Hub, narrow windows: single column so cards are wide enough for qty + buttons */
@media (max-width: 1100px) {
    .rmp-products-wrapper {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    .rmp-template-1,
    .rmp-template-2,
    .rmp-template-3,
    .rmp-template-4 {
        gap: 24px;
    }
    .rmp-container {
        padding-left: max(10px, env(safe-area-inset-left, 0px));
        padding-right: max(10px, env(safe-area-inset-right, 0px));
    }
}

/* Responsive */
/* Booking Form */
.rmp-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}
.rmp-form-row > div {
    flex: 1;
}

@media (max-width: 768px) {
    .rmp-columns-2, .rmp-columns-3, .rmp-columns-4 {
        grid-template-columns: 1fr !important;
    }
    
    .rmp-template-1 .rmp-product-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .rmp-template-1 .rmp-actions-row {
        justify-content: center;
        flex-wrap: wrap;
    }
    .rmp-template-5 {
        flex-direction: column;
        align-items: flex-start !important;
    }
    .rmp-template-5 .rmp-details-right {
        margin-top: 15px;
        width: 100%;
        justify-content: flex-start;
    }
    .rmp-template-5 .rmp-tpl5-right {
        width: 100%;
        justify-content: space-between;
    }
    .rmp-template-5 .rmp-actions-row {
        width: 100%;
        justify-content: flex-start;
    }

    .rmp-actions-row {
        flex-wrap: wrap;
    }
    .rmp-template-3 .rmp-actions-row {
        flex-wrap: wrap;
    }
    
    .rmp-form-row {
        flex-direction: column;
        gap: 15px;
    }
}

/* Very small screens: keep row on one line, scroll if needed */
@media (max-width: 400px) {
    .rmp-actions-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        max-width: 100%;
    }
    .rmp-actions-row .rmp-btn {
        padding: 6px 10px;
        font-size: 0.85em;
    }
    .rmp-qty {
        flex-shrink: 0;
    }
}

/* Modal Styling */
.rmp-modal-overlay {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.rmp-modal-content {
    background-color: var(--rmp-bg);
    margin: 5% auto;
    padding: 0;
    width: 90%;
    max-width: 700px;
    border-radius: var(--rmp-radius);
    position: relative;
    animation: rmp-fadeIn 0.3s;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
@keyframes rmp-fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
.rmp-modal-close {
    color: #999;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    transition: color 0.3s;
}
.rmp-modal-close:hover,
.rmp-modal-close:focus {
    color: #333;
    text-decoration: none;
}
.rmp-modal-body {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
}
.rmp-modal-image-col {
    flex: 1 1 300px;
    display: flex;
    flex-direction: column;
    background: #f6f6f6;
    min-width: 0;
}
/* 1:1 “stage” for product photo; any aspect ratio is cropped to cover the square. */
.rmp-modal-main-image {
    width: 100%;
    max-width: min(100%, 45vh);
    margin: 10px auto 0;
    aspect-ratio: 1 / 1;
    position: relative;
    overflow: hidden;
    display: block;
    padding: 0;
    box-sizing: border-box;
    background: #e8e8e8;
    align-self: center;
}
.rmp-modal-main-image img#rmp-modal-img {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    margin: 0;
    max-width: none;
    max-height: none;
}
/* Modal: horizontally scrollable thumbs (like category filter) */
.rmp-modal-gallery-outer {
    border-top: 1px solid rgba(0,0,0,0.08);
    padding: 10px 8px 6px;
    background: #fafafa;
    margin-top: 0;
    flex: 0 0 auto;
}
.rmp-modal-gallery-scroll {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--rmp-primary) rgba(0, 0, 0, 0.05);
}
.rmp-modal-gallery-scroll::-webkit-scrollbar {
    height: 5px;
}
.rmp-modal-gallery-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}
.rmp-modal-gallery-scroll::-webkit-scrollbar-thumb {
    background: var(--rmp-primary);
    border-radius: 3px;
}
.rmp-modal-thumb {
    flex: 0 0 auto;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    width: 64px;
    height: 64px;
    background: #fff;
    cursor: pointer;
    scroll-snap-align: start;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 0;
}
.rmp-modal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    vertical-align: top;
    /* Ensure the button element receives the click (large image above updates reliably). */
    pointer-events: none;
}
.rmp-modal-thumb:hover,
.rmp-modal-thumb:focus {
    border-color: var(--rmp-primary);
    outline: none;
    box-shadow: 0 0 0 1px var(--rmp-primary);
}
.rmp-modal-thumb.is-active {
    border-color: var(--rmp-primary);
    box-shadow: 0 0 0 2px var(--rmp-primary);
}
@media (max-width: 480px) {
    .rmp-modal-thumb {
        width: 52px;
        height: 52px;
    }
}
.rmp-modal-info-col {
    flex: 1 1 300px;
    min-width: 0;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.rmp-modal-info-col .rmp-modal-actions-row,
#rmp-modal-actions.rmp-modal-actions-row {
    flex-wrap: nowrap;
    margin-top: 0;
    max-width: 100%;
    gap: 5px 6px;
}
.rmp-modal .rmp-actions-row .rmp-btn {
    font-size: clamp(0.7rem, 0.8vw, 0.88rem);
    padding: 5px 9px;
    line-height: 1.2;
}
.rmp-modal .rmp-qty {
    height: min(var(--rmp-qty-height, 40px), 34px);
    flex: 0 0 auto;
}
.rmp-modal .rmp-qty-input {
    width: min(var(--rmp-qty-input-width, 44px), 36px);
    min-width: 24px;
    font-size: 0.8em;
}
.rmp-modal .rmp-qty-btn {
    min-width: 28px;
    padding: 0 5px;
    font-size: 1.05em;
}
@media (max-width: 768px) {
    .rmp-modal-info-col .rmp-modal-actions-row,
    #rmp-modal-actions.rmp-modal-actions-row {
        flex-wrap: wrap;
    }
    .rmp-modal-content {
        margin: 10% auto;
    }
    .rmp-modal-image-col {
        min-height: 0;
    }
    .rmp-modal-main-image {
        max-width: min(100%, 38vh);
    }
    .rmp-modal-info-col {
        padding: 25px 20px;
    }
    
    /* Responsive Form adjustments */
    #rmp-booking-form > div {
        flex-direction: column !important;
        gap: 15px !important;
    }
}

