/* ============================================
   商品卡片组件样式 (TASK003 - 重新设计)
   基于整体设计结构优化 - 使用全局和组件变量
   ============================================ */

/* 使用全局和组件变量，确保与整体设计一致 */
:root {
    /* 使用组件变量 */
    --product-card-primary: var(--component-primary, #4b5563);
    --product-card-primary-hover: var(--component-primary-hover, #374151);
    --product-card-primary-light: var(--component-primary-light, #6b7280);
    --product-card-success: var(--component-success, #10b981);
    --product-card-danger: var(--component-danger, #ef4444);
    --product-card-info: var(--component-info, #3b82f6);
    
    /* 使用全局圆角变量 */
    --product-card-border-radius: var(--global-border-radius, 1.5rem);
    --product-card-border-radius-sm: var(--global-border-radius-sm, 0.75rem);
    
    /* 使用组件阴影变量 */
    --product-card-shadow: var(--component-shadow, 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06));
    --product-card-shadow-hover: var(--component-shadow-hover, 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06));
    
    /* 使用全局颜色变量 */
    --product-card-bg: var(--global-bg-tertiary, var(--bs-body-tertiary-bg, #f5f5f5));
    --product-card-text: var(--global-text-body, var(--bs-body-color, #374151));
    --product-card-text-secondary: var(--global-text-secondary, var(--bs-secondary-color, #6b7280));
    --product-card-text-emphasis: var(--global-text-emphasis, var(--bs-emphasis-color, #1f2937));
    --product-card-border: var(--global-border-color, var(--bs-border-color, #e5e7eb));
}

[data-bs-theme="dark"] {
    --product-card-shadow: var(--component-shadow, 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2));
    --product-card-shadow-hover: var(--component-shadow-hover, 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2));
    --product-card-bg: var(--global-bg-tertiary, var(--bs-body-tertiary-bg, #1f2937));
    --product-card-text: var(--global-text-body, var(--bs-body-color, #d1d5db));
    --product-card-text-secondary: var(--global-text-secondary, var(--bs-secondary-color, #9ca3af));
    --product-card-text-emphasis: var(--global-text-emphasis, var(--bs-emphasis-color, #e5e7eb));
    --product-card-border: var(--global-border-color, var(--bs-border-color, #374151));
}

/* ============================================
   横向布局商品卡片（主要布局）
   ============================================ */

.product-card-modern.product-card-horizontal {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    padding: 1.5rem;
    gap: 1.5rem;
    height: auto;
    min-height: 200px;
    margin-bottom: 1.5rem;
    background: var(--product-card-bg);
    border-radius: var(--product-card-border-radius);
    border: 1px solid var(--product-card-border);
    box-shadow: var(--product-card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* 悬停效果 - 使用组件标准悬停效果 */
@media (hover: hover) and (pointer: fine) {
    .product-card-modern.product-card-horizontal:hover:not(.out-of-stock) {
        transform: translateY(-2px);
        box-shadow: var(--product-card-shadow-hover);
        border-color: var(--product-card-primary);
    }
}

/* 缺货状态 */
.product-card-modern.out-of-stock {
    opacity: 0.6;
    cursor: not-allowed;
}

.product-card-modern.out-of-stock::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.05);
    z-index: 1;
    pointer-events: none;
}

[data-bs-theme="dark"] .product-card-modern.out-of-stock::before {
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================
   图片区域
   ============================================ */

.product-card-image-wrapper {
    position: relative;
    width: 160px;
    min-width: 160px;
    flex-shrink: 0;
    padding: 1rem;
    background: var(--bs-body-bg, #ffffff);
    border-radius: var(--product-card-border-radius-sm);
    border: 1px solid var(--product-card-border);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-bs-theme="dark"] .product-card-image-wrapper {
    background: var(--bs-body-bg, #111827);
    border-color: var(--product-card-border);
}

@media (hover: hover) and (pointer: fine) {
    .product-card-modern:hover .product-card-image-wrapper {
        border-color: var(--product-card-primary);
        box-shadow: 0 2px 8px rgba(75, 85, 99, 0.15);
    }
    
    [data-bs-theme="dark"] .product-card-modern:hover .product-card-image-wrapper {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

.product-card-image-link {
    display: block;
    width: 100%;
    text-decoration: none;
    position: relative;
}

.product-card-image-container {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    overflow: hidden;
    border-radius: var(--component-border-radius-sm, 0.5rem);
    background: var(--bs-body-bg, #ffffff);
}

[data-bs-theme="dark"] .product-card-image-container {
    background: var(--bs-secondary-bg, #1f2937);
}

.product-card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (hover: hover) and (pointer: fine) {
    .product-card-modern:hover .product-card-image {
        transform: scale(1.08);
    }
}

/* 缺货遮罩 */
.product-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--component-border-radius-sm, 0.5rem);
    z-index: 1;
    pointer-events: none;
}

/* ============================================
   标签系统
   ============================================ */

/* 左上角标签（自动/人工/缺货） */
.product-card-tags-left {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-card-tags-left .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.625rem;
    border-radius: var(--component-border-radius-sm, 0.5rem);
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(4px);
}

/* HOT标签（右上角） */
.product-card-hot-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    width: 70px;
    height: 70px;
    overflow: visible;
}

.product-card-hot-badge .badge {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.375rem 0.75rem;
    background-color: var(--product-card-danger) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    transform: rotate(45deg) translate(25px, -25px);
    transform-origin: center;
    width: 90px;
    text-align: center;
    line-height: 1.2;
    border-radius: var(--component-border-radius-sm, 0.5rem);
}

/* 标签颜色 - 使用组件颜色变量 */
.badge-success {
    background-color: var(--product-card-success) !important;
    color: #fff !important;
}

.badge-info {
    background-color: var(--product-card-primary) !important;
    color: #fff !important;
}

.badge-danger {
    background-color: var(--product-card-danger) !important;
    color: #fff !important;
}

[data-bs-theme="dark"] .badge-success {
    background-color: #059669 !important;
}

[data-bs-theme="dark"] .badge-info {
    background-color: var(--product-card-primary-light) !important;
}

[data-bs-theme="dark"] .badge-danger {
    background-color: #dc2626 !important;
}

/* ============================================
   商品信息区域
   ============================================ */

.product-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 0;
    position: relative;
    z-index: 2;
}

/* 商品头部（标题+价格） */
.product-card-header {
    margin-bottom: 1rem;
}

.product-card-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-title a {
    color: var(--product-card-text-emphasis);
    text-decoration: none;
    transition: color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .product-card-title a:hover {
        color: var(--product-card-primary);
    }
}

/* 价格区域 */
.product-card-price-wrapper {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.product-card-price-current {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--product-card-danger);
    line-height: 1.2;
}

.product-card-price-duration {
    font-size: 1rem;
    font-weight: 500;
    color: var(--product-card-danger);
    margin-left: 0.125rem;
}

.product-card-price-original {
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--product-card-text-secondary);
    text-decoration: line-through;
}

[data-bs-theme="dark"] .product-card-price-current,
[data-bs-theme="dark"] .product-card-price-duration {
    color: #f87171;
}

[data-bs-theme="dark"] .product-card-price-original {
    color: var(--product-card-text-secondary);
}

/* 商品标签列表 */
.product-card-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.product-card-tag-item {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    background-color: var(--bs-body-bg, #ffffff);
    color: var(--product-card-text);
    font-weight: 500;
    border: 1px solid var(--product-card-border);
    white-space: nowrap;
    line-height: 1.2;
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .product-card-tag-item:hover {
        border-color: var(--product-card-primary);
        color: var(--product-card-primary);
    }
}

[data-bs-theme="dark"] .product-card-tag-item {
    background-color: var(--bs-body-bg, #111827);
    color: var(--product-card-text);
    border-color: var(--product-card-border);
}

[data-bs-theme="dark"] .product-card-tag-item:hover {
    border-color: var(--product-card-primary-light);
    color: var(--product-card-primary-light);
}

/* ============================================
   商品底部（销量+按钮）
   ============================================ */

.product-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--product-card-border);
}

.product-card-sales {
    font-size: 0.875rem;
    flex: 1;
}

.product-card-sales-text {
    color: var(--product-card-text-secondary);
}

.product-card-sales-count {
    font-weight: 600;
    color: var(--product-card-text-emphasis);
}

/* 查看详情按钮 - 使用组件按钮样式 */
.product-card-detail-btn {
    min-width: 110px;
    padding: 0.625rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--product-card-border-radius-sm);
    background: var(--product-card-primary);
    border-color: var(--product-card-primary);
    color: #fff;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.product-card-detail-btn:hover {
    background: var(--product-card-primary-hover);
    border-color: var(--product-card-primary-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--product-card-shadow-hover);
}

.product-card-detail-btn:active {
    transform: translateY(0);
}

[data-bs-theme="dark"] .product-card-detail-btn {
    background: var(--product-card-primary-light);
    border-color: var(--product-card-primary-light);
}

[data-bs-theme="dark"] .product-card-detail-btn:hover {
    background: var(--component-secondary, #9ca3af);
    border-color: var(--component-secondary, #9ca3af);
}

/* ============================================
   响应式设计
   ============================================ */

@media (max-width: 991.98px) {
    .product-card-modern.product-card-horizontal {
        padding: 1.25rem;
        gap: 1.25rem;
        min-height: 180px;
    }

    .product-card-image-wrapper {
        width: 140px;
        min-width: 140px;
    }

    .product-card-title {
        font-size: 1.25rem;
    }

    .product-card-price-current {
        font-size: 1.5rem;
    }

    .product-card-price-duration {
        font-size: 0.9375rem;
    }
}

@media (max-width: 767.98px) {
    .product-card-modern.product-card-horizontal {
        padding: 1rem;
        gap: 1rem;
        min-height: 160px;
        border-radius: var(--product-card-border-radius-sm);
        /* 移动端使用较小的圆角 */
    }

    .product-card-image-wrapper {
        width: 120px;
        min-width: 120px;
        padding: 0.75rem;
    }

    .product-card-title {
        font-size: 1.125rem;
        margin-bottom: 0.5rem;
    }

    .product-card-price-current {
        font-size: 1.25rem;
    }

    .product-card-price-duration {
        font-size: 0.875rem;
    }

    .product-card-tag-item {
        font-size: 0.6875rem;
        padding: 0.25rem 0.625rem;
    }

    .product-card-footer {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        padding-top: 0.75rem;
    }

    .product-card-detail-btn {
        min-width: 90px;
        padding: 0.5rem 1.25rem;
        font-size: 0.875rem;
    }

    .product-card-hot-badge {
        top: 0.5rem;
        right: 0.5rem;
        width: 60px;
        height: 60px;
    }

    .product-card-hot-badge .badge {
        width: 80px;
        font-size: 0.6875rem;
        padding: 0.25rem 0.5rem;
        transform: rotate(45deg) translate(20px, -20px);
    }

    .product-card-tags-left {
        top: 0.75rem;
        left: 0.75rem;
        gap: 0.375rem;
    }

    .product-card-tags-left .badge {
        font-size: 0.6875rem;
        padding: 0.25rem 0.5rem;
    }
}

@media (max-width: 575.98px) {
    .product-card-modern.product-card-horizontal {
        padding: 0.875rem;
        gap: 0.875rem;
        min-height: 140px;
    }

    .product-card-image-wrapper {
        width: 100px;
        min-width: 100px;
        padding: 0.5rem;
    }

    .product-card-title {
        font-size: 1rem;
        -webkit-line-clamp: 2;
    }

    .product-card-price-current {
        font-size: 1.125rem;
    }

    .product-card-price-duration {
        font-size: 0.8125rem;
    }

    .product-card-tags-list {
        gap: 0.375rem;
        margin-bottom: 0.75rem;
    }

    .product-card-tag-item {
        font-size: 0.625rem;
        padding: 0.1875rem 0.5rem;
    }

    .product-card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .product-card-detail-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   打印样式
   ============================================ */

@media print {
    .product-card-modern {
        box-shadow: none;
        break-inside: avoid;
        border: 1px solid #e5e7eb;
    }

    .product-card-modern:hover {
        transform: none;
    }
}
