/* ========================================
   components.css - Badge Forge 通用组件
   版本: 2026-05-03
   依赖: variables.css
   ======================================== */

/* ========================================
   Reset & Base
   ======================================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--duration-fast, 150ms) var(--ease-standard, ease);
}

a:hover {
    color: var(--primary);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: all var(--duration-normal, 250ms) var(--ease-standard, ease);
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: var(--card-border);
}

.btn-warning {
    background: var(--warning);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background var(--duration-fast, 150ms) ease;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   Cards
   ======================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

/* ========================================
   Forms
   ======================================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--duration-fast, 150ms) var(--ease-standard, ease);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-hint {
    display: block;
    color: var(--text-muted, #888);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.admin-toggle-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.admin-toggle-row select {
    flex: 1;
    min-width: 100px;
}

/* ========================================
   Badge Components
   ======================================== */
.badge-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: transform var(--duration-normal, 250ms) var(--ease-standard, ease),
                box-shadow var(--duration-normal, 250ms) var(--ease-standard, ease);
}

.badge-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.badge-icon {
    font-size: 4rem;
}

.badge-id {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.badge-level {
    color: var(--text-secondary);
}

/* Rarity colors */
.rarity-1 { color: #94a3b8; }
.rarity-2 { color: #22c55e; }
.rarity-3 { color: #3b82f6; }
.rarity-4 { color: #a855f7; }
.rarity-5 { color: #fbbf24; }

/* ========================================
   Item Components
   ======================================== */
.items-section {
    margin-top: 2rem;
}

.item-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 2rem 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
    text-align: center;
    position: relative;
}

.item-card .item-icon {
    font-size: 2rem;
}

.item-card .item-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: normal;
    overflow: visible;
    text-align: center;
    display: block;
}

.item-card .item-count {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-weight: 600;
    color: var(--purple, #a855f7);
    font-size: 0.8rem;
    background: var(--card-bg);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
}

.item-card .use-item-btn {
    flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.item-card .use-item-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
}

.item-card .use-item-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

/* Global item styles (outside .item-card) */
.items-list .item-icon,
.items-grid .item-icon {
    font-size: 2rem;
}

.items-list .item-name,
.items-grid .item-name {
    font-weight: 600;
}

.items-list .item-desc,
.items-grid .item-desc {
    color: var(--text-secondary);
    flex: 1;
}

.items-list .item-count,
.items-grid .item-count {
    background: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-pill, 999px);
    font-size: 0.875rem;
}

/* ========================================
   Stat Components
   ======================================== */
.stat {
    text-align: center;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.25rem;
    max-width: 100%;
    line-height: 1.2;
    white-space: nowrap;
}

.stat-value.large {
    font-size: 1.1rem;
}

.stat-value.danger {
    color: var(--danger);
}

.stat-value.cost-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    word-break: keep-all;
    display: inline-block;
    min-width: fit-content;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: transform var(--duration-normal, 300ms) var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)),
                box-shadow var(--duration-normal, 300ms) var(--ease-standard, ease);
    cursor: default;
    animation: fadeInUp 0.6s ease backwards;
}

.stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,0.4));
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.stat-card .stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-light);
    transition: color var(--duration-fast, 150ms) ease;
    display: inline-block;
}

.stat-card:hover .stat-value {
    color: var(--primary, #6366f1);
    text-shadow: 0 0 20px var(--primary-glow, rgba(99, 102, 241, 0.5));
}

.stat-card .stat-label {
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Tables
   ======================================== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
}

.table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.table tr:hover {
    background: var(--bg-secondary);
}

/* ========================================
   Misc Utilities
   ======================================== */
.text-muted {
    color: var(--text-muted, #888);
}

.beta-badge {
    background: var(--warning);
    color: #000;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-pill, 999px);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.admin-link {
    color: var(--warning) !important;
}

.badge-admin {
    font-size: 1.1rem;
    cursor: default;
}

/* ========================================
   Avatar & Frame Components
   ======================================== */
.avatar-wrapper {
    position: relative;
    display: inline-block;
}

.avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary, #6366f1), var(--primary-light, #3b82f6));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    box-shadow: 
        0 0 30px rgba(99, 102, 241, 0.4),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
}

.avatar-sm {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

.avatar-md {
    width: 60px;
    height: 60px;
    font-size: 32px;
}

.avatar-lg {
    width: 100px;
    height: 100px;
    font-size: 48px;
}

.avatar-ring {
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: linear-gradient(135deg, var(--primary, #6366f1), var(--primary-light, #3b82f6)) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.6;
}

/* ====== 头像框装饰效果 ====== */
.avatar-wrapper.frame-gold .avatar-ring,
.avatar-wrapper.frame-gold .avatar {
    background: none;
    -webkit-mask: none;
    mask: none;
}
.avatar-wrapper.frame-gold .avatar-ring {
    top: -8px; left: -8px; right: -8px; bottom: -8px;
    border: 4px solid #ffd700;
    box-shadow:
        0 0 12px rgba(255, 215, 0, 0.6),
        0 0 24px rgba(255, 215, 0, 0.3),
        inset 0 0 8px rgba(255, 215, 0, 0.2);
    opacity: 1;
    -webkit-mask: none; mask: none;
    animation: frameGoldShimmer 3s ease-in-out infinite;
}
.avatar-wrapper.frame-gold .avatar {
    box-shadow:
        0 0 20px rgba(255, 215, 0, 0.4),
        inset 0 0 15px rgba(255, 215, 0, 0.1);
}

@keyframes frameGoldShimmer {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.25); }
}

/* 彩虹头像框 */
.avatar-wrapper.frame-rainbow .avatar-ring,
.avatar-wrapper.frame-rainbow .avatar {
    background: none;
    -webkit-mask: none; mask: none;
}
.avatar-wrapper.frame-rainbow .avatar-ring {
    top: -8px; left: -8px; right: -8px; bottom: -8px;
    border: 4px solid transparent;
    background: linear-gradient(#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00) border-box;
    opacity: 1;
    -webkit-mask: none; mask: none;
    animation: frameRainbowRotate 3s linear infinite;
    box-shadow: 0 0 16px rgba(255, 50, 150, 0.5);
}
.avatar-wrapper.frame-rainbow .avatar {
    box-shadow: 0 0 20px rgba(255, 100, 180, 0.35), inset 0 0 15px rgba(255,255,255,0.08);
}

@keyframes frameRainbowRotate {
    to { background: linear-gradient(360deg, #f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00) border-box; }
}

/* 火焰头像框 */
.avatar-wrapper.frame-flame .avatar-ring,
.avatar-wrapper.frame-flame .avatar {
    background: none;
    -webkit-mask: none; mask: none;
}
.avatar-wrapper.frame-flame .avatar-ring {
    top: -10px; left: -10px; right: -10px; bottom: -10px;
    border-radius: 50%;
    border: none;
    opacity: 1;
    -webkit-mask: none; mask: none;
    background:
        radial-gradient(circle at 50% 0%, #fff 0%, transparent 30%),
        radial-gradient(circle at 20% -5%, #ff4d00 0%, transparent 35%),
        radial-gradient(circle at 80% -5%, #ffaa00 0%, transparent 35%),
        radial-gradient(circle at 40% -8%, #ffdd00 0%, transparent 40%),
        radial-gradient(circle at 60% -8%, #ff6a00 0%, transparent 40%);
    animation: frameFlameFlicker 0.5s ease-in-out infinite alternate;
    filter: blur(1px);
}
.avatar-wrapper.frame-flame .avatar {
    box-shadow: 0 0 24px rgba(255, 80, 0, 0.55), inset 0 0 12px rgba(255,200,0,0.12);
}

@keyframes frameFlameFlicker {
    0%   { transform: scale(1) translateY(0); opacity: 0.95; }
    50%  { transform: scale(1.03) translateY(-1px); opacity: 1; }
    100% { transform: scale(0.98) translateY(1px); opacity: 0.9; }
}
