/* ══════════════════════════════════════════════════════════════
   Reusable Modal & Form Utility Classes
   Used across all modals to avoid inline color-bearing styles
   ══════════════════════════════════════════════════════════════ */

/* Modal inner padding wrapper */
.modal-pad {
  padding: 30px;
}
.modal-pad-sm {
  padding: 20px;
}

/* Section panel (gray bg card inside modal) */
.panel {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

/* Section headings inside modals */
.panel-title {
  margin: 0 0 15px 0;
  font-size: 16px;
  color: #333;
}

.panel-title-lg {
  margin: 0 0 15px 0;
  font-size: 18px;
  color: #333;
}

/* Form label (block, small) */
.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.form-label-sm {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 12px;
  color: #666;
}

.form-label-xs {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 13px;
  color: #333;
}

/* Form input/select/textarea */
.form-control {
  width: 100%;
  padding: 10px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  background: white;
  color: var(--text-primary);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.form-control-sm {
  width: 100%;
  padding: 8px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: var(--text-primary);
}

.form-control-sm:focus {
  outline: none;
  border-color: var(--color-primary);
}

/*
 * Price input paired with a compact currency picker. The amount input
 * stays the dominant field; the picker is a flex-shrink-0 select sized
 * to its longest contents (¥ JPY) so flipping codes doesn't reflow the
 * row. Used in owned-edit, ordered-edit, batch-order and edit-order
 * forms.
 */
.price-with-currency {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.price-with-currency > input {
  flex: 1 1 auto;
  /* Was min-width: 0 — combined with the currency select (~80px) and a
     narrow batch-card column the input could shrink to ~30px, hiding
     the typed value. 96px keeps "12345.67" visible while still
     allowing the grid cell to flex. */
  min-width: 96px;
}
.price-with-currency > select.price-currency-select {
  flex: 0 0 auto;
  width: auto;
  padding-right: 6px;
  cursor: pointer;
}

/* Muted text */
.text-muted {
  color: #666;
}
.text-muted-sm {
  font-size: 12px;
  color: #666;
}
.text-muted-xs {
  font-size: 11px;
  color: #999;
}

/* Primary color text */
.text-primary {
  color: var(--color-primary);
}

.text-success {
  color: #4caf50;
}

/* Warning panel (yellow) */
.panel-warning {
  padding: 15px;
  background: #fff3cd;
  border-radius: 6px;
  border: 2px solid #ffc107;
}

.panel-warning-title {
  margin: 0 0 10px 0;
  color: #856404;
}

.panel-warning-text {
  font-size: 14px;
  color: #856404;
}

/* Preview panel (gray) */
.panel-preview {
  padding: 15px;
  background: #f5f5f5;
  border-radius: 8px;
}

.panel-preview-text {
  margin: 0;
  color: #666;
  font-size: 14px;
}

/* Section divider */
.section-divider {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid var(--color-primary);
}

.section-divider-light {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid var(--border-color);
}

.section-divider-purple {
  padding-top: 20px;
  border-top: 2px solid #8b5cf6;
}

.section-divider-sm {
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

/* Section title (colored) */
.section-title {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 15px;
}

/* Button row at bottom of modal */
.modal-btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Confirm dialog footer */
.confirm-footer {
  padding: 20px 30px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Confirm dialog message */
.confirm-message {
  font-size: 16px;
  color: #333;
  line-height: 1.6;
  margin: 0;
}

/* Import warning divider */
.import-warning-divider {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
  color: #d97706;
}

/* Binder progress bar track */
.binder-progress-track {
  background: #e0e0e0;
}

/* Binder placeholder text (Cover/End) */
.binder-placeholder-text {
  color: #ccc;
}

/* Breadcrumb filter label */
.breadcrumb-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  margin-right: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Binder search filter panel */
.binder-filter-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #333;
}

/* Quick status label in owned modal */
.quick-status-label {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
  display: block;
}

/* Duplicate instances section */
.duplicate-section-header {
  font-size: 16px;
  color: #8b5cf6;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Modal styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.owned-edit-modal {
  z-index: var(--z-modal-stacked);
}

#confirmDialog {
  z-index: var(--z-confirm-dialog);
}

#orderedModal {
  z-index: var(--z-top-modal);
}

#confirmModal {
  z-index: var(--z-top-confirm);
}

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

.modal-content {
  background: white;
  border-radius: var(--radius-xl);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  position: relative;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s;
}

.modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.modal-body {
  padding: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.modal-image {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.modal-image img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-details {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.detail-label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
}

.detail-value {
  font-size: 16px;
  color: #333;
}

.detail-value .flag-icon {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  background: #f0f0f0;
  color: #333;
  font-size: 14px;
  font-weight: 600;
}

.type-badge .type-icon {
  width: 24px;
  height: 24px;
}

/* Market Prices Section */
#modalMarketPricesSection {
  margin-top: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.market-prices-header {
  margin-bottom: 10px;
}

.market-prices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.market-price-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid #e9ecef;
}

.market-price-card.cm {
  border-left: 3px solid #e74c3c;
}

.market-price-card.justtcg {
  border-left: 3px solid #3498db;
}

.market-price-source {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  margin-bottom: 6px;
}

.market-price-hero-row {
  display: flex;
  gap: 16px;
  align-items: baseline;
  justify-content: space-evenly;
}

.market-price-hero-col {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.market-price-main {
  font-size: 20px;
  font-weight: 700;
  color: #333;
  line-height: 1.2;
}

.market-price-label {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
}

.market-price-label-tip {
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  text-decoration-color: rgba(153, 153, 153, 0.4);
}

.market-price-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e9ecef;
}

.market-price-detail {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.market-price-detail-label {
  color: #999;
}

.market-price-detail-value {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: #555;
}

.market-price-updated {
  font-size: 11px;
  color: #bbb;
  margin-top: 6px;
  text-align: right;
}

.market-price-currency {
  font-weight: 400;
  opacity: 0.7;
}

.market-price-range {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #e9ecef;
}

.market-price-change {
  font-size: 9px;
  font-weight: 600;
}

.market-price-change.price-up {
  color: #27ae60;
}

.market-price-change.price-down {
  color: #e74c3c;
}

/* Source Section (unified) */
#modalSourceSection {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.source-section-header {
  margin-bottom: 8px;
}

.source-section-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-type-badge {
  display: inline-block;
  align-self: flex-start;
  background: #f0f0f0;
  color: #555;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.source-entry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-lang-label {
  display: inline-block;
  min-width: 24px;
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-align: center;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.source-img-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #f8f8f8;
  color: #666;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s;
}

.source-img-btn:hover {
  background: #e8e8ff;
  color: #4338ca;
  border-color: #a5b4fc;
}

.source-name {
  font-size: 13px;
  color: #333;
  font-weight: 500;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #2563eb;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}

.source-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* External Links Section */
#modalExternalLinksSection {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.external-links-header {
  margin-bottom: 8px;
}

.external-links-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.external-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  color: white;
}

.external-link:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.external-link.cm {
  background: #e74c3c;
}

.external-link.tcgp {
  background: #2980b9;
}

.external-link.bulba {
  background: #27ae60;
}

.external-link.pokep {
  background: #8e44ad;
}

/* Pokémon tags in modal */
.pokemon-tag {
  display: inline-block;
  background: #f0f4ff;
  color: #3b5998;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #d0d9ef;
  margin: 1px 2px;
  cursor: default;
  transition: background 0.15s;
}

.pokemon-tag:hover {
  background: #dce4f5;
}

/* Clickable filter elements in card modal */
.clickable-filter {
  cursor: pointer !important;
  transition: all 0.15s ease;
}

.clickable-filter:hover {
  background: rgba(102, 126, 234, 0.15);
  color: var(--color-primary);
  transform: translateY(-1px);
}

/* Uniform style for every clickable-filter chip in the card modal —
   info values (year, set, serie, size, illustrator, …), the stage
   badge, the type badge, the Pokémon tags, and modal lang-flag pills.
   Pill-shaped, content-width, transparent by default, tinted toast on
   hover, no layout shift.
   !important needed because each element type carries its own default
   background (type-badge: #f0f0f0, pokemon-tag: #f0f4ff,
   modal-lang-flag: var(--bg-primary), …). */
.info-value.clickable-filter,
.stage-badge.clickable-filter,
.type-badge.clickable-filter,
.pokemon-tag.clickable-filter,
.modal-lang-flag.clickable-filter {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  /* Negative left margin cancels the pill's left padding so the text
     itself aligns with non-clickable info-values above it. Right side
     keeps the padding so the toast still has breathing room. */
  margin-left: -9px;
  padding: 2px 8px;
  border-radius: 12px;
  background: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  color: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.info-value.clickable-filter:hover,
.stage-badge.clickable-filter:hover,
.type-badge.clickable-filter:hover,
.pokemon-tag.clickable-filter:hover,
.modal-lang-flag.clickable-filter:hover {
  background: rgba(102, 126, 234, 0.12) !important;
  border-color: rgba(102, 126, 234, 0.35) !important;
  color: inherit !important;
  box-shadow: none !important;
  text-decoration: none;
  filter: none;
  transform: none;
}

/* The clickable stage element wraps the actual .stage-badge as an
   inner <span> — neutralise the badge's own bg/padding so the outer
   pill chrome is the only visible chip. */
.info-value.clickable-filter > .stage-badge {
  background: transparent !important;
  padding: 0 !important;
  color: inherit;
  border-radius: 0;
}

.collection-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.collection-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.collection-toggle:hover {
  background: #e9ecef;
}

.collection-toggle input[type='checkbox'] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.collection-toggle label {
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.modal-scrollable-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-nav {
  display: flex;
  justify-content: space-between;
  padding: 20px 30px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  background: white;
}

.modal-nav button {
  padding: 10px 20px;
  border: 2px solid var(--color-primary);
  background: white;
  color: var(--color-primary);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.modal-nav button:hover:not(:disabled) {
  background: var(--color-primary);
  color: white;
}

.modal-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .modal-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {
  .modal-nav {
    padding: 12px 15px;
    gap: 10px;
  }

  .modal-nav button {
    padding: 10px 12px;
    font-size: 12px;
    flex: 1;
    min-width: 0;
  }
}

/* ══════════════════════════════════════════════════════════════
   Contact Modal
   ══════════════════════════════════════════════════════════════ */

.contact-modal-content {
  max-width: 650px;
}

.contact-modal-body {
  padding: 24px 28px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contact-form-row--half {
  display: flex;
  gap: 14px;
}

.contact-form-row--half .contact-form-group {
  flex: 1;
  min-width: 0;
}

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

.contact-form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
}

.required-star {
  color: #e53e3e;
  margin-left: 2px;
  font-weight: 400;
}

.contact-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #333;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.contact-input:focus {
  outline: none;
  border-color: var(--color-primary, #667eea);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.contact-input::placeholder {
  color: #aaa;
  font-size: 12px;
}

select.contact-input {
  appearance: auto;
  cursor: pointer;
}

.contact-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.contact-modal-footer {
  padding: 14px 28px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#contactSubmitBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .contact-modal-content {
    max-width: 100%;
    margin: 10px;
  }

  .contact-modal-body {
    padding: 18px 18px 8px;
  }

  .contact-form-row--half {
    flex-direction: column;
  }

  .contact-modal-footer {
    padding: 12px 18px 16px;
  }
}
