/* ===============================
   MAIN AREA
================================ */

.catalog-wrapper {
    display: block;
}

/* Two-column layout: sidebar + products */
.catalog-layout {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.catalog-filters-col {
    flex: 0 0 260px;
    width: 260px;
    min-width: 0;
    margin-top: 7px;
    position: static;
}

.catalog-products-col {
    flex: 1;
    min-width: 0;
    overflow: visible;
}

@media (max-width: 991px) {
    .catalog-layout {
        flex-direction: column;
        gap: 16px;
    }
    .catalog-filters-col {
        flex: none;
        width: 100%;
    }
}

/* Controls row above the two-column layout */
.catalog-top-controls {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.catalog-top-controls .catalog-header {
    flex: 1;
    min-width: 0;
}

.catalog-top-controls .catalog-sort-block {
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .catalog-top-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    .catalog-top-controls .catalog-sort-block {
        width: 100%;
    }
}

.catalog-main {
    min-width: 0;
    overflow: visible;
}

.catalog-content-inner {
    width: 100%;
    overflow: visible;
}



/* ===============================
   PRODUCT GRID — 3 per row (sidebar layout)
================================ */

.catalog-has-sidebar #productsContainer .product-card-wrapper {
    flex: 0 0 calc(33.333% - 16px);
    max-width: calc(33.333% - 16px);
}

@media (max-width: 1199px) {
    .catalog-has-sidebar #productsContainer .product-card-wrapper {
        flex: 0 0 calc(50% - 12px);
        max-width: calc(50% - 12px);
    }
}

@media (max-width: 767px) {
    .catalog-has-sidebar #productsContainer .product-card-wrapper {
        flex: 0 0 calc(50% - 6px);
        max-width: calc(50% - 6px);
    }
}

@media (max-width: 480px) {
    .catalog-has-sidebar #productsContainer .product-card-wrapper {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* legacy .product-col kept for other uses */
.product-col {
    flex: 0 0 auto;
    width: 16.666%;
    min-width: 0;
    display: flex;
    justify-content: center;
}



/* ===============================
   PRODUCT CARD
================================ */

.product-card-img-wrap {
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.product-card-link {
    text-decoration: none;
    color: inherit;
}

.product-card-link:hover {
    color: inherit;
}



/* ===============================
   CATALOG TOOLBAR (title + sort)
================================ */



/* ===============================
   ACTIVE FILTERS
================================ */

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.filters-label {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .7rem;
    border-radius: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: .8rem;
}

.filter-tag i {
    font-size: .75rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.filter-tag i:hover {
    color: var(--text-primary);
}

.clear-all-filters {
    margin-left: auto;
    font-size: .8rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.clear-all-filters:hover {
    color: var(--accent);
}



/* ===============================
   PAGINATION
================================ */

.pagination-nav .page-link {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.pagination-nav .page-link:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination-nav .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}



/* ===============================
   RESPONSIVE
================================ */

@media (max-width: 991px) {
    .catalog-main {
        min-width: 0;
    }
}



/* ===============================
   LARGE SCREENS
================================ */

@media (min-width: 1400px) {
    .main-content > .container {
        max-width: 96%;
    }
}

.product-card-wrapper .product-card {
    height: 100%;
}

#productsContainer .product-card {
    overflow: visible;
}
.product-card {
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #252527 0%, #1e1e1f 100%);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    overflow: visible;
    transition: all 0.3s;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}
.product-card:hover {
    border-color: rgba(72, 84, 252, 0.3);
    box-shadow: 0 20px 25px -5px rgba(72, 84, 252, 0.1);
}

.product-image-container {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #2a2a2b 0%, #1e1e1f 100%);
    overflow: hidden;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}
.product-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.product-card:hover .product-image-container img {
    transform: scale(1.08);
}
.product-card:hover .product-card-title {
    color: #4854FC !important;
}
.product-card .p-3 {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 10px !important;
    overflow: visible;
}
@media (min-width: 768px) {
    .product-card { border-radius: 24px; }
    .product-image-container { border-radius: 24px 24px 0 0; }
    .product-card .p-3 { padding: 20px !important; }
}

.cart-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.cart-trigger, .add-to-cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    color: #fff;
    font-family: Inter, sans-serif;
    font-size: 11px;
    font-weight: 600;
    background: linear-gradient(to right, #4854FC, #6B5FFF);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 6px -1px rgba(72, 84, 252, 0.3);
}
.cart-trigger:hover:not(:disabled), .add-to-cart-btn:hover:not(:disabled) {
    background: linear-gradient(to right, #5B65FF, #7C6FFF);
}
.cart-trigger:disabled, .add-to-cart-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
@media (min-width: 768px) {
    .cart-trigger, .add-to-cart-btn { font-size: 16px; padding: 12px 16px; }
}

.cart-btn-icon, .add-to-cart-btn .cart-btn-icon { width: 20px; height: 20px; flex-shrink: 0; }
.cart-btn-icon svg, .add-to-cart-btn .cart-btn-icon svg { width: 100%; height: 100%; }

.product-card-category {
    color: #999;
    font-size: 10px;
    font-family: Inter, sans-serif;
    margin-bottom: 4px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
@media (min-width: 768px) {
    .product-card-category { font-size: 14px; margin-bottom: 8px; }
}

.product-card-title {
    color: #fff;
    font-size: 11px;
    font-family: Inter, sans-serif;
    font-weight: 500;
    line-height: 1.45;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.9em;
    max-height: 2.9em;
    text-decoration: none;
}
.product-card-title:hover { color: #4854FC; }
.product-title-wrap { position: relative; overflow: visible; }
.product-title-wrap .title-tooltip {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    background: #1a1a1a;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    white-space: normal;
    max-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
    z-index: 100;
    pointer-events: none;
}
.product-title-wrap:hover .title-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
@media (min-width: 768px) {
    .product-card-title { font-size: 18px; min-height: 2.9em; max-height: 2.9em; margin-bottom: 12px; }
}

.product-card-supplier {
    display: inline-block;
    background: #2a2a2c;
    color: #ccc;
    font-size: 9px;
    font-family: Inter, sans-serif;
    padding: 4px 10px;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: fit-content;
}
@media (min-width: 768px) {
    .product-card-supplier { font-size: 13px; padding: 5px 14px; margin-bottom: 10px; }
}

.product-card-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}
@media (min-width: 768px) { .product-card-meta { margin-bottom: 16px; } }

.product-card-rating { display: flex; align-items: center; gap: 2px; }
.product-card-rating span { color: #fff; font-size: 10px; }
.product-card-reviews { color: #666; font-size: 9px; }
@media (min-width: 768px) {
    .product-card-rating span { font-size: 14px; }
    .product-card-reviews { font-size: 13px; }
}

.product-card-price {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    margin-top: auto;
}
@media (min-width: 768px) {
    .product-card-price { font-size: 24px; margin-bottom: 16px; }
}

.quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background-color: rgba(255,255,255,0.05);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.3);
}

.quantity-selector .qty-btn {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.quantity-selector .qty-btn:hover {
    background-color: #3f3f3f;
    color: #fff;
}

.quantity-selector .qty-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.quantity-selector .qty-value {
    min-width: 20px;
    text-align: center;
    font-weight: 500;
    color: #fff;
}

.d-none { display: none !important; }

#productsRow, #productsContainer { overflow: visible; }
#productsContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 100%;
}
#productsContainer.loading { min-height: 120px; }
@media (min-width: 768px) { #productsContainer { gap: 24px; } }

.product-card-wrapper {
    flex: 0 0 calc(50% - 6px);
    min-width: 0;
    max-width: calc(50% - 6px);
}
@media (min-width: 768px) {
    .product-card-wrapper { flex: 0 0 calc(33.333% - 16px); max-width: calc(33.333% - 16px); }
}
@media (min-width: 992px) {
    .product-card-wrapper { flex: 0 0 calc(25% - 18px); max-width: calc(25% - 18px); }
}

/* Skeleton */
.skeleton {
    background-color: var(--bg-tertiary, #2d2d30);
    border-radius: 4px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
.skeleton-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(135deg, #252527 0%, #1e1e1f 100%);
    border: 1px solid rgba(255,255,255,0.05);
}
@media (min-width: 768px) {
    .skeleton-card { border-radius: 24px; }
}
.skeleton-img { aspect-ratio: 1/1; }
.skeleton-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; }
.skeleton-line { height: 0.7rem; margin-bottom: 0.5rem; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 75%; }
.skeleton-line.long { width: 100%; }
.skeleton-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 1rem; }
.skeleton-price { width: 80px; height: 1.2rem; }
.skeleton-btn { width: 90px; height: 34px; border-radius: 0; }

.link-input {
  position: relative;
}

.link-input input {
  padding-right: 70px;
}

.link-input__btns {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 5px;
  display: flex;
  gap: 5px;
  width: 65px;
}

.link-input__btn {
  width: 30px;
  border: none;
  background-color: transparent;
}

.link-input .link-input__msg {
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
  z-index: 5;
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #7dd3fc;
  white-space: nowrap;
  background: var(--bg-secondary);
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.15),
    0 4px 14px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0s linear 0.28s;
}

.link-input .link-input__msg_visible {
  visibility: visible;
  opacity: 1;
}
