/* Global Styles */
html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
}

/* Header */
.header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid #e0e0e0;
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.auth-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #fff;
  color: #333;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.auth-btn:hover {
  background: #f5f5f5;
}

.auth-btn.primary {
  background: #1565c0;
  color: white;
  border-color: #1565c0;
}

.auth-btn.primary:hover {
  background: #0d47a1;
}

.auth-btn.danger {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
}

.auth-btn.danger:hover {
  background: #b91c1c;
}

.welcome-text {
  color: #374151;
  font-size: 14px;
  padding: 8px 16px;
}

/* Main Content Wrapper */
.wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 40px 80px;
  background: #f6f7fb;
}

/* Buttons */
.btn {
  width: 320px;
  height: 120px;
  border-radius: 12px;
  border: 0;
  background: #1565c0;
  color: white;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Output Display */
.output {
  width: 90%;
  max-width: 1000px;
  margin-top: 24px;
  background: white;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.jsonbox {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  background: #0f1724;
  color: #dbeafe;
  border-radius: 6px;
}

/* Card Gallery */
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.card {
  width: 120px;
  text-align: center;
  font-size: 12px;
}

.card img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: #eee;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.small {
  font-size: 12px;
  color: #333;
  margin-top: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Navigation Footer */
.nav-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #e0e0e0;
  backdrop-filter: blur(10px);
  padding: 12px 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
  text-decoration: none;
}

.nav-btn:hover {
  background: rgba(21, 101, 192, 0.08);
}

.nav-btn.active {
  background: rgba(21, 101, 192, 0.12);
}

.nav-btn svg {
  width: 28px;
  height: 28px;
  fill: #374151;
  transition: fill 0.2s ease;
}

.nav-btn:hover svg,
.nav-btn.active svg {
  fill: #1565c0;
}

/* Login Page Specific Styles */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f3f4f6;
  padding: 20px;
}

.login-card {
  width: 400px;
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 20px;
  text-align: center;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.tab:hover {
  background: #f9fafb;
}

.form-section {
  display: none;
}

.form-section.active {
  display: block;
}

label {
  display: block;
  font-size: 13px;
  margin-top: 12px;
  color: #374151;
}

input {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

button[type="submit"],
button#logoutBtn,
button#continueBtn {
  width: 100%;
  margin-top: 16px;
  padding: 11px;
  border: 0;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
}

button[type="submit"]:hover:not(:disabled) {
  background: #1d4ed8;
}

button#logoutBtn {
  background: #dc2626;
  margin-top: 10px;
}

button#logoutBtn:hover {
  background: #b91c1c;
}

button#continueBtn {
  background: #059669;
  margin-top: 8px;
}

button#continueBtn:hover {
  background: #047857;
}

.msg {
  margin-top: 12px;
  font-size: 13px;
  color: #111;
}

.err {
  color: #dc2626;
}

.ok {
  color: #059669;
}

#welcomeText {
  font-size: 14px;
  color: #374151;
  margin: 10px 0;
}

.switch-form {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: #6b7280;
}

.switch-form a {
  color: #2563eb;
  text-decoration: none;
  cursor: pointer;
}

.switch-form a:hover {
  text-decoration: underline;
}

.suggestions {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.suggestions h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

.suggestion-btn {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  text-decoration: none;
}

.suggestion-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* Collection Page Styles */
.collection-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.collection-header {
  text-align: center;
  margin-bottom: 32px;
  color: #374151;
}

.collection-header h1 {
  font-size: 36px;
  margin-bottom: 8px;
}

.collection-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-box {
  background: white;
  padding: 16px 32px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-label {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 32px;
  font-weight: bold;
  color: #1565c0;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
}

.collection-card {
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.collection-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.card-image-container {
  position: relative;
  width: 100%;
  padding-bottom: 140%;
  overflow: hidden;
  border-radius: 8px;
  background: #f3f4f6;
}

.card-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.quantity-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 3px solid white;
}

.card-info {
  margin-top: 12px;
  text-align: center;
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-rarity {
  font-size: 12px;
  color: #6b7280;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

.rarity-common {
  background: #e5e7eb;
  color: #4b5563;
}

.rarity-uncommon {
  background: #dbeafe;
  color: #1e40af;
}

.rarity-rare {
  background: #fef3c7;
  color: #92400e;
}

.rarity-rare-holo {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  font-weight: bold;
}

.rarity-energy {
  background: #dcfce7;
  color: #166534;
}

/* Missing card styles */
.collection-card.missing {
  opacity: 0.5;
  cursor: default;
}

.collection-card.missing:hover {
  transform: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.missing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  z-index: 1;
}

.missing-label {
  background: #dc2626;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.set-section {
  margin-bottom: 32px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.set-section:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.set-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: white;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
  border-bottom: 1px solid #e5e7eb;
}

.set-header:hover {
  background: #f9fafb;
}

.set-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.set-title {
  font-size: 24px;
  color: #374151;
  font-weight: bold;
  margin: 0;
}

.set-count {
  font-size: 14px;
  color: #6b7280;
  padding: 4px 12px;
  background: #f3f4f6;
  border-radius: 12px;
}

.set-duplicates-count {
  font-size: 14px;
  color: #1565c0;
  padding: 4px 12px;
  background: #e3f2fd;
  border-radius: 12px;
  font-weight: 600;
}

.set-duplicates-count.hidden {
  display: none;
}

.toggle-icon {
  width: 32px;
  height: 32px;
  transition: all 0.2s ease;
  color: #1565c0;
  flex-shrink: 0;
  background: #e3f2fd;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  font-family: monospace;
}

.toggle-icon.collapsed::after {
  content: '+';
}

.toggle-icon:not(.collapsed)::after {
  content: '−';
  position: relative;
  top: -1px;
}

.set-content {
  max-height: 10000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  opacity: 1;
  padding: 20px;
}

.set-content.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0 20px;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e5e7eb;
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #6b7280;
}

.empty-state h2 {
  font-size: 24px;
  margin-bottom: 12px;
  color: #374151;
}

.empty-state p {
  font-size: 16px;
  margin-bottom: 24px;
}

.empty-state a {
  display: inline-block;
  padding: 12px 24px;
  background: #1565c0;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}

.empty-state a:hover {
  background: #0d47a1;
}

/* Utility Classes */
.hidden {
  display: none;
}

#loginPrompt {
  text-align: center;
  padding: 40px 20px;
}

#loginPrompt h2 {
  color: #374151;
  margin-bottom: 16px;
}

#loginPrompt p {
  color: #6b7280;
  margin-bottom: 24px;
}

#loginPrompt .auth-btn {
  font-size: 16px;
  padding: 12px 24px;
}

#packButtons {
  text-align: center;
  gap: 12px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

#openJungleBtn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.output-header {
  margin-top: 12px;
}

/* Collection Filters */
.collection-filters {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.collection-sort {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 14px;
  color: #374151;
  font-weight: 600;
}

.filter-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: 2px solid #e5e7eb;
  background: white;
  color: #374151;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.filter-btn:hover {
  border-color: #1565c0;
  background: #f0f9ff;
}

.filter-btn.active {
  border-color: #1565c0;
  background: #1565c0;
  color: white;
}

.filter-btn.active:hover {
  background: #0d47a1;
  border-color: #0d47a1;
}

.filter-btn:disabled {
  cursor: not-allowed !important;
  background: #d1d5db !important;
  color: #6b7280 !important;
  border-color: #9ca3af !important;
  pointer-events: none !important;
  opacity: 1 !important;
}

.filter-btn:disabled:hover {
  background: #d1d5db !important;
  border-color: #9ca3af !important;
  color: #6b7280 !important;
}
