/**
 * PinShop Public Styles
 * Pinterest-style masonry product grid
 */

/* ─── CSS Custom Properties ─── */
:root {
    --pinshop-btn-color: #e60023;
    --pinshop-btn-text: #ffffff;
    --pinshop-gap: 16px;
    --pinshop-cols-desktop: 4;
    --pinshop-cols-tablet: 2;
    --pinshop-cols-mobile: 1;
    --pinshop-radius: 16px;
    --pinshop-card-bg: #ffffff;
    --pinshop-text: #111111;
    --pinshop-text-muted: #767676;
    --pinshop-overlay-bg: rgba(0,0,0,0.45);
    --pinshop-transition: 0.22s cubic-bezier(0.4,0,0.2,1);
    --pinshop-shadow: 0 2px 8px rgba(0,0,0,0.14);
    --pinshop-shadow-hover: 0 8px 28px rgba(0,0,0,0.22);
    --pinshop-badge-trending: #ff4b2b;
    --pinshop-badge-featured: #f59e0b;
    --pinshop-badge-bought: #10b981;
}

/* ─── Wrapper ─── */
.pinshop-wrapper {
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ─── Filter Bar ─── */
.pinshop-filter-bar {
    margin-bottom: calc(var(--pinshop-gap) * 1.5);
    overflow-x: auto;
    scrollbar-width: none;
}
.pinshop-filter-bar::-webkit-scrollbar { display: none; }

.pinshop-filter-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    padding-bottom: 4px;
}

.pinshop-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 18px;
    border: none;
    border-radius: 999px;
    background: #efefef;
    color: var(--pinshop-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--pinshop-transition), color var(--pinshop-transition), transform 0.15s;
    line-height: 1;
}
.pinshop-filter-tab:hover {
    background: #e1e1e1;
    transform: translateY(-1px);
}
.pinshop-filter-tab.active {
    background: var(--pinshop-text);
    color: #fff;
}
.pinshop-filter-tab.active:hover {
    background: #333;
}

/* ─── Masonry Grid ─── */
.pinshop-grid {
    columns: var(--pinshop-cols-desktop);
    column-gap: var(--pinshop-gap);
}

@media (max-width: 1023px) {
    .pinshop-grid {
        columns: var(--pinshop-cols-tablet);
    }
}
@media (max-width: 599px) {
    .pinshop-grid {
        columns: var(--pinshop-cols-mobile);
    }
}

/* ─── Product Card ─── */
.pinshop-card {
    background: var(--pinshop-card-bg);
    border-radius: var(--pinshop-radius);
    overflow: visible; /* Must be visible so share dropdown isn't clipped */
    break-inside: avoid;
    margin-bottom: var(--pinshop-gap);
    box-shadow: var(--pinshop-shadow);
    transition: box-shadow var(--pinshop-transition), transform var(--pinshop-transition);
    cursor: pointer;
    display: block;
}
.pinshop-card:hover {
    box-shadow: var(--pinshop-shadow-hover);
    transform: translateY(-3px);
}

/* ─── Card Media ─── */
.pinshop-card-media {
    position: relative;
    overflow: hidden;
    border-radius: var(--pinshop-radius) var(--pinshop-radius) 0 0;
    background: #f0f0f0;
}

.pinshop-card-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.4s ease;
    object-fit: cover;
}
.pinshop-card:hover .pinshop-card-image {
    transform: scale(1.03);
}

.pinshop-card-video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.pinshop-card-placeholder {
    width: 100%;
    aspect-ratio: 4/5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    color: #ccc;
    font-size: 48px;
}

/* ─── Overlay (on hover) ─── */
.pinshop-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
    padding: 20px 14px 14px;
    opacity: 0;
    transition: opacity var(--pinshop-transition);
    pointer-events: none;
}
.pinshop-card:hover .pinshop-card-overlay {
    opacity: 1;
}
.pinshop-card-desc {
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    margin: 0;
}

/* ─── Badges ─── */
.pinshop-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}
.pinshop-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    backdrop-filter: blur(4px);
}
.badge-trending {
    background: rgba(255,75,43,0.92);
    color: #fff;
}
.badge-featured {
    background: rgba(245,158,11,0.92);
    color: #fff;
}
.badge-most-bought {
    background: rgba(16,185,129,0.92);
    color: #fff;
}

/* ─── Like Button ─── */
.pinshop-like-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 999px;
    padding: 7px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--pinshop-text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: transform 0.18s, background var(--pinshop-transition);
    z-index: 3;
    backdrop-filter: blur(4px);
}
.pinshop-like-btn:hover {
    background: #fff;
    transform: scale(1.08);
}
.pinshop-like-btn.liked {
    color: #e60023;
}
.pinshop-like-btn.liked svg {
    fill: #e60023;
    animation: pinshop-like-pop 0.3s ease;
}
@keyframes pinshop-like-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* ─── Video Overlay ─── */
.pinshop-video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    transition: opacity var(--pinshop-transition);
}
.pinshop-card:hover .pinshop-video-overlay {
    opacity: 0;
}
.pinshop-play-icon {
    font-size: 36px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* ─── Card Footer ─── */
.pinshop-card-footer {
    padding: 12px 14px 14px;
    border-radius: 0 0 var(--pinshop-radius) var(--pinshop-radius);
    background: var(--pinshop-card-bg);
    overflow: visible;
}

.pinshop-card-cat {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--pinshop-text-muted);
    display: block;
    margin-bottom: 4px;
}

.pinshop-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--pinshop-text);
    margin: 0 0 10px;
    line-height: 1.35;
    word-break: break-word;
}
.pinshop-title-link {
    color: inherit;
    text-decoration: none;
}
.pinshop-title-link:hover {
    text-decoration: underline;
}

/* ─── Card Actions ─── */
.pinshop-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

/* ─── Buy Button ─── */
.pinshop-buy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--pinshop-btn-color);
    color: var(--pinshop-btn-text) !important;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: filter var(--pinshop-transition), transform 0.15s;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.pinshop-buy-btn:hover {
    filter: brightness(0.88);
    transform: translateY(-1px);
    text-decoration: none !important;
}
.pinshop-buy-btn:active {
    transform: translateY(0);
}

/* ─── Action Group ─── */
.pinshop-action-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ─── Buy Count ─── */
.pinshop-buy-count {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #4caf50;
    white-space: nowrap;
}
.pinshop-bought-label {
    color: var(--pinshop-text-muted);
    font-weight: 400;
}

/* ─── Share Button & Dropdown ─── */
.pinshop-share-wrap {
    position: relative;
    z-index: 10;
}

.pinshop-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #efefef;
    border: none;
    cursor: pointer;
    transition: background var(--pinshop-transition), transform 0.15s;
    color: var(--pinshop-text);
}
.pinshop-share-btn:hover {
    background: #e1e1e1;
    transform: scale(1.08);
}

.pinshop-share-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    padding: 6px;
    min-width: 160px;
    z-index: 9999;
    animation: pinshop-dropdown-in 0.18s ease;
}
@keyframes pinshop-dropdown-in {
    from { opacity: 0; transform: translateY(6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pinshop-share-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--pinshop-text);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s;
    border: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    text-align: left;
}
.pinshop-share-option:hover {
    background: #f5f5f5;
    text-decoration: none;
    color: var(--pinshop-text);
}

/* ─── Loading Spinner ─── */
.pinshop-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: var(--pinshop-text-muted);
    font-size: 14px;
}
.pinshop-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #efefef;
    border-top-color: var(--pinshop-btn-color);
    border-radius: 50%;
    animation: pinshop-spin 0.7s linear infinite;
}
@keyframes pinshop-spin {
    to { transform: rotate(360deg); }
}

/* ─── Load More Button ─── */
.pinshop-load-more-wrap {
    text-align: center;
    margin-top: 24px;
}
.pinshop-load-more-btn {
    display: inline-flex;
    align-items: center;
    padding: 12px 32px;
    border: 2px solid var(--pinshop-text);
    border-radius: 999px;
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--pinshop-transition), color var(--pinshop-transition);
    color: var(--pinshop-text);
}
.pinshop-load-more-btn:hover {
    background: var(--pinshop-text);
    color: #fff;
}
.pinshop-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Pagination ─── */
.pinshop-pagination {
    text-align: center;
    margin-top: 32px;
}
.pinshop-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    list-style: none;
    gap: 6px;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}
.pinshop-pagination .page-numbers li { margin: 0; }
.pinshop-pagination .page-numbers a,
.pinshop-pagination .page-numbers span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: var(--pinshop-text);
    transition: background 0.15s, color 0.15s;
    border: 1px solid #e0e0e0;
}
.pinshop-pagination .page-numbers a:hover { background: #f0f0f0; }
.pinshop-pagination .page-numbers .current {
    background: var(--pinshop-btn-color);
    color: #fff;
    border-color: var(--pinshop-btn-color);
}

/* ─── No Results ─── */
.pinshop-no-results {
    text-align: center;
    padding: 64px 24px;
    color: var(--pinshop-text-muted);
    font-size: 16px;
}

/* ─── No More ─── */
.pinshop-no-more {
    text-align: center;
    padding: 24px;
    color: var(--pinshop-text-muted);
    font-size: 14px;
}

/* ─── Copy Toast ─── */
.pinshop-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111;
    color: #fff;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}
.pinshop-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Skeleton Loading Cards ─── */
.pinshop-card-skeleton {
    background: #f0f0f0;
    border-radius: var(--pinshop-radius);
    margin-bottom: var(--pinshop-gap);
    break-inside: avoid;
    animation: pinshop-skeleton 1.4s ease infinite;
}
.pinshop-card-skeleton-img {
    width: 100%;
    aspect-ratio: 4/5;
    background: #e0e0e0;
    border-radius: var(--pinshop-radius) var(--pinshop-radius) 0 0;
}
.pinshop-card-skeleton-body {
    padding: 12px 14px;
}
.pinshop-card-skeleton-line {
    height: 12px;
    background: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
}
.pinshop-card-skeleton-line.short { width: 60%; }
@keyframes pinshop-skeleton {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ─── RTL Support ─── */
[dir="rtl"] .pinshop-share-dropdown { right: auto; left: 0; }
[dir="rtl"] .pinshop-badges { left: auto; right: 10px; }
[dir="rtl"] .pinshop-like-btn { right: auto; left: 10px; }

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    .pinshop-card,
    .pinshop-card-image,
    .pinshop-filter-tab,
    .pinshop-buy-btn,
    .pinshop-share-btn,
    .pinshop-like-btn,
    .pinshop-card-overlay { transition: none; }
    .pinshop-spinner { animation: none; border-top-color: var(--pinshop-btn-color); }
}
