/* catalog.css — раздел каталог / поиск товаров в дизайне яснаб.рф
   Использует переменные из variables.css (--primary, --dark, --gray-light...) */

/* Контейнер как в яснаб.рф (max-width: 1200px; margin: 0 auto) */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}
@media (max-width: 768px) {
    .container { padding: 0 16px; }
}

.page-catalog { background: var(--light); }

/* ========== Главная (catalog-home) ========== */
.catalog-hero {
    background: linear-gradient(135deg, var(--dark) 0%, #2a2a4e 50%, var(--primary) 130%);
    color: var(--white);
    padding: 80px 0 100px;
    position: relative;
    overflow: hidden;
}
.catalog-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 50%, rgba(229, 57, 53, 0.18), transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(21, 101, 192, 0.15), transparent 50%);
    pointer-events: none;
    z-index: 0;
}
.catalog-hero .container { position: relative; z-index: 1; }
.catalog-hero h1, .catalog-hero .hero-sub, .catalog-hero .hero-badges, .catalog-hero .hero-search, .catalog-hero .hero-suggestions { position: relative; z-index: 1; }
.catalog-hero h1 {
    font-size: clamp(36px, 5vw, 56px);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}
.catalog-hero .hero-sub {
    font-size: clamp(16px, 2vw, 20px);
    opacity: 0.9;
    max-width: 640px;
    margin-bottom: 36px;
    line-height: 1.5;
}
.catalog-hero .hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 28px;
}
.hero-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    backdrop-filter: blur(8px);
}

.hero-search {
    background: var(--white);
    border-radius: 16px;
    padding: 8px;
    display: flex;
    gap: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 720px;
    position: relative;
}
.hero-search input {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px 20px;
    font-size: 17px;
    color: var(--dark);
    background: transparent;
    font-family: inherit;
}
.hero-search input::placeholder { color: var(--gray); }
.hero-search button {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 0 32px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}
.hero-search button:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* Suggestions under hero search */
.hero-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    align-items: center;
}
.hero-suggestions .label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    margin-right: 4px;
}
.hero-suggestions a {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--white);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    text-decoration: none;
    transition: var(--transition);
}
.hero-suggestions a:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Features */
.catalog-features {
    padding: 64px 0;
    background: var(--white);
}
.section-title {
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}
.section-sub {
    color: var(--gray);
    font-size: 16px;
    margin-bottom: 40px;
    max-width: 600px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}
.feature-card {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: 16px;
    padding: 28px 24px;
    transition: var(--transition);
}
.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(229, 57, 53, 0.1);
}
.feature-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}
.feature-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}
.feature-card p {
    color: var(--gray);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

/* Categories */
.catalog-categories {
    padding: 64px 0;
    background: var(--light);
}
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.category-chip {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--dark);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.category-chip:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    color: var(--primary-dark);
}
.category-chip .cat-emoji { font-size: 32px; }
.category-chip .cat-name {
    font-size: 14px;
    font-weight: 600;
}

/* ========== Каталог (catalog-list) ========== */
.catalog-main {
    padding: calc(var(--header-offset) + 24px) 0 64px;
    background: var(--light);
    min-height: calc(100vh - var(--header-height));
}
.catalog-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 900px) {
    .catalog-layout { grid-template-columns: 1fr; }
    .catalog-filters { position: static; }
}

/* Filters sidebar */
.catalog-filters {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: 16px;
    padding: 20px;
    position: sticky;
    top: calc(var(--header-height) + 16px);
}
.filter-block { margin-bottom: 24px; }
.filter-block:last-child { margin-bottom: 0; }
.filter-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-light);
}
.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--dark);
    cursor: pointer;
}
.filter-option:hover { color: var(--primary); }
.filter-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}
.filter-option input[type="number"] {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--gray-light);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
.filter-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.filter-price input { flex: 1; min-width: 0; }
.filter-price span { color: var(--gray); }
.filter-btn {
    width: 100%;
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.filter-btn:hover { background: var(--primary-dark); }
.filter-btn-ghost {
    background: var(--white);
    color: var(--gray);
    border: 1px solid var(--gray-light);
    margin-top: 6px;
}
.filter-btn-ghost:hover {
    background: var(--light);
    color: var(--dark);
}

/* Content */
.catalog-content { min-width: 0; }
.catalog-toolbar {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.results-count { font-size: 14px; color: var(--gray); }
.results-count strong { color: var(--dark); font-weight: 600; }
.toolbar-sort { display: flex; align-items: center; gap: 8px; }
.toolbar-sort label { font-size: 14px; color: var(--gray); }
.toolbar-sort select {
    padding: 6px 12px;
    border: 1px solid var(--gray-light);
    border-radius: 8px;
    font-size: 14px;
    background: var(--white);
    color: var(--dark);
    cursor: pointer;
    font-family: inherit;
}

/* Search input bar on catalog page */
.catalog-search-bar {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.catalog-search-bar input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--dark);
    background: transparent;
    font-family: inherit;
}
.catalog-search-bar button {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 0 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.catalog-search-bar button:hover { background: var(--primary-dark); }

/* Cards grid */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
@media (max-width: 600px) {
    .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}

/* Card */
.product-card {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: 16px;
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
}
.product-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}
.product-card .card-img-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--gray-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    position: relative;
    border-bottom: 1px solid var(--gray-light);
}
.product-card .card-source-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(26, 26, 46, 0.85);
    color: var(--white);
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    backdrop-filter: blur(4px);
}
.product-card .card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.product-card .card-name {
    font-size: 14px;
    color: var(--dark);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
    font-weight: 500;
    text-decoration: none;
}
.product-card .card-name:hover { color: var(--primary); }
.product-card .card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--gray);
}
.product-card .card-rating .stars { color: #ffa500; letter-spacing: -1px; }
.product-card .card-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 4px;
}
.product-card .card-delivery {
    font-size: 12px;
    color: var(--green);
    display: flex;
    align-items: center;
    gap: 4px;
}
.product-card .card-btn {
    width: 100%;
    background: var(--white);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
    margin-top: auto;
    font-family: inherit;
}
.product-card .card-btn:hover {
    background: var(--primary);
    color: var(--white);
}
.product-card .card-btn-primary {
    background: var(--primary);
    color: var(--white);
}
.product-card .card-btn-primary:hover { background: var(--primary-dark); }

/* Warning banner */
.warning-banner {
    background: #fff8e1;
    border: 1px solid #ffc107;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 10px;
}
.warning-banner .icon { font-size: 18px; }

/* Pagination */
.catalog-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
}
.catalog-pagination button {
    padding: 8px 14px;
    border: 1px solid var(--gray-light);
    background: var(--white);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--dark);
    font-family: inherit;
    transition: var(--transition);
}
.catalog-pagination button:hover:not(:disabled):not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}
.catalog-pagination button.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}
.catalog-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* States */
.no-results, .loading, .error-results {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: 16px;
    text-align: center;
    padding: 64px 24px;
    color: var(--gray);
}
.no-results .icon, .error-results .icon { font-size: 64px; margin-bottom: 16px; }
.no-results h3, .error-results h3 {
    font-size: 20px;
    color: var(--dark);
    margin-bottom: 8px;
    font-weight: 700;
}
.no-results p, .error-results p { font-size: 14px; line-height: 1.5; }

.loading { color: var(--gray); }
.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 12px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.catalog-footer {
    background: var(--dark);
    color: var(--white);
    padding: 32px 0;
    text-align: center;
    font-size: 13px;
    opacity: 0.8;
}
.catalog-footer a { color: var(--white); text-decoration: none; opacity: 0.7; }
.catalog-footer a:hover { opacity: 1; }

/* ========== Captcha modal (Яндекс Маркет) ========== */
.captcha-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 20, 0.65);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: captcha-fade-in 0.18s ease-out;
}

@keyframes captcha-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.captcha-modal {
    background: var(--white, #fff);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: captcha-slide-up 0.22s ease-out;
}

@keyframes captcha-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.captcha-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--gray-light, #f5f5f7);
}

.captcha-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    color: var(--dark, #1a1a2e);
    line-height: 1.3;
}

.captcha-modal-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.captcha-modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--gray, #666);
    cursor: pointer;
    padding: 0 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.captcha-modal-close:hover {
    background: rgba(229, 57, 53, 0.1);
    color: var(--primary, #e53935);
}

.captcha-modal-body {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: auto;
}

.captcha-modal-hint {
    margin: 0;
    font-size: 14px;
    color: var(--gray, #555);
    line-height: 1.5;
}

.captcha-modal-iframe {
    width: 100%;
    min-height: 380px;
    height: 60vh;
    max-height: 600px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: #fff;
}

.captcha-modal-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray, #666);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.captcha-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f0a000;
    flex-shrink: 0;
    animation: captcha-pulse 1.4s ease-in-out infinite;
}

@keyframes captcha-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.85); }
}

.captcha-modal-status[data-state="solved"] {
    background: rgba(76, 175, 80, 0.1);
    color: #2e7d32;
}

.captcha-modal-status[data-state="solved"] .captcha-status-dot {
    background: #2e7d32;
    animation: none;
}

.captcha-modal-status[data-state="error"] {
    background: rgba(229, 57, 53, 0.08);
    color: #c62828;
}

.captcha-modal-status[data-state="error"] .captcha-status-dot {
    background: #c62828;
    animation: none;
}

@media (max-width: 600px) {
    .captcha-modal-overlay { padding: 0; }
    .captcha-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .captcha-modal-iframe {
        min-height: 60vh;
        height: auto;
        flex: 1;
    }
}

/* Картинка товара в карточке (Яндекс Маркет, Yandex API, etc.) */
.product-card .card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}
.product-card .card-emoji-fallback {
    font-size: 56px;
    line-height: 1;
}

/* Lazy-load реальных картинок через og_image endpoint */
.product-card .card-img {
    transition: opacity 0.3s ease;
}
.product-card .card-img-lazy {
    opacity: 0.95; /* лёгкая прозрачность пока грузится реальная */
}
.product-card .card-img-loaded {
    opacity: 1;
}
.product-card .card-img-failed {
    /* fallback остаётся SVG placeholder */
    opacity: 1;
}
