/* ==========================================================================
   ITOCCHI GAMES — VIP USER PROFILE MODAL (HIGH-END GLASSMORPHISM)
   ========================================================================== */

/* Overlay */
.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(15, 23, 42, 0.88) 0%, rgba(2, 6, 23, 0.96) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overscroll-behavior: contain;
}

.profile-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Finestra Modale Principale */
.profile-modal-window {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 2px solid rgba(255, 215, 0, 0.6);
  border-radius: 28px;
  box-shadow: 
    0 25px 60px -15px rgba(0, 0, 0, 0.9),
    0 0 40px rgba(255, 215, 0, 0.25),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.profile-modal-overlay.active .profile-modal-window {
  transform: scale(1) translateY(0);
}

/* Header VIP del Modale */
.profile-modal-header {
  padding: 18px 24px;
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.12) 0%, transparent 100%);
  border-bottom: 1px solid rgba(255, 215, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.profile-header-user-summary {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Avatar con Cornice nel Header */
.profile-header-avatar-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #0f172a;
  display: block;
}

.profile-avatar-flag {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 1.2rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

.profile-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-header-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-header-nickname {
  font-family: 'Fredoka', 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.profile-header-title-badge {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.35) 100%);
  border: 1px solid #ffd700;
  color: #ffd700;
  padding: 2px 10px;
  border-radius: 99px;
  width: fit-content;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.profile-header-xp-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.profile-xp-track {
  width: 130px;
  height: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 99px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  overflow: hidden;
  position: relative;
}

.profile-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24, #ffd700);
  border-radius: 99px;
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.profile-level-tag {
  font-size: 0.75rem;
  font-weight: 900;
  color: #ffd700;
}

.btn-close-profile {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #94a3b8;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-close-profile:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #ffffff;
  transform: scale(1.08);
}

/* Tabs di Navigazione */
.profile-modal-tabs {
  display: flex;
  padding: 8px 16px 0 16px;
  background: rgba(10, 15, 30, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.profile-modal-tabs::-webkit-scrollbar {
  display: none;
}

.profile-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #94a3b8;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

.profile-tab-btn:hover {
  color: #e2e8f0;
}

.profile-tab-btn.active {
  color: #ffd700;
  border-bottom-color: #ffd700;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

/* Contenuto scorrevole delle Tab */
.profile-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.profile-tab-pane {
  display: none;
}

.profile-tab-pane.active {
  display: block;
  animation: tabFadeIn 0.3s ease;
}

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

/* Sezioni e Griglie */
.profile-section-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffd700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-form-group {
  margin-bottom: 22px;
}

.profile-input-row {
  display: flex;
  gap: 10px;
}

.profile-text-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(255, 215, 0, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  outline: none;
  transition: all 0.2s;
}

.profile-text-input:focus {
  border-color: #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.35);
}

.profile-select-custom {
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(255, 215, 0, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

/* Griglie di Selezione Avatar & Cornici */
.avatar-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.avatar-pick-item {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.25s;
  padding: 2px;
}

.avatar-pick-item img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-pick-item:hover {
  transform: scale(1.1);
}

.avatar-pick-item.selected {
  outline: 3px solid #ffd700;
  outline-offset: 2px;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  transform: scale(1.08);
}

/* Cornici Avatar (Frame Designs) */
.frame-classic {
  box-shadow: 0 0 0 2.5px #ffd700, 0 4px 10px rgba(0,0,0,0.6);
}
.frame-wood {
  box-shadow: 0 0 0 3px #854d0e, 0 0 0 4px #d97706, 0 4px 10px rgba(0,0,0,0.6);
}
.frame-silver {
  box-shadow: 0 0 0 2.5px #e2e8f0, 0 0 12px rgba(226, 232, 240, 0.5);
}
.frame-gold-vip {
  box-shadow: 0 0 0 3.5px #ffd700, 0 0 22px rgba(255, 215, 0, 0.95);
  animation: vipPulseGlow 1.8s infinite alternate;
}
.frame-neon-emerald {
  box-shadow: 0 0 0 3px #10b981, 0 0 20px rgba(16, 185, 129, 0.9);
}
.frame-fire {
  box-shadow: 0 0 0 3px #ef4444, 0 0 20px rgba(239, 68, 68, 0.95);
}
.frame-royal-crown {
  box-shadow: 0 0 0 3.5px #f59e0b, 0 0 25px rgba(245, 158, 11, 0.9);
}

@keyframes vipPulseGlow {
  0% { box-shadow: 0 0 0 3px #ffd700, 0 0 14px rgba(255, 215, 0, 0.7); }
  100% { box-shadow: 0 0 0 4px #fff, 0 0 28px rgba(255, 215, 0, 1); }
}

/* Griglia Cornici */
.frames-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.frame-pick-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.frame-pick-card:hover {
  background: rgba(255, 215, 0, 0.1);
  border-color: rgba(255, 215, 0, 0.5);
  transform: translateY(-2px);
}

.frame-pick-card.selected {
  border-color: #ffd700;
  background: rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.35);
}

.frame-preview-thumb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
}

.frame-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame-card-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #cbd5e1;
  text-align: center;
}

.vip-badge-mini {
  background: linear-gradient(135deg, #ffd700, #f59e0b);
  color: #000;
  font-size: 0.6rem;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 99px;
}

/* Griglia Retro Carte 3D */
.card-backs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
}

.card-back-pick-item {
  background: rgba(15, 23, 42, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.25s;
}

.card-back-pick-item:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 215, 0, 0.5);
}

.card-back-pick-item.selected {
  border-color: #ffd700;
  background: rgba(245, 158, 11, 0.2);
  box-shadow: 0 8px 20px rgba(0,0,0,0.6), 0 0 16px rgba(255, 215, 0, 0.4);
  transform: translateY(-4px) scale(1.03);
}

.card-back-mini-3d {
  width: 48px;
  height: 72px;
  border-radius: 5px;
  border: 1.5px solid #ffd700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.7);
  position: relative;
}

.card-back-mini-inner {
  width: 86%;
  height: 88%;
  border: 1px dashed rgba(255, 215, 0, 0.6);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* Griglia Feltri Tavolo */
.table-felts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.felt-pick-item {
  background: rgba(15, 23, 42, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.felt-pick-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 215, 0, 0.5);
}

.felt-pick-item.selected {
  border-color: #ffd700;
  background: rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.35);
}

.felt-oval-thumb {
  width: 68px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #ffd700;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.7), 0 4px 8px rgba(0,0,0,0.5);
}

/* Tab Statistiche & Trofei */
.stats-cards-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-metric-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-metric-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
}

.stat-metric-val {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.35rem;
  font-weight: 900;
  color: #ffd700;
}

.trophies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.trophy-item-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.trophy-item-card.unlocked {
  border-color: rgba(255, 215, 0, 0.6);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(15, 23, 42, 0.85) 100%);
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

.trophy-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255, 215, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.trophy-info h4 {
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 2px;
}

.trophy-info p {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.2;
}

/* Footer con Salva */
.profile-modal-footer {
  padding: 14px 24px;
  background: rgba(10, 15, 30, 0.8);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-profile-save {
  background: linear-gradient(135deg, #ffd700 0%, #f59e0b 100%);
  color: #000000;
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  font-weight: 900;
  padding: 10px 24px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.5);
  transition: all 0.2s;
}

.btn-profile-save:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.8);
}

/* ==================== RESPONSIVE PER MOBILE & TABLET ==================== */
@media (max-width: 768px) {
  .profile-modal-window {
    border-radius: 20px;
    max-height: 94dvh;
  }

  .profile-modal-header {
    padding: 14px 16px;
  }

  .profile-header-avatar-wrap {
    width: 50px;
    height: 50px;
  }

  .profile-header-nickname {
    font-size: 1.1rem;
  }

  .profile-modal-body {
    padding: 14px 16px;
  }

  .avatar-selection-grid {
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 8px;
  }

  .avatar-pick-item {
    width: 56px;
    height: 56px;
  }

  .card-backs-grid, .frames-selection-grid, .table-felts-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .trophies-grid {
    grid-template-columns: 1fr;
  }
}
