/* backtesting.ast.bar — AST Dark tokens */

:root {
  --bg: #0F1014;
  --surface: #16181F;
  --surface-elevated: #1F222C;
  --border: #2A2E3A;
  --text: #E5E7EB;
  --text-muted: #9CA3AF;
  --brand: #D97706;
  --brand-hover: #B45309;
  --accent: #10B981;
  --danger: #EF4444;
  --pending: #F59E0B;
  --validated: #10B981;
  --not_validated: #EF4444;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.6);
}

/* CRITICAL: [hidden] cascade fix antes de display rules — gana sobre UA stylesheet (lección Bloque 4 H2) */
[hidden] { display: none !important; }
.modal[hidden] { display: none; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* Header */
#app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#app-header h1 {
  margin: 0;
  font-size: 1.125rem;
  text-align: center;
  font-weight: 600;
}
#btn-inicio {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.875rem;
}
#btn-inicio:hover { color: var(--text); border-color: var(--text-muted); }

#btn-trader-upload {
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 600;
}
#btn-trader-upload:hover { background: var(--brand-hover); }

/* Filter bar */
#filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
#filter-bar::-webkit-scrollbar { height: 4px; }
#filter-bar::-webkit-scrollbar-thumb { background: var(--border); }

.filter-group { display: flex; gap: 8px; align-items: center; }
.filter-group + .filter-group { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--border); }
.filter-group-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.filter-pill {
  background: var(--surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: all 0.15s;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

/* BT list grid */
#bt-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
}

.bt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
}
.bt-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}
.bt-card.status-pending { border-left: 3px solid var(--pending); }
.bt-card.status-validated { border-left: 3px solid var(--validated); }
.bt-card.status-not_validated { border-left: 3px solid var(--not_validated); }

.bt-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  background-size: cover;
  background-position: center;
}
.bt-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.bt-meta { padding: 12px; }
.bt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.bt-row:last-child { margin-bottom: 0; }
.bt-trader-name {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.bt-resultado {
  font-size: 0.95rem;
  font-weight: 600;
}
.bt-resultado-tp { color: var(--accent); }
.bt-resultado-sl { color: var(--danger); }

.bt-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.bt-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-elevated);
  color: var(--text-muted);
  text-transform: capitalize;
}
.bt-badge.status-pending { background: rgba(245,158,11,0.15); color: var(--pending); }
.bt-badge.status-validated { background: rgba(16,185,129,0.15); color: var(--validated); }
.bt-badge.status-not_validated { background: rgba(239,68,68,0.15); color: var(--not_validated); }

.bt-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 16px;
  font-size: 0.95rem;
}

/* Modal shared */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
}
.modal-body {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.btn-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-modal-close:hover { background: rgba(0,0,0,0.8); }

/* Modal viewer (image fullsize + meta + coach actions) */
.viewer-img-wrap {
  position: relative;
  width: 100%;
  background: black;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 65vh;
  overflow: hidden;
}
.viewer-img-wrap img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  display: block;
}
#viewer-meta {
  padding: 16px 20px 20px;
}
.viewer-trader-name {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 600;
}
.viewer-row {
  margin: 0 0 6px;
  font-size: 0.9rem;
}
.viewer-row .viewer-label {
  color: var(--text-muted);
  display: inline-block;
  min-width: 130px;
}
.muted { color: var(--text-muted); font-size: 0.85rem; }

.coach-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.coach-actions button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
}
.action-validate { background: var(--accent); color: white; }
.action-validate:hover { background: #059669; }
.action-validate:disabled { opacity: 0.5; cursor: not-allowed; }
.action-reject { background: var(--danger); color: white; }
.action-reject:hover { background: #DC2626; }
.action-reject:disabled { opacity: 0.5; cursor: not-allowed; }

/* Modal forms */
.modal-body-form {
  max-width: 540px;
  padding: 24px;
}
.modal-body-form h2 { margin: 0 0 20px; font-size: 1.25rem; }

#form-upload, #form-reject {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#form-upload label, #form-reject label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
}
#form-upload label small, #form-reject label small {
  color: var(--text-muted);
  opacity: 0.7;
}

#form-upload input[type=file],
#form-upload select,
#form-reject textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}
#form-upload select:focus,
#form-reject textarea:focus {
  outline: none;
  border-color: var(--brand);
}
#form-reject textarea { resize: vertical; min-height: 100px; }

#btn-form-submit {
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 4px;
}
#btn-form-submit:hover { background: var(--brand-hover); }
#btn-form-submit:disabled { opacity: 0.5; cursor: not-allowed; }

#btn-reject-submit {
  margin-top: 4px;
  font-size: 1rem;
  padding: 12px;
  border-radius: var(--radius);
}

.form-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

/* Mobile tweaks */
@media (max-width: 600px) {
  #app-header { padding: 10px 12px; }
  #app-header h1 { font-size: 1rem; }
  #bt-list { padding: 12px; gap: 12px; grid-template-columns: 1fr; }
  .filter-group + .filter-group { margin-left: 8px; padding-left: 8px; }
  .modal { padding: 0; }
  .modal-body { max-height: 100vh; border-radius: 0; }
  .viewer-img-wrap, .viewer-img-wrap img { max-height: 50vh; }
}
