/* ================================
   XHELOS 2: STATS COMPONENT SYSTEM
   Unified Statistics & Metrics Display
   ================================ */

/* #region ===== BASE STAT DISPLAYS ===== */

/* Stat Group Container */
.stat-group {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.stat-group--grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-md);
}

.stat-group--inline {
    display: inline-flex;
    gap: var(--space-md);
    align-items: center;
}

/* Base Stat Item */
.stat-item {
    flex: 1;
    min-width: 150px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    transition: all var(--transition-fast);
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--accent-bio);
}

/* Stat Label */
.stat-item__label {
    font-size: var(--fs-small);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
    font-family: var(--font-heading);
}

/* Stat Value */
.stat-item__value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-bio);
    font-family: var(--font-heading);
    line-height: 1;
}

/* Stat Change Indicator */
.stat-item__change {
    font-size: var(--fs-small);
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.stat-item__change--positive {
    color: var(--accent-bio);
}

.stat-item__change--negative {
    color: var(--accent-chem);
}

.stat-item__change--neutral {
    color: var(--text-secondary);
}

/* Stat Icon */
.stat-item__icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
    opacity: 0.8;
}

/* #endregion */

/* #region ===== INLINE STATS (Combat/Units) ===== */

/* Inline Stat Element */
.stat {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
}

/* Stat Types (using data attributes) */
.stat[data-type="hp"] {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.stat[data-type="armor"] {
    color: #6b7280;
    background: rgba(107, 114, 128, 0.05);
}

.stat[data-type="ap"] {
    color: var(--accent-tech);
    background: rgba(245, 158, 11, 0.05);
}

.stat[data-type="damage"] {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.05);
}

.stat[data-type="speed"] {
    color: var(--accent-crystal);
    background: rgba(96, 165, 250, 0.05);
}

.stat[data-type="energy"] {
    color: var(--accent-tech);
    background: rgba(245, 158, 11, 0.05);
}

.stat[data-type="psi"] {
    color: var(--accent-psi);
    background: rgba(167, 139, 250, 0.05);
}

.stat[data-type="effect"] {
    color: var(--accent-psi);
    background: rgba(167, 139, 250, 0.05);
}

.stat[data-type="will"] {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
}

.stat[data-type="heal"] {
    color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

/* Stat Modifiers */
.stat--strike {
    text-decoration: line-through;
    opacity: 0.6;
}

.stat--amplified {
    font-size: 1.1rem;
    font-weight: 700;
    animation: pulse-glow 2s ease-in-out infinite;
    border: 1px solid currentColor;
}

.stat--fade {
    opacity: 0.4;
}

.stat--ignored {
    opacity: 0.5;
    text-decoration: line-through;
    color: #6b7280 !important;
}

.stat--decay {
    opacity: 0.7;
    font-style: italic;
}

.stat--critical {
    background: rgba(239, 68, 68, 0.2) !important;
    border: 1px solid #ef4444;
    animation: critical-flash 0.5s ease-in-out 2;
}

/* #endregion */

/* #region ===== STAT BARS ===== */

/* Stat Bar Container */
.stat-bar {
    width: 100%;
    margin: var(--space-sm) 0;
}

.stat-bar__label {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-xs);
    font-size: var(--fs-small);
}

.stat-bar__label-text {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-bar__label-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Bar Track */
.stat-bar__track {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

/* Bar Fill */
.stat-bar__fill {
    height: 100%;
    background: var(--accent-bio);
    transition: width var(--transition-normal);
    position: relative;
}

/* Bar Fill Variants */
.stat-bar__fill--hp {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.stat-bar__fill--energy {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.stat-bar__fill--xp {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.stat-bar__fill--corruption {
    background: linear-gradient(90deg, #7c3aed, #ec4899);
}

/* Segmented Bar */
.stat-bar__fill--segmented {
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.1) 10px,
        rgba(0, 0, 0, 0.1) 11px
    );
}

/* Animated Bar */
.stat-bar__fill--animated {
    background-size: 20px 100%;
    background-image: linear-gradient(
        45deg,
        transparent 25%,
        rgba(255, 255, 255, 0.1) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 50%,
        transparent 75%,
        rgba(255, 255, 255, 0.1) 75%
    );
    animation: progress-stripes 1s linear infinite;
}

/* #endregion */

/* #region ===== RESOURCE DISPLAYS ===== */

/* Resource Container */
.resource-display {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.resource-display--inline {
    display: inline-flex;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--fs-small);
}

/* Resource Icon */
.resource-display__icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Resource Value */
.resource-display__value {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* Resource Label */
.resource-display__label {
    font-size: var(--fs-small);
    color: var(--text-secondary);
    margin-left: var(--space-xs);
}

/* Resource Change */
.resource-display__change {
    margin-left: auto;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: var(--fs-small);
    font-weight: 600;
}

.resource-display__change--positive {
    background: rgba(74, 222, 128, 0.2);
    color: var(--accent-bio);
}

.resource-display__change--negative {
    background: rgba(236, 72, 153, 0.2);
    color: var(--accent-chem);
}

/* Resource Grid */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-sm);
}

/* #endregion */

/* #region ===== PROPERTY LISTS ===== */

/* Property List Container */
.property-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Property Item */
.property-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.property-item:hover {
    background: var(--bg-secondary);
    transform: translateX(2px);
}

/* Property Icon */
.property-item__icon {
    font-size: 1.5rem;
    margin-right: var(--space-sm);
}

/* Property Label */
.property-item__label {
    flex: 1;
    color: var(--text-secondary);
    font-size: var(--fs-small);
}

/* Property Value */
.property-item__value {
    font-weight: 600;
    color: var(--text-primary);
}

/* #endregion */

/* #region ===== UNIT STATS DISPLAY ===== */

/* Unit Stats Card */
.unit-stats {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

/* Unit Stats Header */
.unit-stats__header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
}

.unit-stats__icon {
    font-size: 3rem;
}

.unit-stats__name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.unit-stats__type {
    font-size: var(--fs-small);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Unit Stats Grid */
.unit-stats__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--space-md);
}

.unit-stat {
    text-align: center;
}

.unit-stat__icon {
    font-size: 1.5rem;
    margin-bottom: var(--space-xs);
    opacity: 0.8;
}

.unit-stat__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.unit-stat__label {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: var(--space-xs);
}

/* #endregion */

/* #region ===== COMPARISON STATS ===== */

/* VS Comparison */
.stat-comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--space-lg);
    align-items: center;
}

.stat-comparison__side {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.stat-comparison__side--left {
    text-align: right;
}

.stat-comparison__side--right {
    text-align: left;
}

.stat-comparison__divider {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-tech);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

/* Comparison Item */
.comparison-stat {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.stat-comparison__side--left .comparison-stat {
    justify-content: flex-end;
}

.comparison-stat__label {
    color: var(--text-secondary);
    font-size: var(--fs-small);
}

.comparison-stat__value {
    font-weight: 700;
    font-size: 1.1rem;
}

.comparison-stat__value--higher {
    color: var(--accent-bio);
}

.comparison-stat__value--lower {
    color: var(--accent-chem);
}

.comparison-stat__value--equal {
    color: var(--text-primary);
}

/* #endregion */

/* #region ===== STAT BADGES ===== */

/* Stat Badge */
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: var(--fs-small);
    font-weight: 600;
}

.stat-badge__icon {
    font-size: 1rem;
}

.stat-badge__value {
    color: var(--text-primary);
}

/* Badge Variants */
.stat-badge--hp {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.stat-badge--armor {
    background: rgba(107, 114, 128, 0.1);
    border-color: #6b7280;
    color: #6b7280;
}

.stat-badge--energy {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--accent-tech);
    color: var(--accent-tech);
}

.stat-badge--psi {
    background: rgba(167, 139, 250, 0.1);
    border-color: var(--accent-psi);
    color: var(--accent-psi);
}

/* #endregion */

/* #region ===== COST DISPLAYS ===== */

/* Cost Container */
.cost-display {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.2rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Cost Badge Variants */
.cost-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: var(--fs-small);
    font-weight: 600;
}

.cost-badge--matter {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-tech);
}

.cost-badge--bio {
    background: rgba(74, 222, 128, 0.2);
    color: var(--accent-bio);
}

.cost-badge--energy {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-tech);
}

.cost-badge--blood {
    background: rgba(220, 38, 38, 0.2);
    color: #dc2626;
}

.cost-badge--crystal {
    background: rgba(96, 165, 250, 0.2);
    color: var(--accent-crystal);
}

/* #endregion */

/* #region ===== ANIMATIONS ===== */

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(74, 222, 128, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(74, 222, 128, 0.8);
    }
}

@keyframes critical-flash {
    0%, 100% {
        background: rgba(239, 68, 68, 0.2);
    }
    50% {
        background: rgba(239, 68, 68, 0.4);
    }
}

@keyframes progress-stripes {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 20px 0;
    }
}

/* #endregion */

/* #region ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .stat-group {
        flex-direction: column;
    }
    
    .stat-comparison {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .stat-comparison__divider {
        text-align: center;
    }
    
    .unit-stats__grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .resource-grid {
        grid-template-columns: 1fr;
    }
}

/* #endregion */