/**
 * S14.1.2 - Catalog Product Card Styles (Premium design v2)
 * Professional product card with swipe gallery, premium buttons, install badge
 * Class prefix: cc (catalog-card)
 */

/* ==========================================================================
   Card Container
   ========================================================================== */
.cc {
    display: flex;
    flex-direction: column;
    background: #fafbfc;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    position: relative;
}

.cc::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.8), rgba(20, 184, 166, 0.7), rgba(34, 197, 94, 0.6));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.cc:hover::after {
    opacity: 1;
}

.cc:hover {
    transform: translateY(-6px);
    background: #ffffff;
    border-color: rgba(15, 118, 110, 0.2);
    box-shadow: 0 12px 32px rgba(15, 118, 110, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   Media Section (Image / Gallery)
   ========================================================================== */
.cc-media-link {
    display: block;
    position: relative;
    text-decoration: none;
}

.cc-media {
    height: 340px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: transparent;
}

/* Swipe gallery strip */
.cc-media--strip {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: auto;
}

/* Ensure first image is visible on load */
.cc-media--strip .cc-media__img:first-child {
    scroll-snap-stop: always;
}

.cc-media--strip::-webkit-scrollbar {
    display: none;
}

.cc-media__img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    display: block;
}

/* S25.3-FIX: Swipe gallery images need full size */
.cc-media--strip .cc-media__img {
    flex: 0 0 100%;
    scroll-snap-align: start;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
}

/* Swipe hint (mobile only) */
.cc-swipe-hint {
    display: none;
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(55, 65, 81, 0.85);
    color: #fff;
    font-size: 10px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 10px;
    pointer-events: none;
}

@media (max-width: 768px) {
    .cc-swipe-hint {
        display: block;
    }
}

/* ==========================================================================
   Badges (Discount, Install)
   ========================================================================== */
.cc-badge {
    position: absolute;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

.cc-badge--discount {
    top: 10px;
    right: 10px;
    background: #dc2626;
    color: #fff;
}

/* S15.6 - SKU badge (compact, top-left corner) */
.cc-badge--sku {
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 9px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 3px;
}

.cc-badge--install {
    top: 10px;
    left: 10px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.cc-badge__icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* ==========================================================================
   S51.0 - Top Promo Badges (left side, stacked)
   ========================================================================== */
.cc-promo-badges {
    position: absolute;
    bottom: 36px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 3;
}

.cc-promo-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 4px;
    white-space: nowrap;
}

.cc-promo-badge__icon {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

/* Free delivery badge */
.cc-promo-badge--delivery {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: #047857;
    border: 1px solid #a7f3d0;
}

/* Turnkey badge */
.cc-promo-badge--turnkey {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

/* ==========================================================================
   Body Section
   ========================================================================== */
.cc-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 12px 14px 14px;
    gap: 6px;
}

/* Header with brand and actions */
.cc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 16px;
}

/* Brand */
.cc-brand {
    margin: 0;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
}

/* Quick actions */
.cc-quick-actions {
    display: flex;
    gap: 4px;
}

.cc-quick-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cc-quick-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.cc-quick-btn.is-active {
    background: #fef3c7;
    color: #d97706;
}

.cc-quick-btn[data-action="favorite"].is-active {
    background: #fee2e2;
    color: #dc2626;
}

.cc-quick-btn[data-action="favorite"].is-active svg {
    fill: currentColor;
}

.cc-quick-btn[data-action="compare"].is-active {
    background: #dbeafe;
    color: #2563eb;
}

.cc-quick-btn svg {
    width: 14px;
    height: 14px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    /* Always show quick actions on mobile */
    .cc-quick-actions {
        opacity: 1;
    }
    
    .cc-quick-btn {
        width: 28px;
        height: 28px;
    }
    
    .cc-quick-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* Title - compact, 3 lines max */
.cc-title {
    margin: 0;
    font-size: 14px !important;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: #1f2937;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 52px;
}

.cc-title a {
    color: inherit;
    text-decoration: none;
}

.cc-title a:hover {
    color: #374151;
}

/* ==========================================================================
   Feature Badges
   ========================================================================== */
.cc-features {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

.cc-feature {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    padding: 3px 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    color: #475569;
    white-space: nowrap;
}

.cc-feature__icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.cc-feature__label {
    line-height: 1;
}

/* Feature badge variants */
.cc-feature--area {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.cc-feature--inverter {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.cc-feature--quiet {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #065f46;
}

.cc-feature--wifi {
    background: #ede9fe;
    border-color: #c4b5fd;
    color: #5b21b6;
}

.cc-feature--self_clean {
    background: #fce7f3;
    border-color: #f9a8d4;
    color: #9d174d;
}

.cc-feature--smart_home {
    background: #cffafe;
    border-color: #67e8f9;
    color: #0e7490;
}

.cc-feature--free_delivery {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

/* S15.6 - Energy class badge (A+, A++, A+++) */
.cc-feature--energy_class {
    background: #fef9c3;
    border-color: #fde047;
    color: #854d0e;
}

/* S50.0 - Additional feature badges */
.cc-feature--cooling_energy_class {
    background: #e0f2fe;
    border-color: #7dd3fc;
    color: #0369a1;
}

.cc-feature--ionizer {
    background: #fae8ff;
    border-color: #e879f9;
    color: #86198f;
}

.cc-feature--air_purifier {
    background: #ecfccb;
    border-color: #bef264;
    color: #3f6212;
}

.cc-feature--pump {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.cc-feature--dehumidify {
    background: #f0fdfa;
    border-color: #5eead4;
    color: #0f766e;
}

.cc-feature--night_mode {
    background: #eef2ff;
    border-color: #a5b4fc;
    color: #4338ca;
}

.cc-feature--plasma {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #b45309;
}

.cc-feature--i_feel {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.cc-feature--4d_flow {
    background: #fff7ed;
    border-color: #fdba74;
    color: #c2410c;
}

/* S50.0 - "ещё +N" badge button */
.cc-feature--more {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid #cbd5e1;
    font-family: inherit;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1;
}

.cc-feature--more:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #334155;
}

.cc-feature--more.is-active {
    background: #e2e8f0;
    border-color: #64748b;
    color: #1e293b;
}

/* S50.0 - Hidden badges popover */
.cc-features-popover {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 50;
    margin-top: 4px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.cc-features-popover[hidden] {
    display: none;
}

.cc-features-popover.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cc-features-popover__content {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

/* ==========================================================================
   Price Block
   ========================================================================== */
.cc-price-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
    padding-top: 8px;
}

.cc-price-block:not(.cc-price-block--personal):not(.cc-price-block--request) {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
}

/* Price on request styling */
.cc-price-block--request {
    flex-direction: row;
    align-items: center;
}

.cc-price--request {
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #fcd34d;
}

.cc-price,
.cc-price--current {
    font-size: 17px;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.02em;
}

.cc-price--old {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: line-through;
    order: -1;
}

/* ==========================================================================
   Personal Discount Price Display (РЦ + Ваша цена)
   ========================================================================== */
.cc-price--rc {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 12px;
    color: #9ca3af;
}

.cc-price--rc-label {
    font-weight: 500;
}

.cc-price--rc-value {
    /* Не зачёркиваем РЦ - просто показываем для сравнения */
}

.cc-price--personal {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.cc-price--personal-label {
    font-size: 11px;
    font-weight: 500;
    color: #059669;
}

.cc-price--personal-value {
    font-size: 17px;
    font-weight: 800;
    color: #059669;
    letter-spacing: -0.02em;
}

/* Status after personal price block */
.cc-price-block--personal .cc-status {
    margin-top: 4px;
}

/* ==========================================================================
   Status
   ========================================================================== */
.cc-status {
    margin: 0;
    font-size: 11px;
    font-weight: 600;
}

.cc-status--in-stock {
    color: #059669;
}

/* ==========================================================================
   Actions (Premium Buttons)
   ========================================================================== */
.cc-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.cc-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

/* Primary button - soft blue accent */
.cc-btn--primary {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}

.cc-btn--primary:hover {
    background: #bae6fd;
    border-color: #38bdf8;
    color: #0c4a6e;
}

/* Primary button - added state (success feedback) */
.cc-btn--primary.is-added {
    background: #10b981;
    color: #ffffff;
    border-color: #10b981;
    animation: btnAddedPulse 1.5s ease forwards;
}

/* Primary button - in cart state (persistent) */
.cc-btn--primary.is-in-cart {
    background: #059669;
    color: #ffffff;
    border-color: #059669;
}

.cc-btn--primary.is-in-cart:hover {
    background: #047857;
    border-color: #047857;
}

/* Quote button - for products without price */
.cc-btn--quote {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #fbbf24;
    font-weight: 500;
}

.cc-btn--quote:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
    border-color: #f59e0b;
    color: #78350f;
}

@keyframes btnAddedPulse {
    0% { transform: scale(1); }
    20% { transform: scale(1.05); }
    40% { transform: scale(1); }
    100% { transform: scale(1); }
}

/* Secondary button - outline, neutral */
.cc-btn--secondary {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.cc-btn--secondary:hover {
    background: #f9fafb;
    border-color: #374151;
    color: #1f2937;
}

/* ==========================================================================
   Grid Layout
   ========================================================================== */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

/* ==========================================================================
   Responsive - Mobile (professional horizontal cards)
   ========================================================================== */
@media (max-width: 640px) {
    /* Grid: 1 card per row */
    .catalog-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Card: horizontal layout */
    .cc {
        flex-direction: row;
        border-radius: 12px;
        min-height: 140px;
    }

    .cc:hover {
        transform: none;
    }

    .cc::after {
        display: none;
    }

    /* Image section: left side, fixed width */
    .cc-media-link {
        flex: 0 0 130px;
        width: 130px;
    }

    .cc-media {
        height: 100%;
        min-height: 140px;
        padding: 8px;
    }

    .cc-media__img {
        max-width: 100%;
        max-height: 120px;
    }

    /* Badges: smaller, repositioned */
    .cc-badge {
        font-size: 8px;
        padding: 2px 5px;
    }

    .cc-badge--sku {
        bottom: 6px;
        left: 6px;
        font-size: 8px;
        padding: 2px 4px;
    }

    .cc-badge--discount {
        top: 6px;
        right: auto;
        left: 6px;
    }

    .cc-badge--install {
        top: 6px;
        left: 6px;
    }

    /* S51.0 - Promo badges: compact for mobile */
    .cc-promo-badges {
        bottom: 28px;
        left: 4px;
        gap: 2px;
    }

    .cc-promo-badge {
        font-size: 7px;
        padding: 2px 4px;
        border-radius: 3px;
    }

    .cc-promo-badge__icon {
        width: 8px;
        height: 8px;
    }

    /* Body: right side, flex-grow */
    .cc-body {
        flex: 1;
        padding: 10px 12px;
        gap: 4px;
        justify-content: space-between;
    }

    /* Header with brand & actions */
    .cc-header {
        min-height: auto;
    }

    /* Brand: soft capsule badge style */
    .cc-brand {
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.3px;
        color: #374151;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        padding: 3px 8px;
        border-radius: 4px;
        border: 1px solid #e2e8f0;
        display: inline-block;
    }

    .cc-quick-actions {
        gap: 2px;
    }

    .cc-quick-btn {
        width: 26px;
        height: 26px;
    }

    .cc-quick-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Title: 2-3 lines, readable */
    .cc-title {
        font-size: 13px !important;
        line-height: 1.25;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        min-height: auto;
        margin-bottom: 2px;
    }

    /* Feature badges: show max 3 */
    .cc-features {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .cc-feature {
        font-size: 10px;
        padding: 3px 6px;
    }

    .cc-feature__icon {
        width: 10px;
        height: 10px;
    }

    .cc-feature__label {
        font-size: 9px;
    }

    /* Hide 4th and beyond features, but keep "more" button visible */
    .cc-feature:nth-child(n+4):not(.cc-feature--more) {
        display: none;
    }

    /* S50.0 - Mobile: always show "ещё" button */
    .cc-feature--more {
        display: inline-flex !important;
    }

    /* S50.0 - Mobile: popover becomes inline expanded block */
    .cc-features-popover {
        position: static;
        margin-top: 4px;
        width: 100%;
        border: none;
        box-shadow: none;
        padding: 0;
        transform: none;
        background: transparent;
    }

    .cc-features-popover.is-open {
        transform: none;
    }

    .cc-features-popover__content {
        gap: 4px;
    }

    .cc-features-popover .cc-feature {
        display: inline-flex !important;
    }

    /* Price block */
    .cc-price-block {
        margin: 2px 0;
    }

    .cc-price {
        font-size: 16px;
        font-weight: 700;
    }

    .cc-price--old {
        font-size: 11px;
    }

    .cc-status {
        font-size: 10px;
    }

    /* Actions: row layout, compact */
    .cc-actions {
        flex-direction: row;
        gap: 6px;
        margin-top: auto;
    }

    .cc-btn {
        flex: 1;
        padding: 8px 10px;
        font-size: 11px;
        border-radius: 6px;
    }

    .cc-btn svg {
        width: 14px;
        height: 14px;
        margin-right: 4px !important;
    }

    .cc-btn--secondary {
        flex: 0 0 auto;
        padding: 8px 12px;
    }
}

/* ==========================================================================
   S25.X - Premium Hover Image Effect ("живое" фото)
   Плавное вращение при наведении - показывает товар с разных сторон
   ========================================================================== */

/* Подготовка 3D контекста на контейнере */
.cc .cc-media {
    perspective: 1000px;
    transform-style: preserve-3d;
}

/* Плавный transition для изображения */
.cc .cc-media__img {
    transition: transform 0.6s ease-in-out;
    will-change: transform;
    backface-visibility: hidden;
}

/* Hover эффект только на desktop с мышью - плавное вращение */
@media (hover: hover) and (pointer: fine) {
    .cc:hover .cc-media__img {
        animation: productRotate 3s ease-in-out infinite;
    }
}

/* Анимация вращения - показывает товар с разных сторон */
@keyframes productRotate {
    0% {
        transform: rotateY(0deg) scale(1.02);
    }
    25% {
        transform: rotateY(8deg) scale(1.03);
    }
    50% {
        transform: rotateY(0deg) scale(1.02);
    }
    75% {
        transform: rotateY(-8deg) scale(1.03);
    }
    100% {
        transform: rotateY(0deg) scale(1.02);
    }
}

/* Отключить на тач-устройствах */
@media (hover: none) {
    .cc .cc-media__img {
        transform: none !important;
        animation: none !important;
    }
}

/* Отключить для пользователей с reduced motion */
@media (prefers-reduced-motion: reduce) {
    .cc .cc-media__img {
        transition: none !important;
        transform: none !important;
        animation: none !important;
    }
}