/* Shared Hamburger Dropdown menu style */
.context-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  display: none;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  min-width: 180px;
  padding: 6px 0;
  z-index: 1300;
}
.context-menu a {
  display: block;
  padding: 10px 16px;
  color: #f8fafc;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s ease;
}
.context-menu a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #6366f1;
}

/* Global Header Layering to prevent overlaps */
.header {
  position: relative !important;
  z-index: 1100 !important;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2) !important;
}
.header-actions {
  position: relative !important;
}

/* Statistics Overlay (Glassmorphism backdrop, maintained for compatibility) */
.stats-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(9, 13, 22, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stats-overlay.show {
  display: flex;
  opacity: 1;
}

/* Premium Statistics Modal Card (used when overlay is fallback) */
.stats-modal {
  width: 450px;
  max-width: 92%;
  max-height: 85vh;
  background: rgba(17, 25, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  color: #f8fafc;
}

.stats-overlay.show .stats-modal {
  transform: translateY(0);
}

/* Modal / Page Stats Header */
.stats-header {
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
}

.stats-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.stats-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

/* Modal Content area */
.stats-content {
  padding: 16px 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}

.stats-content::-webkit-scrollbar {
  width: 6px;
}
.stats-content::-webkit-scrollbar-track {
  background: transparent;
}
.stats-content::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
}

/* Back navigation inside details */
.stats-back-btn {
  background: transparent;
  border: none;
  color: #6366f1;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  align-self: flex-start;
  transition: color 0.2s ease;
}

.stats-back-btn:hover {
  color: #818cf8;
  text-decoration: none;
}

/* Collection List Row */
.stats-collection-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  cursor: pointer;
  text-decoration: none;
  color: #f8fafc;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stats-collection-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

.stats-collection-title {
  font-weight: 600;
  color: #f8fafc;
  font-size: 15px;
}

.stats-collection-count {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Call-to-action block for guests */
.stats-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  gap: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
}

.stats-cta-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.stats-cta-title {
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
  font-family: 'Outfit', sans-serif;
}

.stats-cta-desc {
  font-size: 14px;
  color: #94a3b8;
  line-height: 1.5;
  margin: 0 0 12px 0;
  max-width: 320px;
}

.stats-cta-btn {
  background: #6366f1;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: all 0.2s ease;
}

.stats-cta-btn:hover {
  background: #4f46e5;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

/* Detailed Question Cards */
.stats-question-card {
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-question-card.answer-yes {
  border-left: 4px solid #10b981; /* green */
}

.stats-question-card.answer-no {
  border-left: 4px solid #ef4444; /* red */
}

.stats-question-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.stats-question-text {
  font-weight: 600;
  font-size: 14px;
  color: #f8fafc;
  line-height: 1.5;
  margin: 0;
}

.stats-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.stats-badge.yes {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.stats-badge.no {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Stats Comparison Numbers */
.stats-metrics-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.stats-metric-line {
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
}

.stats-metric-line strong {
  color: #f8fafc;
  font-weight: 600;
}

.stats-metric-icon {
  font-size: 13px;
  opacity: 0.85;
}

/* Loading / Spinner Styles */
.stats-loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  gap: 12px;
  color: #94a3b8;
}

.stats-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid #6366f1;
  border-radius: 50%;
  animation: stats-spin 0.8s linear infinite;
}

@keyframes stats-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.stats-empty-state {
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  padding: 30px 10px;
  line-height: 1.5;
}

/* Group Selector Header styling */
.stats-group-selector-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-group-select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-group-label {
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
}

.stats-group-select {
  padding: 6px 30px 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 600;
  background: #0f172a;
  color: #f8fafc;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

.stats-group-select:hover, .stats-group-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.stats-manage-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stats-manage-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
}

/* Group Management UI styling */
.group-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  margin: 20px 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.group-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.group-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #f8fafc;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.group-input:focus {
  border-color: #6366f1;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.group-btn-primary {
  background: #6366f1;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.group-btn-primary:hover {
  background: #4f46e5;
}

.group-card-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.group-card-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.group-card-name {
  font-weight: 600;
  font-size: 14px;
  color: #f8fafc;
}

.group-card-meta {
  font-size: 12px;
  color: #94a3b8;
}

.group-card-actions {
  display: flex;
  gap: 8px;
}

.group-btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.group-btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.group-member-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  margin-bottom: 6px;
}

.group-member-info {
  display: flex;
  flex-direction: column;
}

.group-member-username {
  font-weight: 600;
  font-size: 13px;
  color: #f8fafc;
}

.group-member-email {
  font-size: 11px;
  color: #94a3b8;
}

.group-owner-badge {
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Mini Swiped Card Statistics Overlay */
.swipe-stats-overlay {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  pointer-events: none;
  animation: swipeStatsFadeInOut 2.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  border: 1px solid rgba(255, 255, 255, 0.15);
  white-space: nowrap;
}

@keyframes swipeStatsFadeInOut {
  0% {
    opacity: 0;
    transform: translate(-50%, -15px);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -15px);
  }
}

/* Responsive adjustments for mobile screens */
@media (max-width: 600px) {
  /* Save space by reducing outer padding and spacing */
  .container {
    padding: 12px 10px !important;
    gap: 16px !important;
  }
  
  .app {
    padding: 12px 10px !important;
  }

  /* Make header fit without overflowing */
  .header {
    padding: 8px 12px !important;
    border-radius: 12px !important;
    margin-bottom: 12px !important;
  }

  .logo-section {
    gap: 6px !important;
  }

  .logo-section h1 {
    font-size: 22px !important;
  }

  .logo-badge {
    font-size: 9px !important;
    padding: 1px 4px !important;
    border-radius: 4px !important;
  }

  /* Handle sub-headings or extra details in the logo section (like in collections.html) */
  .logo-section > span {
    font-size: 13px !important;
    gap: 4px !important;
  }
  
  .logo-section > span > span[style*="opacity"] {
    display: none !important; /* Hide structural separator (|) on mobile */
  }

  /* Save space between action items */
  .header-actions,
  .header > div:nth-child(2),
  .header > div:last-child {
    gap: 6px !important;
  }

  /* Make user menu button compact (shows icon only) and match hamburger size */
  .user-btn {
    font-size: 16px !important;
    border-radius: 10px !important;
    width: 38px !important;
    height: 38px !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    display: inline-flex !important;
  }

  .user-btn#userMenuBtn {
    padding: 0 !important;
    display: inline-block !important; /* Render as block to support ::first-letter rule */
    text-align: center !important; /* Horizontally center the single visible emoji */
    line-height: 36px !important; /* Vertically center the single visible emoji */
    font-size: 0 !important; /* Hide all text by default */
  }

  .user-btn#userMenuBtn::first-letter {
    font-size: 16px !important; /* Force only the emoji icon to render at full size */
  }

  .user-btn#hamburgerBtn {
    padding: 0 !important;
    justify-content: center !important;
  }

  /* Ensure context dropdown works nicely on mobile */
  .context-menu {
    right: 0 !important;
    left: auto !important;
    min-width: 160px !important;
  }

  /* Optimize card and modal layouts for small screens */
  .stats-page-card {
    padding: 16px !important;
    border-radius: 16px !important;
    gap: 16px !important;
  }

  .stats-page-title-section {
    padding-bottom: 14px !important;
  }

  .stats-page-title-section h2 {
    font-size: 20px !important;
  }

  .auth-modal {
    padding: 20px !important;
    border-radius: 18px !important;
  }

  .stats-modal {
    max-height: 90vh !important;
  }

  .stats-header {
    padding: 14px 18px !important;
  }

  .stats-title {
    font-size: 16px !important;
  }

  /* Make stats dropdown and actions wrap elegantly on mobile */
  .stats-group-selector-container {
    flex-wrap: wrap !important;
    padding: 10px 14px !important;
    gap: 8px !important;
  }

  .stats-group-select-wrapper {
    width: 100% !important;
    justify-content: space-between !important;
  }

  .stats-group-select {
    flex-grow: 1 !important;
    max-width: 70% !important;
  }

  .stats-manage-btn {
    width: 100% !important;
    text-align: center !important;
  }

  /* Compact collection item lists in stats */
  .stats-collection-item {
    padding: 12px 14px !important;
  }

  .stats-collection-title {
    font-size: 13px !important;
  }

  .stats-collection-count {
    font-size: 11px !important;
    padding: 2px 8px !important;
  }
}

