/* LLM API Relay - Marketplace Responsive & UX Patch */
/* Loaded via /fixes/marketplace-styles.css — does NOT modify original styles */

/* ===== Missing CSS Variables Fix ===== */
:root {
  --error: var(--danger, #ef4444);
  --secondary-bg: var(--bg2, #1a1d27);
  --text-primary: var(--text, #e2e8f0);
  --accent: var(--primary, #6366f1);
  --bg-primary: var(--bg, #0f1117);
  --bg-secondary: var(--bg2, #1a1d27);
  --text-secondary: var(--text2, #94a3b8);
}

/* ===== Missing .btn-secondary ===== */
.btn-secondary {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}
.btn-secondary:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ===== Loading Spinner ===== */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(2px);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Button loading state */
.btn.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}
.btn.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 6px;
}

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.confirm-dialog {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: confirmPop 0.2s ease;
}
@keyframes confirmPop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.confirm-dialog h3 { margin-bottom: 8px; font-size: 16px; }
.confirm-dialog p { color: var(--text2); font-size: 13px; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.confirm-actions .btn { min-width: 100px; justify-content: center; }

/* ===== Dispute Modal ===== */
.dispute-modal .modal { max-width: 400px; }

/* ===== Toast Duration Fix ===== */
.toast.toast-error { animation: slideIn 0.3s; }
.toast.toast-error.persistent {
  animation: none;
  cursor: pointer;
}

/* ===== Recharge Buttons ===== */
.recharge-btn {
  min-width: 60px;
  transition: all 0.15s !important;
}
.recharge-btn:hover {
  border-color: var(--primary) !important;
  background: var(--primary-bg) !important;
}

/* ===== Provider Filter Cards ===== */
.provider-filter-card {
  transition: border-color 0.1s, background 0.1s, box-shadow 0.1s, opacity 0.1s !important;
  will-change: border-color, background, opacity;
}
.provider-filter-card:hover:not(.pf-selected) {
  border-color: var(--primary) !important;
  background: var(--primary-bg) !important;
}
.provider-filter-card.pf-selected {
  border-color: var(--primary) !important;
  background: var(--primary-bg) !important;
  box-shadow: 0 0 12px rgba(99,102,241,0.15) !important;
}
.provider-filter-card.pf-dimmed {
  opacity: 0.25 !important;
  pointer-events: none !important;
}
.listing-card {
  will-change: display;
}

/* ===== Card Footer Responsive ===== */
.listing-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
@media (max-width: 900px) {
  .listing-card .card-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .listing-card .card-footer > div:last-child {
    align-self: flex-end;
  }
}

/* ===== Mobile: 480px ===== */
@media (max-width: 480px) {
  header { padding: 8px 0 !important; }
  header .container { padding: 0 10px !important; }
  .logo { font-size: 15px !important; }
  nav { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { padding: 8px 10px !important; font-size: 12px !important; white-space: nowrap; }
  .container { padding: 0 10px !important; }
  .hero { padding: 24px 12px 20px !important; }
  .hero h1 { font-size: 20px !important; }
  .hero p { font-size: 12px !important; }
  .hero-buttons { flex-wrap: wrap; gap: 6px !important; }
  .hero-stats { gap: 16px !important; flex-wrap: wrap; }
  .hero-stat .num { font-size: 18px !important; }
  /* Cards */
  .listing-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  .card { padding: 12px !important; }
  /* Search */
  .search-bar { flex-direction: column; }
  .search-bar input { min-width: 100% !important; font-size: 16px; }
  .search-bar select { width: 100%; }
  /* Forms */
  .form-row {
    grid-template-columns: 1fr !important;
  }
  /* Wallet */
  .wallet-stats {
    grid-template-columns: 1fr !important;
  }
  /* Modal */
  .modal {
    padding: 16px !important;
    max-height: 90vh !important;
    border-radius: 12px !important;
  }
  /* Touch targets */
  nav button, .btn, [onclick] {
    min-height: 44px;
  }
  .btn-sm {
    padding: 8px 12px !important;
    font-size: 12px !important;
  }
  /* Header right */
  .header-right { gap: 4px; }
  .theme-btn { width: 36px; height: 36px; }
  .size-btn { padding: 6px 10px; }
}

/* ===== Tablet: 768px ===== */
@media (max-width: 768px) {
  header .container { flex-wrap: wrap; }
  nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .listing-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
  }
  /* Wallet 3-col → 2-col */
  .wallet-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Sell form 3-col → 1-col */
  .form-row {
    grid-template-columns: 1fr !important;
  }
  /* Hero responsive */
  .hero-stats { flex-wrap: wrap; gap: 20px; }
  /* Detail modal */
  .modal { max-width: 95vw !important; }
}
