/**
 * Public Catalog Styles — [modual_catalog]
 * @package Modual_Configurator
 */

/* ================================
   LAYOUT
================================ */
.mc-catalog {
    font-family: var(--wp--preset--font-family--body, 'Montserrat', sans-serif);
    min-height: 100vh;
}
.mc-catalog-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px;
}

.mc-catalog-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--wp--preset--color--grey-700);
    margin: 0 0 20px;
}

/* ================================
   FILTER BAR
================================ */
.mc-catalog-filters-wrap {
    /* structural wrapper — style as needed */
    display: block;
    position: sticky;
    top: 83px;
    z-index: 2;
    background: var(--wp--preset--color--white);
    padding: 8px 0 4px 0;
    margin: 0 0 20px 0;
}

.mc-catalog-filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--wp--preset--color--grey-50, #f7f7f7);
    border-radius: 2px;
    z-index: 50;
}

/* Mobile collapse toggle (hidden on desktop) — matches the filter panel */
.mc-catalog-filter-toggle {
    display: none;
    width: 100%;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border: none;
    border-radius: 2px;
    background: var(--wp--preset--color--grey-50, #f7f7f7);
    color: var(--wp--preset--color--grey-700, #333);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.mc-catalog-filter-toggle i[data-lucide="sliders-horizontal"] {
    width: 18px;
    height: 18px;
    color: var(--wp--preset--color--primary, #2e5efc);
}

.mc-catalog-filter-toggle-label {
    flex: 1 1 auto;
    text-align: left;
}

.mc-catalog-filter-toggle-chevron {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.mc-catalog-filter-toggle[aria-expanded="true"] .mc-catalog-filter-toggle-chevron {
    transform: rotate(180deg);
}

.mc-catalog-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mc-catalog-filter-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--wp--preset--color--grey-500, #7a7a7c);
    letter-spacing: 0.5px;
}

/* Styled select with leading Lucide icon */
.mc-catalog-select-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.mc-catalog-select-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--wp--preset--color--grey-500, #7a7a7c);
    pointer-events: none;
}

.mc-catalog-filter-group select {
    appearance: none;
    -webkit-appearance: none;
    padding: 9px 34px 9px 36px;
    border: 1px solid var(--wp--preset--color--grey-300, #dee2e6);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--wp--preset--color--grey-700, #333);
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a7a7c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    min-width: 150px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.mc-catalog-filter-group select:hover {
    border-color: var(--wp--preset--color--primary, #2e5efc);
}

.mc-catalog-filter-group select:focus {
    outline: none;
    border-color: var(--wp--preset--color--primary, #2e5efc);
    box-shadow: 0 0 0 3px rgba(46, 94, 252, 0.15);
}

/* Tag pills (single-select per group) */
.mc-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mc-filter-pill {
    padding: 7px 16px;
    border: 1px solid var(--wp--preset--color--grey-300, #dee2e6);
    border-radius: 999px;
    background: #fff;
    color: var(--wp--preset--color--grey-700, #333);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.mc-filter-pill:hover {
    border-color: var(--wp--preset--color--primary, #2e5efc);
    color: var(--wp--preset--color--primary, #2e5efc);
}

.mc-filter-pill.is-active {
    background: var(--wp--preset--color--primary, #2e5efc);
    border-color: var(--wp--preset--color--primary, #2e5efc);
    color: var(--wp--preset--color--white, #fff);
}

.mc-filter-pill:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 94, 252, 0.25);
}

/* ================================
   PRODUCT GRID
================================ */
.mc-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(325px, 1fr));
    gap: 20px;
}

/* ================================
   PRODUCT CARD
================================ */
.mc-catalog-card {
    background: #fff;
    border: 1px solid #CCCCCC;
    border-radius: 2px;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    display: flex;
    width: 100%;
    min-width: 325px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
    opacity: 0;
}

/* Entry animation — applied by JS only once products have loaded */
.mc-catalog-card.mc-animate-in {
    animation: mc-card-in 0.35s ease both;
}

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

@media (prefers-reduced-motion: reduce) {
    .mc-catalog-card {
        opacity: 1;
        animation: none;
    }
}

.mc-catalog-card:hover {
    border-color: #2E5EFC;
}

.mc-catalog-card:hover .mc-catalog-card-image-gradient::after {
    opacity: 1;
}

.mc-catalog-card-image {
    align-self: stretch;
    height: 50%;
    padding: 16px;
    position: relative;
    background: #fff;
    overflow: hidden;
    border-bottom: 1px solid #CCCCCC;
    justify-content: center;
    align-items: center;
    display: inline-flex;
    box-sizing: border-box;
}

.mc-catalog-card-image-gradient {
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    position: absolute;
    opacity: 0.5;
    background: linear-gradient(43deg, #F3F3F3 0%, rgba(243, 243, 243, 0) 100%);
    pointer-events: none;
}

.mc-catalog-card-image-gradient::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(43deg, #bdd1ff 0%, rgba(46, 94, 252, 0) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mc-catalog-card-header {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}

.mc-catalog-image {
    flex: 1 1 0;
    align-self: stretch;
    position: relative;
    object-fit: contain;
    max-width: 100%;
}

.mc-catalog-image-placeholder {
    flex: 1 1 0;
    align-self: stretch;
    background: #f7f7f7;
}

.mc-catalog-card-body {
    align-self: stretch;
    padding: 24px;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    display: flex;
    box-sizing: border-box;
    flex: 1;
}

.mc-catalog-card-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mc-catalog-card-title-area {
    align-self: stretch;
    display: flex;
    flex-direction: column;
}

.mc-catalog-card-title-row {
    align-self: stretch;
    justify-content: space-between;
    align-items: flex-start;
    display: inline-flex;
    gap: 8px;
}

.mc-catalog-product-name {
    color: var(--wp--preset--color--grey-700, #1A1C1C);
    font-size: 1.25rem;
    font-family: var(--wp--preset--font-family--body, 'Montserrat', sans-serif);
    font-weight: 400;
    line-height: 1.3;
    word-break: break-word;
}

.mc-catalog-card-desc {
    color: var(--wp--preset--color--grey-500, #6B7280);
    font-size: 0.875rem;
    font-family: var(--wp--preset--font-family--body, 'Montserrat', sans-serif);
    font-weight: 400;
    line-height: 1.45;
    /* Truncate to fit the card layout regardless of length */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mc-catalog-badge-group {
    display: flex;
    flex-direction: row;
    align-items: start;
    gap: 0.5rem;
}

.mc-catalog-category-badge {
    padding: 4px 8px;
    background: #EEEEEE;
    color: #404042;
    font-size: 12px;
    font-family: var(--wp--preset--font-family--body, 'Montserrat', sans-serif);
    font-weight: 400;
    text-transform: uppercase;
    line-height: 18px;
    letter-spacing: 0.6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.mc-catalog-card-footer {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ================================
   PRICE DISPLAY
================================ */
.mc-catalog-price-section {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mc-catalog-price-main {
    color: #1A1C1C;
    font-size: 24px;
    font-weight: 700;
    font-family: var(--wp--preset--font-family--body, 'Montserrat', sans-serif);
    line-height: 36px;
    word-break: break-word;
}

.mc-catalog-price-sub {
    color: #404042;
    font-size: 12px;
    font-weight: 400;
    font-family: var(--wp--preset--font-family--body, 'Montserrat', sans-serif);
    line-height: 18px;
}

.mc-catalog-price-badge {
    display: inline-block;
    font-size: 10px;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 700;
}

/* ================================
   CARD ACTIONS
================================ */
.mc-catalog-actions {
    align-self: stretch;
    display: flex;
    flex-direction: column;
}

.mc-catalog-btn-configure {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px 12px;
    border: 1px solid rgba(10, 10, 10, 0.16);
    background: #404042;
    color: #FFFFFF;
    font-size: 14px;
    font-family: var(--wp--preset--font-family--body, 'Montserrat', sans-serif);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
    width: 100%;
    border-radius: 2px;
    transition: background 0.2s ease;
}

.mc-catalog-btn-configure svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.mc-catalog-btn-configure span {
    overflow: hidden;
    white-space: nowrap;
    max-width: 150px;
    opacity: 1;
    transition: opacity 0.18s ease, max-width 0.22s ease;
}

.mc-catalog-btn-configure[data-state="loading"] span,
.mc-catalog-btn-configure[data-state="success"] span,
.mc-catalog-btn-configure[data-state="error"] span {
    opacity: 0;
    max-width: 0;
}

/* ── Hover ── */
.mc-catalog-btn-configure:hover:not(:disabled):not([data-state="loading"]) {
    background: #58585a;
}

.mc-catalog-card:hover .mc-catalog-btn-configure:not(:disabled):not([data-state="loading"]):not([data-state="success"]):not([data-state="error"]) {
    background: #2E5EFC;
}

/* ── Disabled ── */
.mc-catalog-btn-configure:disabled,
.mc-catalog-btn-configure[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Loading: cart icon only, pulse ── */
.mc-catalog-btn-configure[data-state="loading"] {
    cursor: wait;
}

.mc-catalog-btn-configure[data-state="loading"] svg {
    animation: mc-cart-pulse 0.9s ease-in-out infinite alternate;
}

/* ── Icon-only states: slightly larger icon ── */
.mc-catalog-btn-configure[data-state="loading"] svg,
.mc-catalog-btn-configure[data-state="success"] svg,
.mc-catalog-btn-configure[data-state="error"] svg {
    width: 18px;
    height: 18px;
}

/* ── Success: green background + check icon pop ── */
.mc-catalog-btn-configure[data-state="success"] {
    background: #2e7d32;
}

.mc-catalog-btn-configure[data-state="success"] svg {
    animation: mc-icon-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Error: red background + horizontal shake ── */
.mc-catalog-btn-configure[data-state="error"] {
    background: #c62828;
    animation: mc-btn-shake 0.45s ease;
}

/* ── Keyframes ── */
@keyframes mc-cart-pulse {
    from { opacity: 1;   transform: scale(1); }
    to   { opacity: 0.4; transform: scale(0.8); }
}

@keyframes mc-icon-pop {
    0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
    65%  { transform: scale(1.35) rotate(5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes mc-btn-shake {
    0%, 100% { transform: translateX(0);    }
    20%      { transform: translateX(-5px); }
    40%      { transform: translateX(5px);  }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(3px);  }
}

.mc-catalog-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--wp--preset--font-family--body, 'Montserrat', sans-serif);
    cursor: pointer;
    border: none;
    transition: background 0.2s;
    text-decoration: none;
    background: #efefef;
    color: var(--wp--preset--color--grey-700, #404042);
    box-sizing: border-box;
}

.mc-catalog-btn:hover:not(:disabled) {
    background: #e0e0e0;
}

.mc-catalog-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mc-catalog-btn-success {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
}

.mc-catalog-cart-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--wp--preset--color--grey-700, #404042);
    text-decoration: none;
    transition: color 0.2s;
    margin-top: 8px;
}

.mc-catalog-cart-link:hover {
    color: #2a2a4e;
    text-decoration: underline;
}

/* ================================
   STOCK BADGES
================================ */
.mc-stock-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.mc-stock-ok {
    background: #e8f5e9;
    color: #2e7d32;
}

.mc-stock-low {
    background: #fff3e0;
    color: #e65100;
}

.mc-stock-out {
    background: #fce4ec;
    color: #c62828;
}

/* ================================
   LOADING / EMPTY / ERROR
================================ */
.mc-catalog-loading,
.mc-catalog-empty,
.mc-catalog-error {
    text-align: center;
    padding: 40px;
    color: var(--wp--preset--color--grey-500, #7a7a7c);
    font-size: 15px;
    grid-column: 1 / -1;
}

.mc-catalog-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.mc-catalog-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--wp--preset--color--grey-200, #e5e5e5);
    border-top-color: var(--wp--preset--color--primary, #2e5efc);
    border-radius: 50%;
    animation: mc-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .mc-catalog-spinner {
        animation-duration: 1.6s;
    }
}

/* ================================
   TIER WIDGET
================================ */
.mc-tier-widget {
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, var(--wp--preset--color--grey-700, #404042) 0%, var(--wp--preset--color--grey-700, #404042) 100%);
    color: #fff;
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.mc-tier-status {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.mc-tier-icon {
    font-size: 24px;
}

.mc-tier-info {
    display: flex;
    flex-direction: column;
}

.mc-tier-info strong {
    font-size: 16px;
}

.mc-tier-info span {
    font-size: 13px;
    color: #7dd87d;
}

.mc-tier-progress {
    flex: 1;
    min-width: 0;
}

.mc-tier-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.mc-tier-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #7dd87d, #4caf50);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.mc-tier-progress small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

/* ================================
   NOTICES
================================ */
.mc-catalog-notice {
    padding: 16px 20px;
    border-radius: 2px;
    margin-bottom: 24px;
}

.mc-catalog-notice-pending {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.mc-catalog-notice-guest {
    background: var(--wp--preset--color--primary);
    color: var(--wp--preset--color--white);
}

.mc-catalog-notice p {
    margin: 6px 0 12px;
}

.mc-catalog-card--linked {
    cursor: pointer;
}

/* ================================
   BUTTON EXTRAS
================================ */
.mc-catalog-btn-outline {
    background: transparent;
    border: 1px solid #dee2e6;
    color: #495057;
}

.mc-catalog-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ================================
   UTILITY
================================ */
.mc-hidden {
    display: none !important;
}

/* ================================
   RESPONSIVE
================================ */
@media (max-width: 768px) {
    .mc-catalog-filter-toggle {
        display: flex;
    }

    .mc-catalog-filters {
        flex-direction: column;
        align-items: stretch;
        overflow: hidden;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-top: 0;
        opacity: 0;
        transition: max-height 0.3s ease, opacity 0.25s ease,
                    padding 0.3s ease, margin 0.3s ease;
    }

    .mc-catalog-filters.is-open {
        max-height: 1000px;
        padding-top: 14px;
        padding-bottom: 14px;
        margin-top: 8px;
        opacity: 1;
    }

    .mc-catalog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Let cards shrink to fit their grid cells (override the 325px base
       min-width, which otherwise overflows the narrower tablet columns) and
       cap card height so cards never exceed 75% of the viewport. */
    .mc-catalog-card {
        min-width: 0;
        max-height: 75vh;
        overflow: hidden;
    }

    .mc-tier-widget {
        flex-direction: column;
        text-align: center;
    }

}

@media (max-width: 600px) {
    /* Single column on phones */
    .mc-catalog-grid {
        grid-template-columns: 1fr;
    }
}
