/**
 * Pre-built Products Widget styles.
 * Self-contained — uses BEM naming under .ms-products to avoid clashing
 * with whatever CSS the AI-generated page already has.
 *
 * Theme: respects the host page's accent color via --ms-accent if defined
 * on :root, otherwise falls back to a neutral gold.
 */

:root {
    --ms-accent: var(--accent-color, #c89b3c);
    --ms-text:   #1f2937;
    --ms-muted:  #6b7280;
    --ms-bg:     #ffffff;
    --ms-border: #e5e7eb;
    --ms-shadow: 0 2px 6px rgba(0,0,0,0.06);
    --ms-shadow-hover: 0 8px 24px rgba(0,0,0,0.10);
    --ms-radius: 12px;
}

/* Wrapper */
.ms-products {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 16px;
    box-sizing: border-box;
    font-family: inherit;
    color: var(--ms-text);
}

/* ── Search ───────────────────────────────────────────────────────────── */
.ms-products__search {
    margin: 0 0 24px;
    display: flex;
    justify-content: center;
}
.ms-products__search-input {
    width: 100%;
    max-width: 480px;
    padding: 12px 16px;
    border: 1px solid var(--ms-border);
    border-radius: 999px;
    font-size: 14px;
    font-family: inherit;
    background: var(--ms-bg);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.ms-products__search-input:focus {
    outline: none;
    border-color: var(--ms-accent);
    box-shadow: 0 0 0 3px rgba(200,155,60,0.15);
}

/* ── List container — varies by layout ────────────────────────────────── */

/* GRID (default) */
.ms-products--grid .ms-products__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

/* LIST */
.ms-products--list .ms-products__list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.ms-products--list .ms-products__card {
    flex-direction: row;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}
.ms-products--list .ms-products__img-wrap {
    width: 220px;
    flex-shrink: 0;
    aspect-ratio: 4 / 3;
}
.ms-products--list .ms-products__body {
    flex: 1;
}
.ms-products--list .ms-products__footer {
    border-top: none;
    padding-top: 0;
}
@media (max-width: 640px) {
    .ms-products--list .ms-products__card {
        flex-direction: column;
    }
    .ms-products--list .ms-products__img-wrap {
        width: 100%;
        aspect-ratio: 16 / 10;
    }
}

/* CAROUSEL */
.ms-products--carousel .ms-products__list {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 4px 4px 16px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--ms-accent) transparent;
}
.ms-products--carousel .ms-products__card {
    flex: 0 0 280px;
    scroll-snap-align: start;
}
.ms-products--carousel .ms-products__list::-webkit-scrollbar {
    height: 8px;
}
.ms-products--carousel .ms-products__list::-webkit-scrollbar-thumb {
    background: var(--ms-accent);
    border-radius: 4px;
}

/* FEATURED-STRIP — compact horizontal */
.ms-products--featured-strip .ms-products__list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 4px 12px;
    scroll-snap-type: x mandatory;
}
.ms-products--featured-strip .ms-products__card {
    flex: 0 0 200px;
    scroll-snap-align: start;
}
.ms-products--featured-strip .ms-products__name {
    font-size: 0.95rem;
}
.ms-products--featured-strip .ms-products__desc {
    display: none;
}
.ms-products--featured-strip .ms-products__img-wrap {
    aspect-ratio: 1 / 1;
}

/* ── Card ─────────────────────────────────────────────────────────────── */
.ms-products__card {
    display: flex;
    flex-direction: column;
    background: var(--ms-bg);
    border: 1px solid var(--ms-border);
    border-radius: var(--ms-radius);
    overflow: hidden;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    box-shadow: var(--ms-shadow);
}
.ms-products__card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ms-shadow-hover);
    border-color: var(--ms-accent);
}
.ms-products__card.is-disabled {
    opacity: 0.55;
}
.ms-products__card.is-disabled:hover {
    transform: none;
    border-color: var(--ms-border);
    box-shadow: var(--ms-shadow);
}

.ms-products__img-wrap {
    position: relative;
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    overflow: hidden;
}
.ms-products__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s;
}
.ms-products__card:hover .ms-products__img {
    transform: scale(1.05);
}

.ms-products__ribbon {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--ms-accent);
    color: #fff;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 2;
}

.ms-products__badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    color: #fff;
    z-index: 2;
}
.ms-products__badge--out          { background: #dc2626; }
.ms-products__badge--preorder     { background: #2563eb; }
.ms-products__badge--discontinued { background: #6b7280; }

.ms-products__body {
    padding: 14px 16px;
    flex: 1;
}
.ms-products__name {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ms-text);
}
.ms-products__desc {
    margin: 0 0 10px;
    font-size: 0.875rem;
    color: var(--ms-muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Price */
.ms-products__price {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.ms-products__price-current {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ms-text);
}
.ms-products__price-original {
    font-size: 0.875rem;
    color: var(--ms-muted);
    text-decoration: line-through;
}
.ms-products__price-badge {
    background: #dc2626;
    color: #fff;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.ms-products__price--contact {
    color: var(--ms-accent);
    font-weight: 600;
    font-size: 0.95rem;
}

/* Footer + button */
.ms-products__footer {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--ms-border);
}
.ms-products__btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--ms-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.ms-products__btn:hover:not(:disabled) {
    filter: brightness(0.92);
    transform: translateY(-1px);
}
.ms-products__btn:active:not(:disabled) {
    transform: translateY(0);
}
.ms-products__btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ── States: loading / empty / error ──────────────────────────────────── */
.ms-products__state {
    text-align: center;
    padding: 60px 20px;
    color: var(--ms-muted);
    font-size: 1rem;
}
.ms-products__state p {
    margin: 12px 0 0;
}
.ms-products__spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto;
    border: 3px solid var(--ms-border);
    border-top-color: var(--ms-accent);
    border-radius: 50%;
    animation: ms-products-spin 0.9s linear infinite;
}
@keyframes ms-products-spin {
    to { transform: rotate(360deg); }
}
.ms-products__empty-icon,
.ms-products__error-icon {
    font-size: 3rem;
    line-height: 1;
}
.ms-products__error small {
    display: block;
    margin-top: 8px;
    font-size: 0.8rem;
    color: #ef4444;
    opacity: 0.85;
    word-break: break-word;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Responsive tweaks ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .ms-products {
        padding: 20px 12px;
    }
    .ms-products--grid .ms-products__list {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
    .ms-products__name {
        font-size: 0.95rem;
    }
    .ms-products__desc {
        -webkit-line-clamp: 2;
        font-size: 0.8rem;
    }
    .ms-products__price-current {
        font-size: 1rem;
    }
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Modal: product details (.ms-pmodal__*)                                  */
/* Opened by products.js when the user clicks "Մանրամասներ" on a card.    */
/* ─────────────────────────────────────────────────────────────────────── */

.ms-pmodal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
    animation: ms-pmodal-fade 0.18s ease;
}
@keyframes ms-pmodal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes ms-pmodal-slide {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.ms-pmodal {
    background: #fff;
    border-radius: 12px;
    max-width: 960px;
    width: 100%;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    animation: ms-pmodal-slide 0.22s ease;
    font-family: inherit;
    color: #1f2937;
}

/* Header */
.ms-pmodal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.ms-pmodal__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}
.ms-pmodal__close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 6px;
    transition: background 0.15s;
    font-family: inherit;
}
.ms-pmodal__close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

/* Body + 2-column layout */
.ms-pmodal__body {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}
.ms-pmodal__layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 24px;
    /* Stretch both columns so they share a height — enables CTA pinning. */
    align-items: stretch;
}
@media (max-width: 720px) {
    .ms-pmodal__layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Gallery (left side) */
.ms-pmodal__gallery {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    /* Don't stretch the gallery if the info column is taller (long description).
       Without this the gallery would have empty space below the image. */
    align-self: start;
}
.ms-pmodal__main {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #f3f4f6;
    border-radius: 10px;
    display: block;
    min-height: 0;
}
.ms-pmodal__thumbs {
    display: flex;
    flex-wrap: wrap;       /* wrap to next row instead of horizontal scroll */
    gap: 8px;
    padding: 2px;
}
.ms-pmodal__thumb {
    width: 72px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, opacity 0.15s;
    flex-shrink: 0;
}
.ms-pmodal__thumb:hover {
    opacity: 0.85;
}
.ms-pmodal__thumb.is-active {
    border-color: var(--ms-accent, #c89b3c);
}

/* Info (right side) */
.ms-pmodal__info {
    min-width: 0;
    /* Flex column so the CTA can use margin-top:auto to stick to the bottom,
       keeping the button in a fixed position regardless of description length. */
    display: flex;
    flex-direction: column;
}
.ms-pmodal__name {
    margin: 0 0 8px;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.25;
}
.ms-pmodal__category {
    display: inline-block;
    align-self: flex-start;
    background: #f3f4f6;
    color: #4b5563;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    margin-bottom: 14px;
}

/* Price block */
.ms-pmodal__price {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin: 6px 0 16px;
}
.ms-pmodal__price-current {
    font-size: 1.5rem;
    font-weight: 700;
}
.ms-pmodal__price-original {
    font-size: 1rem;
    color: #6b7280;
    text-decoration: line-through;
}
.ms-pmodal__price-badge {
    background: #dc2626;
    color: #fff;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.ms-pmodal__price--contact {
    color: var(--ms-accent, #c89b3c);
    font-weight: 600;
    font-size: 1rem;
}

/* Stock badge */
.ms-pmodal__stock {
    display: inline-block;
    align-self: flex-start;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 14px;
}
.ms-pmodal__stock--in           { background: #16a34a; }
.ms-pmodal__stock--out          { background: #dc2626; }
.ms-pmodal__stock--preorder     { background: #2563eb; }
.ms-pmodal__stock--discontinued { background: #6b7280; }

/* Description */
.ms-pmodal__section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9ca3af;
    margin: 18px 0 8px;
}
.ms-pmodal__desc {
    color: #374151;
    line-height: 1.65;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* CTA (always pinned to bottom of the info column) */
.ms-pmodal__cta {
    margin-top: auto;       /* ← pushes button to the bottom */
    padding: 12px 22px;
    background: var(--ms-accent, #c89b3c);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
    font-family: inherit;
    align-self: flex-start; /* don't stretch full-width inside the flex column */
}
.ms-pmodal__cta:hover:not(:disabled) {
    filter: brightness(0.92);
}
.ms-pmodal__cta:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading + error states */
.ms-pmodal__loading,
.ms-pmodal__error {
    text-align: center;
    padding: 50px 20px;
    color: #6b7280;
}
.ms-pmodal__error small {
    display: block;
    margin-top: 8px;
    color: #ef4444;
    font-size: 0.8rem;
}
