/*
 * components.css - 木友圈网站组件样式文件
 * 作用：存放可复用的 UI 组件样式，比如按钮、卡片、标签、评分等
 * 遵循 DRY 原则：这些组件可以在任何页面重复使用
 */

/* ========== 第1部分：按钮组件 ========== */
/* 基础按钮样式 */
.btn {
    display: inline-flex;          /* 行内弹性盒子 */
    align-items: center;           /* 垂直居中 */
    justify-content: center;       /* 水平居中 */
    padding: 12px 28px;            /* 上下 12px，左右 28px */
    font-size: 16px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;     /* 所有属性变化都有过渡动画 */
    text-decoration: none;         /* 去掉下划线（用 a 标签做按钮时） */
    border: none;
    gap: 8px;                      /* 图标和文字之间的距离 */
}

/* 主按钮（棕色实心） */
.btn-primary {
    background-color: var(--wood-dark);
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(139, 90, 43, 0.3);
}

.btn-primary:hover {
    background-color: var(--wood-medium);
    transform: translateY(-2px);   /* 悬停时往上飘一点 */
    box-shadow: 0 6px 20px rgba(139, 90, 43, 0.4);
    color: var(--text-white);
}

.btn-primary:active {
    transform: translateY(0);      /* 点击时回到原位 */
}

/* 次要按钮（描边按钮） */
.btn-secondary {
    background-color: transparent;
    color: var(--wood-dark);
    border: 2px solid var(--wood-dark);
}

.btn-secondary:hover {
    background-color: var(--wood-dark);
    color: var(--text-white);
}

/* 绿色按钮（强调色） */
.btn-success {
    background-color: var(--forest-dark);
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(46, 93, 58, 0.3);
}

.btn-success:hover {
    background-color: var(--forest-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 93, 58, 0.4);
    color: var(--text-white);
}

/* 小按钮 */
.btn-sm {
    padding: 8px 18px;
    font-size: 14px;
    border-radius: var(--radius-sm);
}

/* 大按钮 */
.btn-lg {
    padding: 16px 40px;
    font-size: 18px;
}

/* 禁用状态 */
.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;   /* 禁止点击的鼠标样式 */
    transform: none !important;  /* 强制不移动 */
}

/* 按钮块级（占满整行） */
.btn-block {
    display: flex;
    width: 100%;
}

/* ========== 第2部分：卡片组件 ========== */
/* 基础卡片 */
.card {
    background-color: var(--wood-cream);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;        /* 子元素超出部分隐藏 */
    transition: all 0.3s ease;
    border: 1px solid var(--border-light);
}

.card:hover {
    transform: translateY(-4px);   /* 悬停上浮 */
    box-shadow: var(--shadow-md);
}

/* 卡片图片区域 */
.card-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background-color: var(--wood-light);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;    /* 图片等比例填满，超出部分裁剪 */
    transition: transform 0.5s ease;
}

.card:hover .card-image img {
    transform: scale(1.05);   /* 悬停时图片轻微放大 */
}

/* 卡片内容区域 */
.card-body {
    padding: 20px;
}

/* 卡片标题 */
.card-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;     /* 文字超出显示省略号 */
    display: -webkit-box;
    -webkit-line-clamp: 2;       /* 最多显示 2 行 */
    -webkit-box-orient: vertical;
}

/* 卡片描述文字 */
.card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 卡片底部信息栏 */
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}

/* 卡片网格布局（通用，4列变2列变1列） */
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);   /* 3 列等宽 */
    gap: 24px;
}

.card-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);   /* 4 列等宽 */
    gap: 20px;
}

.card-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);   /* 2 列等宽 */
    gap: 24px;
}

/* 响应式：平板 */
@media (max-width: 992px) {
    .card-grid,
    .card-grid-4 {
        grid-template-columns: repeat(2, 1fr);  /* 变成 2 列 */
    }
}

/* 响应式：手机 */
@media (max-width: 768px) {
    .card-grid,
    .card-grid-4,
    .card-grid-2 {
        grid-template-columns: 1fr;   /* 变成 1 列 */
    }
}

/* ========== 第3部分：标签/分类组件 ========== */
/* 基础标签 */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 20px;    /* 胶囊形状 */
    background-color: var(--wood-light);
    color: var(--wood-dark);
    font-weight: 500;
    line-height: 1.5;
}

/* 绿色标签 */
.tag-success {
    background-color: rgba(46, 93, 58, 0.1);
    color: var(--forest-dark);
}

/* 棕色标签 */
.tag-primary {
    background-color: rgba(139, 90, 43, 0.15);
    color: var(--wood-dark);
}

/* 红色标签 */
.tag-danger {
    background-color: rgba(220, 50, 50, 0.1);
    color: #C62828;
}

/* 难度标签 */
.tag-level {
    padding: 3px 10px;
    font-size: 11px;
}

.tag-level-beginner {
    background-color: #E8F5E9;
    color: #2E7D32;
}

.tag-level-intermediate {
    background-color: #FFF3E0;
    color: #E65100;
}

.tag-level-advanced {
    background-color: #FFEBEE;
    color: #C62828;
}

/* 标签组（多个标签排列） */
.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ========== 第4部分：分类标签（可点击切换的那种） ========== */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    justify-content: center;
}

.category-tab {
    padding: 8px 20px;
    background-color: var(--wood-cream);
    color: var(--text-secondary);
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-light);
}

.category-tab:hover {
    background-color: var(--wood-light);
    color: var(--wood-dark);
}

.category-tab.active {
    background-color: var(--wood-dark);
    color: var(--text-white);
    border-color: var(--wood-dark);
}

/* ========== 第5部分：评分组件（星星） ========== */
.rating {
    display: inline-flex;
    gap: 2px;
    color: #FFB300;    /* 金黄色星星 */
    font-size: 14px;
}

.rating .star-empty {
    color: #E0E0E0;    /* 灰色空星 */
}

/* 评分 + 文字 */
.rating-with-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.rating-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========== 第6部分：价格组件 ========== */
.price {
    display: inline-flex;
    align-items: baseline;   /* 文字底部对齐 */
    gap: 4px;
}

.price-current {
    font-size: 24px;
    font-weight: bold;
    color: #C62828;    /* 红色价格 */
}

.price-current .currency {
    font-size: 14px;
    font-weight: normal;
}

.price-original {
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: line-through;   /* 删除线 */
}

/* 会员价标签 */
.price-vip-tag {
    display: inline-block;
    padding: 2px 8px;
    background: linear-gradient(135deg, #FFD700, #FFA000);
    color: white;
    font-size: 11px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 6px;
}

/* ========== 第7部分：头像组件 ========== */
.avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;      /* 圆形头像 */
    overflow: hidden;
    background-color: var(--wood-light);
    border: 3px solid white;
    box-shadow: var(--shadow-sm);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-lg {
    width: 80px;
    height: 80px;
}

.avatar-sm {
    width: 40px;
    height: 40px;
}

/* ========== 第8部分：空状态组件 ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 60px;
    margin-bottom: 16px;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 20px;
}

/* ========== 第9部分：加载动画 ========== */
.loading {
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--wood-dark);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;   /* 旋转动画 */
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== 第10部分：徽章/认证标识 ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 4px;
    font-weight: bold;
}

.badge-certified {
    background: linear-gradient(135deg, #FFD700, #FFA000);
    color: white;
}

.badge-hot {
    background-color: #FF5722;
    color: white;
}

.badge-new {
    background-color: var(--forest-dark);
    color: white;
}

/* ========== 第11部分：输入框和下拉框组件 ========== */
.form-input {
    padding: 10px 16px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background-color: white;
    color: var(--text-primary);
    transition: border-color 0.3s ease;
    width: 100%;
}

.form-input:focus {
    border-color: var(--wood-dark);
}

.form-select {
    padding: 10px 36px 10px 16px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background-color: white;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;      /* 去掉系统默认下拉箭头 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B5A2B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* ========== 第12部分：分割线 ========== */
.divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 20px 0;
}

.divider-wood {
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--wood-light), transparent);
    margin: 30px 0;
}

/* ========== 第13部分：地图容器（工坊地图页面用） ========== */
.map-container {
    width: 100%;
    height: 500px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 30px;
}

/* 地图上的工坊弹窗 */
.map-popup {
    padding: 8px;
    min-width: 200px;
}

.map-popup h4 {
    font-size: 16px;
    color: var(--wood-dark);
    margin-bottom: 6px;
}

.map-popup p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ========== 第14部分：两栏布局（带侧边栏） ========== */
.two-col-layout {
    display: grid;
    grid-template-columns: 240px 1fr;  /* 侧边栏 240px，右边自适应 */
    gap: 30px;
}

/* 侧边栏 */
.sidebar {
    background-color: var(--wood-cream);
    border-radius: var(--radius-md);
    padding: 20px;
    height: fit-content;        /* 高度随内容 */
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    position: sticky;           /* 滚动时跟着固定 */
    top: 90px;                  /* 距离顶部 90px（留出导航栏） */
}

.sidebar-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--wood-dark);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--wood-light);
}

.sidebar-list li {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.sidebar-list li:hover {
    background-color: var(--wood-pale);
    color: var(--wood-dark);
}

.sidebar-list li.active {
    background-color: var(--wood-light);
    color: var(--wood-dark);
    font-weight: bold;
}

/* 响应式：手机端侧边栏变顶部横排 */
@media (max-width: 768px) {
    .two-col-layout {
        grid-template-columns: 1fr;   /* 变成单列 */
    }

    .sidebar {
        position: static;     /* 取消固定定位 */
    }

    .sidebar-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sidebar-list li {
        margin-bottom: 0;
        flex: 1;
        min-width: 80px;
        text-align: center;
    }
}
