/* ============================================
   FenceX - Match Browser Page Styles
   Page-specific styles for matches.html
   Composes from theme.css, settings-modal.css, forms.css
   ============================================ */

/* ---- Page layout ---- */
.fx-matches-page {
  max-width: var(--container-max, 1200px);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-3xl);
}

/* ---- Page header ---- */
.fx-matches-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.fx-matches-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl, 24px);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-primary);
}

/* ---- Add (+) button ---- */
.fx-add-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent, #3b82f6);
  border: none;
  border-radius: var(--radius-sm, 8px);
  color: #fff;
  cursor: pointer;
  transition: background 200ms var(--ease-out), transform 150ms var(--ease-out);
  flex-shrink: 0;
}

.fx-add-btn:hover {
  background: var(--color-accent-hover, #60a5fa);
  transform: scale(1.05);
}

.fx-add-btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.fx-add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ---- Search bar (sticky) ---- */
.fx-search-bar-wrapper {
  position: sticky;
  top: 80px;
  z-index: 90;
  margin-bottom: var(--space-lg);
}

.fx-search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  height: 44px;
  padding: 0 var(--space-md);
  background: var(--color-card-glass, rgba(8, 15, 27, 0.82));
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--color-border, rgba(104, 154, 255, 0.14));
  border-radius: 999px;
  transition: border-color 200ms var(--ease-out);
}

.fx-search-bar:focus-within {
  border-color: var(--color-accent, #3b82f6);
}

.fx-search-icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.fx-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-base, 16px);
  min-width: 0;
}

.fx-search-input::placeholder {
  color: var(--color-text-muted);
}

.fx-search-filter {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-sm, 14px);
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
}

.fx-search-filter option {
  background: var(--color-bg-base, #0a0e17);
  color: var(--color-text-primary);
}

.fx-search-clear {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.fx-search-clear:hover {
  color: var(--color-text-primary);
}

/* ---- Tournament card ---- */
.fx-tournament-card {
  background: rgba(8, 15, 27, 0.82);
  border: 1px solid rgba(104, 154, 255, 0.14);
  border-radius: var(--radius-lg, 24px);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  margin-bottom: var(--space-md);
  overflow: hidden;
  transition: border-color 200ms var(--ease-out), transform 200ms var(--ease-out);
}

.fx-tournament-card:hover {
  border-color: rgba(104, 154, 255, 0.28);
  transform: translateY(-1px);
}

.fx-tournament-header {
  display: flex;
  align-items: center;
  padding: var(--space-lg);
  cursor: pointer;
  gap: var(--space-md);
  position: relative;
  user-select: none;
}

.fx-tournament-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-xl, 20px);
  font-weight: 700;
  color: var(--color-text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fx-tournament-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-text-muted);
  font-size: var(--text-sm, 14px);
  flex-shrink: 0;
}

.fx-weapon-pill {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  background: rgba(104, 154, 255, 0.1);
  color: var(--color-accent, #3b82f6);
}

.fx-bout-count-badge {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  background: rgba(104, 154, 255, 0.08);
  color: var(--color-text-muted);
}

.fx-chevron {
  transition: transform 200ms var(--ease-out);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.fx-tournament-card[data-expanded="true"] .fx-chevron {
  transform: rotate(180deg);
}

.fx-tournament-actions {
  display: flex;
  gap: var(--space-xs);
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}

.fx-tournament-header:hover .fx-tournament-actions {
  opacity: 1;
}

/* ---- Action icons (edit/delete on hover) ---- */
.fx-action-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm, 8px);
  padding: 4px;
  transition: color 200ms var(--ease-out), background 200ms var(--ease-out);
}

.fx-action-icon:hover {
  color: var(--color-text-primary);
  background: rgba(104, 154, 255, 0.1);
}

.fx-action-icon.fx-delete-icon:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ---- Accordion content ---- */
.fx-accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 250ms var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  .fx-accordion-content {
    transition: none;
  }
  .fx-chevron {
    transition: none;
  }
}

/* ---- Event list (expanded under tournament) ---- */
.fx-event-list {
  padding: 0 var(--space-lg) var(--space-lg);
}

.fx-event-add-row {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-xs) 0 var(--space-sm);
}

.fx-event-row {
  margin-left: var(--space-lg);
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid rgba(104, 154, 255, 0.2);
  border-radius: 0 var(--radius-sm, 8px) var(--radius-sm, 8px) 0;
  margin-bottom: var(--space-sm);
  overflow: hidden;
}

.fx-event-header {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  gap: var(--space-sm);
  min-height: 48px;
  position: relative;
  user-select: none;
}

.fx-event-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-xl, 20px);
  font-weight: 700;
  color: var(--color-text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fx-event-actions {
  display: flex;
  gap: var(--space-xs);
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}

.fx-event-header:hover .fx-event-actions {
  opacity: 1;
}

/* ---- Pool/DE section header ---- */
.fx-pool-de-content {
  padding: 0 var(--space-md) var(--space-md);
}

.fx-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  margin-left: var(--space-2xl);
  border-bottom: 1px solid rgba(104, 154, 255, 0.08);
  margin-bottom: var(--space-xs);
}

.fx-section-label {
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.fx-section-helper {
  font-size: var(--text-sm, 14px);
  color: var(--color-text-muted);
  margin-left: var(--space-sm);
}

/* ---- Bout row ---- */
.fx-bout-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  margin-left: var(--space-2xl);
  min-height: 48px;
  border-bottom: 1px solid rgba(104, 154, 255, 0.06);
  cursor: pointer;
  position: relative;
  transition: background 200ms var(--ease-out);
}

.fx-bout-row:hover {
  background: rgba(104, 154, 255, 0.05);
}

.fx-bout-row:last-child {
  border-bottom: none;
}

/* ---- W/L pill ---- */
.fx-wl-pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  flex-shrink: 0;
}

.fx-wl-pill.win {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.fx-wl-pill.loss {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.fx-wl-pill.unknown {
  background: rgba(228, 234, 244, 0.08);
  color: var(--color-text-muted);
}

/* ---- Bout fields ---- */
.fx-opponent-name {
  font-size: var(--text-base, 16px);
  font-weight: 400;
  color: var(--color-text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fx-bout-score {
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ---- Status badges (video / AI review) ---- */
.fx-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  flex-shrink: 0;
}

.fx-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.fx-badge-dot.muted { background: var(--color-text-muted); }
.fx-badge-dot.blue  { background: #3b82f6; }
.fx-badge-dot.green { background: #22c55e; }
.fx-badge-dot.amber {
  background: #fbbf24;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .fx-badge-dot.amber {
    animation: none;
    opacity: 0.7;
  }
}

.fx-badge-label.muted { color: var(--color-text-muted); }
.fx-badge-label.blue  { color: #3b82f6; }
.fx-badge-label.green { color: #22c55e; }
.fx-badge-label.amber { color: #fbbf24; }

/* ---- Bout action icons (edit/delete on hover) ---- */
.fx-bout-actions {
  display: flex;
  gap: var(--space-xs);
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
  position: absolute;
  right: var(--space-sm);
  background: var(--color-bg-base, #0a0e17);
  padding-left: 4px;
}

.fx-bout-row:hover .fx-bout-actions {
  opacity: 1;
}

/* ---- Uncategorized section ---- */
.fx-uncategorized-section {
  opacity: 0.85;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg, 24px);
  padding: var(--space-lg);
  margin-top: var(--space-xl);
}

.fx-uncategorized-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid rgba(104, 154, 255, 0.08);
}

/* ---- Empty states ---- */
.fx-empty-state,
.fx-level-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
}

.fx-empty-icon {
  width: 48px;
  height: 48px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.fx-empty-heading {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl, 24px);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
}

.fx-empty-body {
  font-size: var(--text-base, 16px);
  color: var(--color-text-muted);
  max-width: 320px;
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.fx-empty-cta {
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--color-accent, #3b82f6);
  color: #fff;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: var(--text-base, 16px);
  font-weight: 700;
  cursor: pointer;
  transition: background 200ms var(--ease-out);
}

.fx-empty-cta:hover {
  background: var(--color-accent-hover, #60a5fa);
}

/* ---- Loading / error states ---- */
.fx-loading-state,
.fx-error-state {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--color-text-muted);
}

.fx-error-text {
  margin-bottom: var(--space-md);
  font-size: var(--text-base, 16px);
  line-height: 1.6;
}

.fx-error-retry {
  margin-top: var(--space-md);
  padding: 8px 20px;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: background 200ms var(--ease-out);
}

.fx-error-retry:hover {
  background: var(--color-accent-hover);
}

/* ---- Modal form layout (extends settings-modal.css confirm-box) ---- */
.fx-modal-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.fx-modal-form label {
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  display: block;
}

.fx-modal-form input,
.fx-modal-form select,
.fx-modal-form textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(104, 154, 255, 0.14);
  border-radius: var(--radius-sm, 8px);
  color: var(--color-text-primary);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-base, 16px);
  outline: none;
  transition: border-color 200ms var(--ease-out);
  box-sizing: border-box;
}

.fx-modal-form input:focus,
.fx-modal-form select:focus,
.fx-modal-form textarea:focus {
  border-color: var(--color-accent, #3b82f6);
}

.fx-modal-form select option {
  background: var(--color-bg-base, #0a0e17);
  color: var(--color-text-primary);
}

.fx-modal-form textarea {
  resize: vertical;
  min-height: 80px;
}

.fx-modal-form .fx-field-group {
  display: flex;
  flex-direction: column;
}

.fx-modal-form .fx-field-row {
  display: flex;
  gap: var(--space-md);
}

.fx-modal-form .fx-field-row > .fx-field-group {
  flex: 1;
  min-width: 0;
}

.fx-wl-auto {
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  display: inline-block;
  margin-top: 4px;
}

.fx-wl-auto.win {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.fx-wl-auto.loss {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* ---- Destructive button ---- */
.fx-btn-destructive {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  font-size: var(--text-base, 16px);
  transition: background 200ms var(--ease-out);
}

.fx-btn-destructive:hover {
  background: #dc2626;
}

/* ---- Search result highlighting ---- */
mark {
  background: rgba(59, 130, 246, 0.25);
  color: var(--color-text-primary);
  border-radius: 3px;
  text-decoration: none;
}

.fx-search-dimmed {
  opacity: 0.45;
}

/* ---- Toast notification ---- */
.fx-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--color-card-glass, rgba(8, 15, 27, 0.92));
  border: 1px solid rgba(104, 154, 255, 0.2);
  border-radius: 999px;
  padding: 10px 24px;
  color: var(--color-text-primary);
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  z-index: 5000;
  opacity: 0;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
  pointer-events: none;
  white-space: nowrap;
}

.fx-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Deletion warning banner ---- */
.fx-deletion-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 12px var(--space-md);
  margin-bottom: var(--space-md);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-sm, 8px);
}

.fx-deletion-banner-text {
  font-size: var(--text-sm, 14px);
  font-weight: 600;
  color: #fbbf24;
}

.fx-deletion-banner-dismiss {
  background: none;
  border: none;
  color: #fbbf24;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 150ms;
}

.fx-deletion-banner-dismiss:hover {
  background: rgba(251, 191, 36, 0.15);
}

/* ---- Inline row deletion warning ---- */
.fx-row-deletion-warning {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.fx-deletion-warning-text {
  font-size: var(--text-sm, 14px);
  font-weight: 600;
  color: #fbbf24;
  white-space: nowrap;
}

.fx-retry-upload-btn {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fbbf24;
  font-size: var(--text-sm, 14px);
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms;
}

.fx-retry-upload-btn:hover {
  background: rgba(251, 191, 36, 0.25);
}

.fx-retry-upload-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Light mode overrides ---- */
[data-theme="light"] .fx-deletion-banner {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(217, 158, 22, 0.3);
}

[data-theme="light"] .fx-deletion-banner-text,
[data-theme="light"] .fx-deletion-banner-dismiss,
[data-theme="light"] .fx-deletion-warning-text,
[data-theme="light"] .fx-retry-upload-btn {
  color: #b45309;
}

[data-theme="light"] .fx-retry-upload-btn {
  background: rgba(180, 83, 9, 0.08);
  border-color: rgba(180, 83, 9, 0.25);
}

[data-theme="light"] .fx-retry-upload-btn:hover {
  background: rgba(180, 83, 9, 0.15);
}

/* ---- Light mode overrides ---- */
[data-theme="light"] .fx-tournament-card {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(30, 58, 110, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .fx-tournament-card:hover {
  border-color: rgba(30, 58, 110, 0.2);
}

[data-theme="light"] .fx-search-bar {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(30, 58, 110, 0.1);
}

[data-theme="light"] .fx-uncategorized-section {
  border-color: rgba(30, 58, 110, 0.1);
}

[data-theme="light"] .fx-event-row {
  background: rgba(0, 0, 0, 0.02);
  border-left-color: rgba(30, 58, 110, 0.15);
}

[data-theme="light"] .fx-modal-form input,
[data-theme="light"] .fx-modal-form select,
[data-theme="light"] .fx-modal-form textarea {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(30, 58, 110, 0.1);
  color: var(--color-text-primary);
}

[data-theme="light"] .fx-modal-form select option {
  background: #f5f7fb;
}

[data-theme="light"] .fx-search-filter {
  color: var(--color-text-muted);
}

[data-theme="light"] .fx-bout-actions {
  background: var(--color-bg-base, #f5f7fb);
}

[data-theme="light"] .fx-toast {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(30, 58, 110, 0.15);
}
