/**
 * /assets/css/character-stats.css
 *
 * Purpose:  Character Stats Tab - Glassmorphism Design (Kernattribute + Kampfwerte)
 * Deps:     app.css (CSS Variables: --bg, --card, --text, --muted, --accent, --danger, --gold, --line)
 * Load:     index.php
 * Version:  2.0.0
 */

/* ============================================================================
   STATS CARDS (Glass Card - Outer Container)
   ============================================================================ */

#stats > form > .stats-card {
  position: relative;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
    radial-gradient(circle at top left, rgba(255,255,255,0.06), transparent 70%);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.06);
  overflow: visible;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#stats > form > .stats-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.04), transparent);
  pointer-events: none;
  border-radius: inherit;
}

/* Left-border color coding */
.stats-card--core {
  border-left: 3px solid rgba(176,140,255,0.4);
}

.stats-card--core:hover {
  border-left-color: rgba(176,140,255,0.6);
  box-shadow:
    0 6px 32px rgba(0,0,0,0.3),
    0 0 20px rgba(176,140,255,0.06),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.stats-card--combat {
  border-left: 3px solid rgba(93,214,201,0.4);
}

.stats-card--combat:hover {
  border-left-color: rgba(93,214,201,0.6);
  box-shadow:
    0 6px 32px rgba(0,0,0,0.3),
    0 0 20px rgba(93,214,201,0.06),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

/* ============================================================================
   SECTION HEADER
   ============================================================================ */

.stats-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}

.stats-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text, #e6edf3);
}

.stats-card--core .stats-section-title i {
  color: #b08cff;
  filter: drop-shadow(0 0 6px rgba(176,140,255,0.4));
}

.stats-card--combat .stats-section-title i {
  color: var(--accent, #5dd6c9);
  filter: drop-shadow(0 0 6px rgba(93,214,201,0.4));
}

/* ============================================================================
   SAVE BUTTON (Header + Bottom)
   ============================================================================ */

.btn-save-stats {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text, #e6edf3);
  background:
    linear-gradient(135deg, rgba(93,214,201,0.12), rgba(77,163,255,0.08)),
    radial-gradient(circle at center, rgba(93,214,201,0.06), transparent 70%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(93,214,201,0.25);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  z-index: 1;
}

.btn-save-stats::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.08), transparent);
  pointer-events: none;
  border-radius: inherit;
}

.btn-save-stats:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(93,214,201,0.45);
  box-shadow:
    0 4px 16px rgba(93,214,201,0.2),
    0 0 24px rgba(93,214,201,0.08),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-save-stats:active {
  transform: translateY(-1px) scale(1.0);
}

.btn-save-stats i {
  filter: drop-shadow(0 1px 4px rgba(93,214,201,0.5));
}

/* Bottom save button */
.stats-save-bottom {
  text-align: center;
  margin-top: 0.5rem;
}

.btn-save-stats--bottom {
  width: 100%;
  max-width: 320px;
  justify-content: center;
  padding: 0.7rem 1.5rem;
  font-size: 0.85rem;
}

/* ============================================================================
   STATS GRID
   ============================================================================ */

.stats-grid {
  display: grid;
  gap: 0.75rem;
  position: relative;
  z-index: 1;
}

.stats-grid--core {
  grid-template-columns: repeat(3, 1fr);
}

.stats-grid--combat {
  grid-template-columns: repeat(4, 1fr);
}

/* ============================================================================
   STAT CARD (Glass Element)
   ============================================================================ */

.stat-card {
  --stat-color: var(--accent, #5dd6c9);
  position: relative;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)),
    radial-gradient(circle at top right, color-mix(in srgb, var(--stat-color) 6%, transparent), transparent 70%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.875rem;
  padding: 0.875rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.03), transparent);
  pointer-events: none;
  border-radius: inherit;
}

.stat-card:hover {
  border-color: color-mix(in srgb, var(--stat-color) 35%, transparent);
  box-shadow:
    0 4px 20px rgba(0,0,0,0.2),
    0 0 16px color-mix(in srgb, var(--stat-color) 10%, transparent);
  transform: translateY(-2px);
}

/* ============================================================================
   STAT HEADER (Icon + Name + Total)
   ============================================================================ */

.stat-card-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  position: relative;
  z-index: 1;
}

/* Icon Circle */
.stat-icon {
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: color-mix(in srgb, var(--stat-color) 15%, transparent);
  color: var(--stat-color);
  border: 1px solid color-mix(in srgb, var(--stat-color) 30%, transparent);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.08);
  box-shadow: 0 0 12px color-mix(in srgb, var(--stat-color) 25%, transparent);
}

.stat-icon i {
  filter: drop-shadow(0 1px 3px color-mix(in srgb, var(--stat-color) 40%, transparent));
}

/* Name + Breakdown */
.stat-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.stat-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text, #e6edf3);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-breakdown {
  font-size: 0.65rem;
  color: var(--muted, #8b949e);
  line-height: 1.3;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-buff-sum {
  color: var(--ok, #43d19e);
  font-weight: 600;
}

.stat-debuff-sum {
  color: var(--danger, #ff6b6b);
  font-weight: 600;
}

/* Total Value */
.stat-total {
  text-align: right;
  flex-shrink: 0;
}

.stat-total-value {
  font-size: 1.5rem;
  font-weight: 900;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  line-height: 1;
  background: linear-gradient(135deg,
    var(--stat-color) 0%,
    color-mix(in srgb, var(--stat-color) 70%, #fff) 50%,
    var(--stat-color) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: statTextShimmer 4s linear infinite;
}

@keyframes statTextShimmer {
  0%   { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* ============================================================================
   BASE VALUE ROW
   ============================================================================ */

.stat-base-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  position: relative;
  z-index: 1;
}

.stat-base-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #8b949e);
  flex-shrink: 0;
}

.stat-base-input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  text-align: center;
  color: var(--text, #e6edf3);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  -moz-appearance: textfield;
}

.stat-base-input::-webkit-outer-spin-button,
.stat-base-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stat-base-input:focus {
  outline: none;
  background: rgba(255,255,255,0.07);
  border-color: color-mix(in srgb, var(--stat-color) 50%, transparent);
  box-shadow: 0 0 0 0.15rem color-mix(in srgb, var(--stat-color) 15%, transparent);
}

/* Dirty state indicator */
.stat-base-input.is-dirty {
  border-color: rgba(255,211,107,0.5);
  box-shadow: 0 0 0 0.15rem rgba(255,211,107,0.1);
}

/* ============================================================================
   MODIFIERS TOGGLE
   ============================================================================ */

.stat-mods-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted, #8b949e);
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  z-index: 1;
}

.stat-mods-toggle:hover {
  color: var(--text, #e6edf3);
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.12);
}

.stat-mods-toggle i:first-child {
  font-size: 0.7rem;
  color: color-mix(in srgb, var(--stat-color) 60%, var(--muted));
}

.stat-mods-toggle span {
  flex: 1;
  text-align: left;
}

.stat-mods-chevron {
  font-size: 0.55rem;
  transition: transform 0.3s ease;
}

.stat-mods-toggle[aria-expanded="true"] .stat-mods-chevron {
  transform: rotate(180deg);
}

/* ============================================================================
   MODIFIERS PANEL (Glass Inset)
   ============================================================================ */

.stat-mods-panel {
  margin-top: 0.5rem;
  position: relative;
  z-index: 1;
}

.stat-mods-panel > .stat-mods-list,
.stat-mods-panel > .stat-mod-add {
  padding: 0.4rem;
  background:
    linear-gradient(135deg, rgba(0,0,0,0.15), rgba(0,0,0,0.08)),
    radial-gradient(circle at bottom right, rgba(255,255,255,0.02), transparent 60%);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 0.625rem;
  margin-bottom: 0.35rem;
}

/* ============================================================================
   MODIFIER PILLS (Buff/Debuff)
   ============================================================================ */

.stat-mods-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.stat-mod-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 2rem;
  font-size: 0.7rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-mod-pill:hover {
  transform: translateY(-1px);
}

/* Buff */
.stat-mod-pill--buff {
  background: rgba(67,209,158,0.1);
  border: 1px solid rgba(67,209,158,0.25);
  color: var(--ok, #43d19e);
}

.stat-mod-pill--buff:hover {
  box-shadow: 0 2px 8px rgba(67,209,158,0.15);
}

/* Debuff */
.stat-mod-pill--debuff {
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.25);
  color: var(--danger, #ff6b6b);
}

.stat-mod-pill--debuff:hover {
  box-shadow: 0 2px 8px rgba(255,107,107,0.15);
}

.stat-mod-label {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-mod-value {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-weight: 800;
  font-size: 0.75rem;
}

/* Remove Button on Pill */
.stat-mod-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: inherit;
  font-size: 0.55rem;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.stat-mod-remove:hover {
  opacity: 1;
  background: rgba(255,107,107,0.3);
  color: #fff;
  transform: scale(1.15);
}

/* ============================================================================
   ADD MODIFIER ROW
   ============================================================================ */

.stat-mod-add-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.stat-mod-input {
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text, #e6edf3);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.stat-mod-input:focus {
  outline: none;
  background: rgba(255,255,255,0.07);
  border-color: rgba(93,214,201,0.4);
  box-shadow: 0 0 0 0.15rem rgba(93,214,201,0.1);
}

.stat-mod-input::placeholder {
  color: rgba(255,255,255,0.25);
}

.stat-mod-input.mod-label-input {
  flex: 1;
  min-width: 0;
}

.stat-mod-input.mod-value-input {
  width: 3.5rem;
  text-align: center;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-weight: 700;
  -moz-appearance: textfield;
}

.stat-mod-input.mod-value-input::-webkit-outer-spin-button,
.stat-mod-input.mod-value-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Add Buff Button */
.btn-add-mod {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  border-radius: 0.5rem;
  border: 1px solid;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.btn-add-mod--buff {
  background: rgba(67,209,158,0.12);
  border-color: rgba(67,209,158,0.3);
  color: var(--ok, #43d19e);
}

.btn-add-mod--buff:hover {
  background: rgba(67,209,158,0.25);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(67,209,158,0.2);
}

.btn-add-mod--debuff {
  background: rgba(255,107,107,0.12);
  border-color: rgba(255,107,107,0.3);
  color: var(--danger, #ff6b6b);
}

.btn-add-mod--debuff:hover {
  background: rgba(255,107,107,0.25);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(255,107,107,0.2);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 992px) {
  .stats-grid--core {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-grid--combat {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .stats-grid--core,
  .stats-grid--combat {
    grid-template-columns: 1fr;
  }

  #stats > form > .stats-card {
    padding: 0.875rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-total-value {
    font-size: 1.25rem;
  }

  .stat-icon {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    font-size: 0.8rem;
  }

  .stat-name {
    font-size: 0.75rem;
  }

  .stats-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .btn-save-stats {
    width: 100%;
    justify-content: center;
  }

  .stat-mod-label {
    max-width: 70px;
  }

  .btn-save-stats--bottom {
    max-width: 100%;
  }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .stat-total-value {
    animation: none;
  }

  .stat-card,
  .stat-icon,
  .stat-mod-pill,
  .btn-save-stats,
  .btn-add-mod,
  .stat-mod-remove {
    transition: none;
  }
}

/* ============================================================================
   FORM RESET (prevent Bootstrap default styling leaking in)
   ============================================================================ */

.stats-save-form {
  all: unset;
  display: block;
}

#stats .card.shadow-sm {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
}
