/**
 * 图标库样式
 * 
 * 支持三种使用方式：
 * 1. SVG 内联：cc_icon('cpu')
 * 2. SVG Sprite：cc_use_icon('cpu')
 * 3. CSS 伪元素：.cc-icon--cpu::before
 */

/* ============================================
   基础图标样式
   ============================================ */
.cc-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    line-height: 1;
}

.cc-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* 默认尺寸 */
.cc-icon {
    width: 1em;
    height: 1em;
}

/* 尺寸变体 */
.cc-icon--xs { width: 12px; height: 12px; }
.cc-icon--sm { width: 16px; height: 16px; }
.cc-icon--md { width: 20px; height: 20px; }
.cc-icon--lg { width: 24px; height: 24px; }
.cc-icon--xl { width: 32px; height: 32px; }
.cc-icon--2xl { width: 40px; height: 40px; }
.cc-icon--3xl { width: 48px; height: 48px; }

/* 颜色变体 */
.cc-icon--primary { color: var(--cc-color-primary, #3b82f6); }
.cc-icon--success { color: var(--cc-color-success, #10b981); }
.cc-icon--warning { color: var(--cc-color-warning, #f59e0b); }
.cc-icon--danger { color: var(--cc-color-danger, #ef4444); }
.cc-icon--muted { color: var(--cc-color-muted, #6b7280); }
.cc-icon--white { color: #ffffff; }

/* 动画 */
.cc-icon--spin {
    animation: cc-icon-spin 1s linear infinite;
}

@keyframes cc-icon-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cc-icon--pulse {
    animation: cc-icon-pulse 1s ease-in-out infinite;
}

@keyframes cc-icon-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   图标按钮样式
   ============================================ */
.cc-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: inherit;
}

.cc-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.cc-icon-btn:active {
    transform: scale(0.95);
}

.cc-icon-btn--primary {
    background: var(--cc-color-primary, #3b82f6);
    color: #fff;
}

.cc-icon-btn--primary:hover {
    background: var(--cc-color-primary-dark, #2563eb);
}

.cc-icon-btn--circle {
    border-radius: 50%;
}

/* ============================================
   图标与文字组合
   ============================================ */
.cc-icon-text {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}

.cc-icon-text .cc-icon {
    flex-shrink: 0;
}

/* 图标在左 */
.cc-icon-text--left .cc-icon {
    margin-right: 0.25em;
}

/* 图标在右 */
.cc-icon-text--right {
    flex-direction: row-reverse;
}

.cc-icon-text--right .cc-icon {
    margin-left: 0.25em;
}

/* ============================================
   状态图标
   ============================================ */
.cc-icon-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.cc-icon-status--success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.cc-icon-status--warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.cc-icon-status--danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.cc-icon-status--info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

/* ============================================
   分类图标（用于产品分类等）
   ============================================ */
.cc-category-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.cc-category-icon--sm {
    width: 32px;
    height: 32px;
    font-size: 16px;
}

.cc-category-icon--md {
    width: 48px;
    height: 48px;
    font-size: 24px;
}

.cc-category-icon--lg {
    width: 64px;
    height: 64px;
    font-size: 32px;
}

.cc-category-icon--xl {
    width: 96px;
    height: 96px;
    font-size: 48px;
}

/* 分类图标颜色 */
.cc-category-icon--cpu {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.cc-category-icon--gpu {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.cc-category-icon--mobile {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.cc-category-icon--automotive {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.cc-category-icon--router {
    background: rgba(236, 72, 153, 0.1);
    color: #ec4899;
}

.cc-category-icon--ai {
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
}

/* ============================================
   徽章图标
   ============================================ */
.cc-icon-badge {
    position: relative;
    display: inline-flex;
}

.cc-icon-badge__count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    background: #ef4444;
    color: #fff;
    border-radius: 9px;
}

.cc-icon-badge__count--dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    padding: 0;
    border-radius: 50%;
}

/* ============================================
   加载占位符
   ============================================ */
.cc-icon-skeleton {
    display: inline-block;
    width: 24px;
    height: 24px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: cc-icon-skeleton 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes cc-icon-skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   图标网格（用于图标选择器）
   ============================================ */
.cc-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}

.cc-icon-grid__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cc-icon-grid__item:hover {
    border-color: var(--cc-color-primary, #3b82f6);
    background: rgba(59, 130, 246, 0.05);
}

.cc-icon-grid__item--selected {
    border-color: var(--cc-color-primary, #3b82f6);
    background: rgba(59, 130, 246, 0.1);
}

.cc-icon-grid__item .cc-icon {
    margin-bottom: 4px;
    color: #374151;
}

.cc-icon-grid__item__name {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    word-break: break-word;
}

/* ============================================
   响应式调整
   ============================================ */
@media (max-width: 768px) {
    .cc-icon--xl { width: 24px; height: 24px; }
    .cc-icon--2xl { width: 32px; height: 32px; }
    .cc-icon--3xl { width: 40px; height: 40px; }
    
    .cc-category-icon--xl {
        width: 72px;
        height: 72px;
        font-size: 36px;
    }
}

/* ============================================
   深色模式
   ============================================ */
@media (prefers-color-scheme: dark) {
    .cc-icon-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .cc-icon-grid__item {
        border-color: #374151;
    }
    
    .cc-icon-grid__item:hover {
        border-color: #60a5fa;
        background: rgba(96, 165, 250, 0.1);
    }
    
    .cc-icon-skeleton {
        background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
        background-size: 200% 100%;
    }
}
