/**
 * 产品卡片组件 (Product Card Component)
 * 
 * 管辖范围：
 * - 产品图悬停切换第二张
 * - 产品信息（名字、价格、产品变体、collection品牌信息）
 * - 可定义的卡片宽度（宽度由外部输入）
 * 
 * 设计原则：
 * - 卡片只管理内部内容和样式
 * - 宽度通过CSS变量由外部控制
 * - 完全独立，可在任何布局中使用
 * 
 * @package Leahz
 * @version 2.0.0
 */

/* ==========================================================================
   产品卡片基础结构 (Product Card Base)
   ========================================================================== */

/* 产品卡片基础样式 */
.leahz-product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border: none;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
    
    /* 宽度由网格布局决定，不再使用固定宽度 */
    width: 100%;
    min-width: auto;
    max-width: none;
    
    /* 在flex布局中的行为 */
    flex: 1 1 auto;
    
    /* 基础样式 */
    box-sizing: border-box;
    margin-bottom: 20px;
}

/* ==========================================================================
   产品图片区域 (Product Images)
   ========================================================================== */

/* 产品图片容器 */
.leahz-product-card__image-container {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* 1:1 比例 */
    overflow: hidden;
    background-color: #f8f8f8;
    isolation: isolate; /* 创建隔离的堆叠上下文，确保 z-index 在同一层级比较 */
}

/* 缺货标签 */
.leahz-product-card__out-of-stock-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: var(--font-medium);
    z-index: 100;
    white-space: nowrap;
    pointer-events: none;
}

/* 产品图片基础样式 */
.leahz-product-card__image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease;
}

/* 第一张图片（默认显示） */
.leahz-product-card__image--first {
    opacity: 1;
    z-index: 1;
}

/* 第二张图片（悬停显示） */
.leahz-product-card__image--second {
    opacity: 0;
    z-index: 2;
    pointer-events: none;
    visibility: hidden;
}

/* 悬停时切换图片 */
.leahz-product-card:hover .leahz-product-card__image--first {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.leahz-product-card:hover .leahz-product-card__image--second {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

/* ==========================================================================
   产品操作按钮 (Product Actions)
   ========================================================================== */

/* 操作按钮容器 */
.leahz-product-card__actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: row;
    gap: 5px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10;
}

/* 悬停时显示操作按钮 */
.leahz-product-card:hover .leahz-product-card__actions {
    opacity: 1;
    visibility: visible;
}

/* 操作按钮样式 */
.leahz-product-card__action-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 3px;
    border-radius: 0;
    border: none;
}

.leahz-product-card__action-btn:hover {
    background-color: #fff;
}

.leahz-product-card__action-btn svg {
    width: 11px;
    height: 11px;
    fill: none;
    stroke: #666;
    stroke-width: 2;
    transition: all 0.2s ease;
}

/* 缺货按钮样式 */
.leahz-product-card__action-btn--out-of-stock {
    cursor: not-allowed;
    opacity: 0.5;
}

.leahz-product-card__action-btn--out-of-stock svg {
    stroke: #999;
}

/* ==========================================================================
   产品信息区域 (Product Info)
   ========================================================================== */

/* 产品信息容器 */
.leahz-product-card__info {
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

/* 产品信息详情容器 */
.leahz-product-card__details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* 产品信息行布局 */
.leahz-product-card__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0; /* 允许flex子元素收缩 */
    gap: 5px;
}

/* ==========================================================================
   产品标题 (Product Title)
   ========================================================================== */

.leahz-product-card__title {
    font-size: 11px !important;
    font-weight: var(--font-medium);
    margin: 0;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1; /* 占据剩余空间 */
    min-width: 0; /* 关键：允许flex子元素收缩，确保文本溢出生效 */
    max-width: 100%; /* 确保不超过容器宽度 */
}

/* ==========================================================================
   产品价格 (Product Price)
   ========================================================================== */

/* 价格容器 */
.leahz-product-card__price {
    font-size: 11px !important;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    flex: 0 0 auto; /* 不占据额外空间，不收缩 */
    flex-shrink: 0; /* 确保价格区域不收缩 */
}

/* 现价样式 - 粗体 */
.leahz-product-card__price--current {
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
}

/* 原价样式 - 细体划线 */
.leahz-product-card__price--original {
    font-weight: var(--font-light);
    text-decoration: line-through;
    color: var(--color-text-light);
}

/* ==========================================================================
   产品变体 (Product Variants)
   ========================================================================== */

/* 颜色变体容器 */
.leahz-product-card__variants {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    margin: 0;
    flex-shrink: 0;
}

/* 颜色变体圆圈 */
.leahz-product-card__variant {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
    transition: transform 0.2s ease;
}

/* 变体悬停效果 */
.leahz-product-card__variant:hover {
    transform: scale(1.2);
    z-index: 2;
}

/* 银色变体 */
.leahz-product-card__variant--silver {
    background-image: linear-gradient(135deg, #C0C0C0, #E8E8E8);
}

/* 金色变体 */
.leahz-product-card__variant--gold {
    background-image: linear-gradient(135deg, #CD7F32, #DAA520);
}

/* 选中状态 */
.leahz-product-card__variant--selected {
    border-color: #000;
    border-width: 1px;
}

/* ==========================================================================
   产品品牌信息 (Product Brand)
   ========================================================================== */

/* 品牌信息容器 */
.leahz-product-card__brand {
    font-size: 11px;
    color: var(--color-text-light);
    font-style: italic;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 品牌前缀 */
.leahz-product-card__brand-prefix {
    font-style: normal;
    opacity: 0.7;
}

/* ==========================================================================
   产品关系标签 (Product Labels)
   ========================================================================== */

/* 关系标签 */
.leahz-product-card__label {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 6px;
    font-size: 11px;
    color: #333;
    z-index: 10;
    border-radius: 2px;
    background-color: transparent;
    white-space: nowrap;
}
