/* MTG Commander Deck Builder - Multi-user Dark Theme */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
  color: #e0e0e0;
  min-height: 100vh;
}

/* =============================================================================
   AUTH VIEW
   ============================================================================= */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-box {
  background: #2d2d44;
  border: 2px solid #3d3d54;
  border-radius: 15px;
  padding: 40px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.auth-box h1 {
  text-align: center;
  color: #f9a825;
  margin-bottom: 10px;
  font-size: 2rem;
}

.auth-subtitle {
  text-align: center;
  color: #b0b0b0;
  margin-bottom: 30px;
  font-size: 0.95rem;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 25px;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  background: #1e1e2e;
  color: #b0b0b0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.auth-tab.active {
  background: #f9a825;
  color: #1e1e2e;
  font-weight: bold;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  color: #b0b0b0;
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group input {
  padding: 12px;
  background: #1e1e2e;
  color: #e0e0e0;
  border: 1px solid #3d3d54;
  border-radius: 8px;
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: #f9a825;
}

.error-message {
  color: #ff5252;
  font-size: 0.9rem;
  min-height: 20px;
}

.btn-primary {
  padding: 14px;
  background: #f9a825;
  color: #1e1e2e;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #ffa726;
}

/* =============================================================================
   NAVBAR
   ============================================================================= */

.navbar {
  background: #2d2d44;
  border-bottom: 2px solid #3d3d54;
  padding: 15px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar h1 {
  font-size: 1.3rem;
  color: #f9a825;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo {
  height: 36px;
  width: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.auth-logo {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 15px;
  display: block;
  box-shadow: 0 0 20px rgba(249, 168, 37, 0.3);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.nav-username {
  color: #e0e0e0;
  font-weight: 500;
}

/* =============================================================================
   CONTAINER & LAYOUT
   ============================================================================= */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.5rem;
  color: #f9a825;
  margin-bottom: 10px;
}

header p {
  color: #b0b0b0;
  font-size: 1.1rem;
}

/* =============================================================================
   UPLOAD SECTION
   ============================================================================= */

.upload-box {
  background: #2d2d44;
  border: 2px solid #3d3d54;
  border-radius: 15px;
  padding: 40px;
  max-width: 600px;
  margin: 0 auto;
}

.upload-box h2 {
  color: #f9a825;
  margin-bottom: 10px;
  text-align: center;
}

.upload-box p {
  color: #b0b0b0;
  text-align: center;
  margin-bottom: 30px;
}

.upload-area {
  margin-bottom: 20px;
}

.drop-zone {
  border: 3px dashed #5d5d74;
  border-radius: 12px;
  padding: 60px 20px;
  text-align: center;
  transition: all 0.3s;
  cursor: pointer;
  background: rgba(61, 61, 84, 0.3);
}

.drop-zone.drag-over {
  border-color: #f9a825;
  background: rgba(249, 168, 37, 0.1);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.drop-zone-icon {
  font-size: 4rem;
}

.drop-zone p {
  color: #b0b0b0;
  margin: 0;
}

.drop-zone-or {
  color: #888;
  font-size: 0.9rem;
}

.btn-upload {
  padding: 12px 30px;
  background: #f9a825;
  color: #1e1e2e;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-upload:hover {
  background: #ffa726;
}

#uploadProgress {
  text-align: center;
  padding: 40px 20px;
}

#uploadStatus {
  font-size: 1.2rem;
  color: #f9a825;
  margin-top: 15px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.progress-bar {
  background: #1e1e2e;
  border-radius: 10px;
  height: 25px;
  overflow: hidden;
  margin-bottom: 15px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #43a047 0%, #66bb6a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  transition: width 0.3s;
}

.progress-fill.high {
  background: linear-gradient(90deg, #43a047 0%, #66bb6a 100%);
}

.progress-fill.medium {
  background: linear-gradient(90deg, #fb8c00 0%, #ffa726 100%);
}

.progress-fill.low {
  background: linear-gradient(90deg, #e53935 0%, #ef5350 100%);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 20px;
  margin-bottom: 30px;
}

.stat-item {
  background: #1e1e2e;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  color: #f9a825;
  font-weight: bold;
  margin-bottom: 5px;
}

.stat-label {
  display: block;
  color: #b0b0b0;
  font-size: 0.9rem;
}

/* =============================================================================
   CONTROLS & FILTERS
   ============================================================================= */

.controls {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-size: 0.9rem;
  color: #b0b0b0;
}

.filter-group select {
  padding: 10px;
  background: #2d2d44;
  color: #e0e0e0;
  border: 1px solid #3d3d54;
  border-radius: 5px;
  font-size: 1rem;
  min-width: 180px;
}

.btn-secondary {
  padding: 10px 20px;
  background: #3949ab;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #5c6bc0;
}

.btn-back {
  padding: 10px 20px;
  background: #424242;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin-bottom: 20px;
  font-size: 1rem;
}

.btn-back:hover {
  background: #616161;
}

/* =============================================================================
   COMMANDER GRID
   ============================================================================= */

.loading, .error {
  text-align: center;
  padding: 40px;
  font-size: 1.2rem;
}

.error {
  color: #ff5252;
}

.commander-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.commander-card {
  background: #2d2d44;
  border: 2px solid #3d3d54;
  border-radius: 10px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.commander-card:hover {
  border-color: #f9a825;
  transform: translateY(-5px);
  box-shadow: 0 5px 20px rgba(249, 168, 37, 0.3);
}

.commander-card .commander-preview {
  display: none;
}

@media (min-width: 769px) {
  .commander-card:hover .commander-preview {
    display: block;
    position: absolute;
    top: -10px;
    right: -10px;
    width: 200px;
    border-radius: 10px;
    border: 3px solid #f9a825;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
    z-index: 100;
    pointer-events: none;
  }
}

.commander-card h3 {
  color: #f9a825;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.commander-card .colors {
  font-size: 0.9rem;
  color: #b0b0b0;
  margin-bottom: 10px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.mana-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
}

#commanderHeader .colors .mana-icon,
#deckDetail .colors .mana-icon {
  width: 24px;
  height: 24px;
}

.commander-card .stats {
  font-size: 0.9rem;
  color: #b0b0b0;
}

.commander-card .replaceable-info {
  font-size: 0.8rem;
  color: #66bb6a;
  margin-top: 4px;
}

.cost-badge {
  display: inline-block;
  background: rgba(249, 168, 37, 0.15);
  color: #f9a825;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: bold;
  margin-left: 8px;
  font-size: 0.85rem;
}

.card-meta-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.rank-badge {
  font-size: 0.8rem;
  color: #b0b0b0;
  background: rgba(255,255,255,0.05);
  padding: 2px 6px;
  border-radius: 3px;
}

.salt-badge {
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 3px;
}
.salt-low { color: #81c784; background: rgba(129,199,132,0.1); }
.salt-med { color: #ffb74d; background: rgba(255,183,77,0.1); }
.salt-high { color: #ef5350; background: rgba(239,83,80,0.1); }

.card-themes { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 4px; }
.theme-tag { background: rgba(249,168,37,0.15); color: #f9a825; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; border: 1px solid rgba(249,168,37,0.3); }

.colors-label { color: #888; font-size: 0.75rem; margin-right: 4px; }

.avgmv-badge { background: rgba(100,150,255,0.15); color: #8ab4ff; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; border: 1px solid rgba(100,150,255,0.3); }

/* =============================================================================
   DECK DETAIL
   ============================================================================= */

#commanderHeader {
  display: flex;
  gap: 20px;
  margin-bottom: 25px;
  background: #2d2d44;
  padding: 20px;
  border-radius: 10px;
  align-items: center;
}

#commanderHeader img {
  width: 200px;
  border-radius: 10px;
  border: 3px solid #f9a825;
  cursor: pointer;
}

#commanderHeader .info h2 {
  color: #f9a825;
  margin-bottom: 10px;
  font-size: 1.8rem;
}

#commanderHeader .info .colors {
  font-size: 1.1rem;
  color: #b0b0b0;
  margin-bottom: 15px;
}

.commander-type {
  color: #b0b0b0;
  font-style: italic;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.edhrec-meta {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 15px;
  background: rgba(249, 168, 37, 0.08);
  border: 1px solid rgba(249, 168, 37, 0.2);
  border-radius: 8px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.meta-value {
  font-size: 1.2rem;
  font-weight: bold;
  color: #f9a825;
}

.meta-label {
  font-size: 0.75rem;
  color: #b0b0b0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-themes { flex-basis: 100%; }
.meta-themes .meta-value { font-size: 0.85rem; }

.deck-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.stat-box {
  background: #2d2d44;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #3d3d54;
}

.stat-box .value {
  font-size: 1.8rem;
  color: #f9a825;
  font-weight: bold;
}

.stat-box .label {
  font-size: 0.9rem;
  color: #b0b0b0;
  margin-top: 5px;
}

.btn-export {
  background: #43a047;
  color: white;
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  margin-bottom: 20px;
}

.btn-export:hover {
  background: #66bb6a;
}

.missing-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 15px;
  color: #b0b0b0;
  cursor: pointer;
  font-size: 0.95rem;
  vertical-align: middle;
}

.missing-filter input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #f9a825;
  cursor: pointer;
}

#exportBtnContainer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

/* =============================================================================
   CARD LIST
   ============================================================================= */

.card-list {
  display: grid;
  gap: 10px;
}

.card-category {
  background: #2d2d44;
  padding: 15px;
  border-radius: 8px;
}

.card-category h3 {
  color: #f9a825;
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.card-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px;
  background: #1e1e2e;
  border-radius: 5px;
  margin-bottom: 8px;
}

.card-item.owned {
  border-left: 4px solid #43a047;
}

.card-item.missing {
  border-left: 4px solid #e53935;
}

.card-thumb {
  width: 50px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s;
}

.card-thumb:hover {
  transform: scale(1.1);
}

.card-item .card-info {
  flex: 1;
}

.card-item .card-name {
  font-weight: bold;
  color: #e0e0e0;
  margin-bottom: 3px;
}

.card-item .card-status {
  font-size: 0.85rem;
  color: #b0b0b0;
}

.card-item .card-price {
  font-weight: bold;
  color: #f9a825;
}

.btn-replacements {
  background: #3949ab;
  color: white;
  border: none;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 5px;
  transition: background 0.2s;
}

.btn-replacements:hover {
  background: #5c6bc0;
}

/* =============================================================================
   INSIGHTS / PICKUPS
   ============================================================================= */

.pickups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
}

.pickup-card {
  background: #2d2d44;
  padding: 15px;
  border-radius: 8px;
  border: 2px solid #3d3d54;
}

.pickup-card img {
  width: 100%;
  height: auto;
  object-fit: contain;
  max-height: 260px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.pickup-card h4 {
  color: #f9a825;
  margin-bottom: 8px;
}

.pickup-card .appears-in {
  color: #43a047;
  font-weight: bold;
  margin-bottom: 5px;
}

.pickup-card .price {
  color: #b0b0b0;
  font-size: 0.9rem;
}

/* =============================================================================
   MODALS
   ============================================================================= */

.image-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.image-modal.active {
  display: flex;
}

.image-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
}

.image-modal-img {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  z-index: 1;
}

.replacements-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.replacements-modal.active {
  display: flex;
}

.replacements-modal-content {
  background: #2d2d44;
  border-radius: 12px;
  padding: 25px;
  max-width: 800px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.replacements-modal-content h3 {
  color: #f9a825;
  margin-bottom: 20px;
  font-size: 1.4rem;
  border-bottom: 2px solid #3d3d54;
  padding-bottom: 10px;
}

.replacement-list {
  display: grid;
  gap: 15px;
}

.replacement-item {
  display: flex;
  gap: 15px;
  background: #1e1e2e;
  border-radius: 8px;
  padding: 12px;
  border-left: 4px solid #43a047;
  align-items: center;
}

.replacement-item img.repl-thumb {
  width: 80px;
  height: 112px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s;
}

.replacement-item img.repl-thumb:hover {
  transform: scale(1.05);
}

.repl-info {
  flex: 1;
}

.repl-name {
  font-weight: bold;
  color: #f9a825;
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.repl-type {
  color: #b0b0b0;
  font-style: italic;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.repl-categories {
  color: #81c784;
  font-size: 0.85rem;
  background: rgba(129, 199, 132, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

.btn-close-repl {
  background: #424242;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 5px;
  cursor: pointer;
  margin-top: 20px;
  font-size: 1rem;
  width: 100%;
}

.btn-close-repl:hover {
  background: #616161;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
  .navbar h1 {
    font-size: 1.2rem;
  }
  
  .nav-right {
    flex-direction: column;
    gap: 8px;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-group select {
    min-width: 100%;
  }
  
  .commander-grid {
    grid-template-columns: 1fr;
  }
  
  .commander-card .commander-preview {
    display: none !important;
  }
  
  #commanderHeader {
    flex-direction: column;
    text-align: center;
  }
  
  #commanderHeader img {
    width: 100%;
    max-width: 300px;
  }
  
  .replacements-modal-content {
    padding: 20px;
    max-height: 90vh;
  }
  
  .replacement-item {
    flex-direction: column;
    text-align: center;
  }
  
  .replacement-item img.repl-thumb {
    width: 100%;
    max-width: 200px;
    height: auto;
  }
}
