/**
 * ========================================================
 * Account Dashboard - Badges Modal Styles
 * ========================================================
 * Production badges modal using refined design from homepage
 * Horizontal tabs, proper modal positioning, image support
 * Enhanced animations and visual polish
 * ========================================================
 */

/* ===== Modal Positioning Fix ===== */
.dashboard-container .badges-modal .modal-content {
  background: linear-gradient(165deg, #1c1c1c 0%, #232323 100%);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 900px !important;
  width: 90% !important;
  max-height: calc(100vh - (var(--site-header-height, 85px) + 56px)) !important;
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  display: block !important;
  flex-direction: unset !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: translate(-50%, -50%) translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) translateY(0);
    opacity: 1;
  }
}

@media (max-height: 700px) {
  .dashboard-container .badges-modal .modal-content {
    position: relative !important;
    transform: none !important;
    top: unset !important;
    left: unset !important;
    margin: 12px auto !important;
    max-height: calc(100vh - (var(--site-header-height, 85px) + 48px)) !important;
    overflow-y: auto !important;
  }
}

/* Container for badges */
#badges-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem;
  width: 100%;
  overflow: visible;
}

/* Scrollbar styling for modal content */
.badge-tabs {
  display: flex;
  border-bottom: var(--border-1px);
  background: transparent;
  margin-bottom: 1.5rem;
}

.badge-tab {
  flex: 1;
  padding: 0.75rem 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 500;
  font-family: 'Playfair Display', serif;
  color: var(--color-subdued-white);
  transition: all 0.3s ease;
  text-align: center;
}

.badge-tab:hover {
  color: #fff;
}

.badge-tab.active {
  background: var(--action-button-gradient);
  border-bottom: 3px groove #112547;
  color: var(--color-active);
  border-radius: 6px 6px 0 0;
  text-shadow: 0 0 8px rgba(158, 240, 249, 0.5);
}

.badge-tab-count {
  display: block;
  font-size: 0.75em;
  margin-top: 0.25rem;
  opacity: 0.8;
}

/* ===== Tab Content Panels ===== */
.badge-tab-panel {
  display: none;
}

.badge-tab-panel.active {
  display: block;
  animation: fadeInPanel 0.3s ease;
}

@keyframes fadeInPanel {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Horizontal Tabs (Like Account Settings) ===== */
.badge-tabs {
  display: flex;
  border-bottom: var(--border-1px);
  background: transparent;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.badge-tab {
  flex: 1;
  min-width: 100px;
  padding: 0.75rem 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 500;
  font-family: 'Playfair Display', serif;
  color: var(--color-subdued-white);
  transition: all 0.3s ease;
  text-align: center;
  white-space: nowrap;
}

.badge-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.badge-tab.active {
  background: linear-gradient(135deg, rgba(158, 240, 249, 0.15) 0%, rgba(158, 240, 249, 0.05) 100%);
  border-bottom: 3px solid rgba(158, 240, 249, 0.8);
  color: var(--color-active);
  border-radius: 6px 6px 0 0;
  text-shadow: 0 0 8px rgba(158, 240, 249, 0.5);
}

.badge-tab-count {
  display: block;
  font-size: 0.75em;
  margin-top: 0.25rem;
  opacity: 0.8;
}

/* ===== Tab Content Panels ===== */
.badge-tab-panel {
  display: none;
}

.badge-tab-panel.active {
  display: block;
  animation: fadeInPanel 0.3s ease;
}

@keyframes fadeInPanel {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Scrollbar styling for modal content */
.dashboard-container .badges-modal .modal-content::-webkit-scrollbar {
  width: 8px;
}

.dashboard-container .badges-modal .modal-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.dashboard-container .badges-modal .modal-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.dashboard-container .badges-modal .modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ===== Badge Item (Card) ===== */
.badge-item {
  background: linear-gradient(135deg, #252525 0%, #1a1a1a 100%);
  border: 2px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
}

.badge-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.badge-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
}

.badge-item:hover::before {
  opacity: 1;
}

/* Tier colors */
.badge-item.tier-bronze {
  color: #CD7F32;
}

.badge-item.tier-silver {
  color: #C0C0C0;
}

.badge-item.tier-gold {
  color: #FFD700;
}

.badge-item.tier-platinum {
  color: #E5E4E2;
}

/* ===== Badge Icon Container ===== */
.badge-icon-container {
  width: 90px;
  height: 90px;
  margin: 0 auto 1rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.03), transparent);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Image support for badges */
.badge-icon {
  width: 75px;
  height: 75px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease, filter 0.3s ease;
}

.badge-item:hover .badge-icon {
  transform: scale(1.1) rotate(5deg);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
}

/* Lock overlay for locked badges */
.badge-lock-overlay {
  position: absolute;
  bottom: -5px;
  right: -5px;
  font-size: 1.75rem;
  color: inherit; /* Inherit tier color from parent badge-item */
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Earned badge styling */
.badge-item.earned .badge-icon-container {
  background: radial-gradient(circle, rgba(158, 240, 249, 0.15), transparent);
  border-color: rgba(158, 240, 249, 0.5);
  box-shadow: 0 0 15px rgba(158, 240, 249, 0.2);
  animation: badgeGlow 3s ease-in-out infinite;
}

@keyframes badgeGlow {
  0%, 100% {
    box-shadow: 0 0 15px rgba(158, 240, 249, 0.2);
  }
  50% {
    box-shadow: 0 0 25px rgba(158, 240, 249, 0.4);
  }
}

.badge-item.earned .badge-icon {
  filter: drop-shadow(0 0 10px rgba(158, 240, 249, 0.5));
}

/* Locked badge styling */
.badge-item.locked .badge-icon {
  filter: grayscale(100%) opacity(0.3);
}

.badge-item.locked:hover .badge-icon {
  filter: grayscale(100%) opacity(0.5);
}

/* ===== Badge Info ===== */
.badge-info {
  padding-top: 0.5rem;
}

.badge-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
  line-height: 1.3;
}

.badge-desc {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 1rem 0;
  line-height: 1.4;
}

.badge-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.badge-tier {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  color: currentColor;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-requirement {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  text-align: center;
  line-height: 1.3;
}

.badge-date {
  font-size: 0.75em;
  color: #888;
  font-style: italic;
}

.badge-points {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(158, 240, 249, 0.15);
  color: var(--color-active);
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(158, 240, 249, 0.5);
  border: 1px solid rgba(158, 240, 249, 0.2);
}

/* ===== Hover Tooltip (Slide Up) ===== */
.badge-tooltip {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.85));
  padding: 1rem;
  transform: translateY(100%);
  opacity: 0;
  transition: all 0.3s ease;
  border-top: 2px solid rgba(158, 240, 249, 0.3);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.badge-tooltip-text {
  font-size: 0.8em;
  color: #bbb;
  line-height: 1.4;
  margin: 0;
  text-align: left;
}

.badge-item.locked .badge-tooltip {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.badge-item.earned .badge-tooltip {
  border-top-color: var(--color-active);
  box-shadow: 0 -4px 15px rgba(158, 240, 249, 0.2);
}

/* ===== Loading & Error States ===== */
.badges-loading,
.badges-error,
.no-badges {
  text-align: center;
  padding: 4rem 2rem;
  color: #888;
}

.badges-loading {
  font-style: italic;
}

.badges-error {
  color: #f44336;
}

.badges-error .retry-btn {
  margin-top: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--action-button-gradient);
  color: var(--color-subdued-white);
  border: var(--border-1px);
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Playfair Display', serif;
  box-shadow: var(--box-shadow-header);
  text-shadow: 1px 1px 1px #000;
  transition: all 0.2s ease;
}

.badges-error .retry-btn:hover {
  filter: brightness(1.5);
  color: var(--color-active);
  transform: translateY(-4px);
}

.no-badges svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.2;
  color: #666;
}

.no-badges p {
  margin: 0;
  font-size: 1.1em;
  color: #888;
}

/* ===== Badge Detail Modal (Modal-within-Modal) ===== */
.badge-detail-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: radial-gradient(circle at center, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.9) 100%);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999 !important;
  animation: fadeIn 0.3s ease-out;
}

.badge-detail-modal.active {
  display: flex !important;
}

.badge-detail-content {
  background: linear-gradient(165deg, #1c1c1c 0%, #232323 100%);
  border-radius: 8px;
  border: var(--border-1px);
  max-width: 450px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
  box-shadow: var(--box-shadow-modal);
  animation: scaleIn 0.3s ease-out;
  z-index: 100000 !important;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.close-detail {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2em;
  color: #888;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s ease;
}

.close-detail:hover {
  color: var(--color-active);
  transform: rotate(90deg);
  text-shadow: 0 0 10px rgba(158, 240, 249, 0.5);
}

.badge-detail-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.badge-detail-icon {
  width: 120px;
  height: 120px;
  margin: 0 auto 1rem;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05), transparent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.1);
}

.badge-detail-icon.earned {
  background: radial-gradient(circle, rgba(158, 240, 249, 0.2), transparent);
  border-color: var(--color-active);
  box-shadow: 0 0 40px rgba(158, 240, 249, 0.3);
  animation: badgeGlow 3s ease-in-out infinite;
}

.badge-detail-icon img {
  width: 90px;
  height: 90px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.badge-detail-icon.earned img {
  filter: drop-shadow(0 0 15px rgba(158, 240, 249, 0.6));
}

.badge-detail-icon svg {
  width: 80px;
  height: 80px;
  color: #47607c;
}

.badge-detail-icon.earned svg {
  color: var(--color-active);
  filter: drop-shadow(0 0 15px rgba(158, 240, 249, 0.6));
}

.badge-detail-content h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5em;
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px 4px #000;
}

.badge-detail-inscription {
  text-align: center;
  color: #aaa;
  margin-bottom: 1.5rem;
  font-style: italic;
  line-height: 1.5;
  font-size: 0.9em;
}

.badge-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  border-radius: 6px;
  text-align: center;
  border: var(--border-1px);
}

.stat-label {
  display: block;
  font-size: 0.7em;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 0.4rem;
}

.stat-value {
  display: block;
  font-size: 1.2em;
  font-weight: 700;
  color: var(--color-active);
  text-shadow: 0 0 8px rgba(158, 240, 249, 0.5);
}

.badge-unlock-requirements {
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 6px;
  border-left: 3px solid var(--color-active);
}

.badge-unlock-requirements h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1em;
  color: var(--color-active);
  text-shadow: 0 0 6px rgba(158, 240, 249, 0.3);
}

.badge-unlock-requirements p {
  margin: 0;
  color: #bbb;
  line-height: 1.6;
  font-size: 0.9em;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .dashboard-container .badges-modal .modal-content {
    width: 95%;
    max-width: 95%;
  max-height: calc(100vh - (var(--site-header-height, 85px) + 56px));
  }
  
  .badge-tab {
    font-size: 0.85em;
    padding: 0.6rem 0.4rem;
  }
  
  #badges-container {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }
  
  .badge-icon-container {
    width: 80px;
    height: 80px;
  }
  
  .badge-icon {
    width: 60px;
    height: 60px;
  }
  
  .badge-icon-container svg {
    width: 50px;
    height: 50px;
  }
  
  .badge-tooltip {
    padding: 0.75rem;
  }
  
  .badge-tooltip-text {
    font-size: 0.75em;
  }
  
  .badge-detail-stats {
    grid-template-columns: 1fr;
  }
}
