/* train-builder.css */
/* Modern desktop-focused UI redesign, matching the signal-training aesthetic. */

:root{
  --bg0:#0b1220;
  --bg1:#0f1a30;
  --text:#e7eefc;
  --muted:#a7b3cf;
  --border:rgba(255,255,255,.10);
  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --radius:18px;
  --btn:#1b2a4a;
  --btn2:#22355f;
  --focus: rgba(105,226,255,.45);
  --accent:#69e2ff;
  --good:#00ff82;
  --warn:#ffea00;
  --bad:#ff0033;
}

*{ box-sizing:border-box; }

html, body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background: radial-gradient(1200px 700px at 15% 10%, #16325e 0%, transparent 55%),
              radial-gradient(900px 600px at 85% 20%, #0f4f6a 0%, transparent 55%),
              linear-gradient(180deg, var(--bg1), var(--bg0));
  display:flex;
  flex-direction:column;
}

/* Topbar (matches signal-training) */
.topbar{
  width:100%;
  border-bottom:1px solid var(--border);
  background: rgba(11,18,32,.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner{
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}

.brand{
  display:flex;
  align-items:center;
  gap:14px;
  min-width:0;
}

.logo{
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  flex: 0 0 auto;
}

.logo img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}

.titles{
  line-height:1.1;
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width: 0;
}

.titles h1{
  font-size: 18px;
  font-weight: 750;
  margin:0;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}

.titles .sub{
  font-size: 13px;
  color: var(--muted);
  margin:0;
  letter-spacing: .3px;
}

.header-right{
  display:flex;
  align-items:center;
  gap:10px;
  flex: 0 0 auto;
}

.pill{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  white-space: nowrap;
}

.pill.accent{ border-color: rgba(105,226,255,.30); }
.pill.good{ border-color: rgba(0,255,130,.30); }
.pill.warn{ border-color: rgba(255,234,0,.30); }
.pill.bad{ border-color: rgba(255,0,51,.30); }

/* Layout */
main{
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 18px 34px;
  display:flex;
  flex-direction:column;
  gap: 16px;
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.03));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.card-header{
  padding: 14px 14px 12px;
  display:flex;
  align-items:flex-end;
  justify-content: space-between;
  gap: 14px;
  background: rgba(0,0,0,.18);
  border-bottom: 1px solid var(--border);
}

.card-titlewrap{
  display:flex;
  flex-direction:column;
  gap: 4px;
  min-width: 0;
}

.card-title{
  margin:0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing:.2px;
}

.card-sub{
  margin:0;
  color: var(--muted);
  font-size: 13px;
}

.controlsbar{
  display:flex;
  align-items:flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.field.searchfield{
  min-width: 320px;
}

label{
  font-size: 12px;
  color: var(--muted);
}

.input{
  width: 260px;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  color: var(--text);
  outline:none;
}

.input:focus{
  box-shadow: 0 0 0 4px var(--focus);
  border-color: rgba(105,226,255,.35);
}

.input.small{
  width: 130px;
}

/* Builder layout requested */
.builder-layout{
  padding: 14px;
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.top-row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.bottom-row{
  display:block;
}

/* Panels */
.panel{
  background: rgba(0,0,0,.18);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

.panel.fixed{
  /* At most ~30% of viewport height (desktop focus). Scroll lists inside. */
  height: clamp(200px, 30vh, 300px);
}

.panel.preview{
  /* Preview should dominate the page */
  min-height: clamp(520px, 62vh, 900px);
}

.panel-header{
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.14);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.panel-title{
  margin:0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--text);
}

.panel-body{
  padding: 12px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  height: 100%;
}

/* Scrollable lists inside fixed panels */
#imageSelector{
  display:flex;
  flex-direction:column;
  gap: 10px;
  overflow:auto;
  padding-right: 4px;
  flex: 1 1 auto;
  min-height: 0; /* important for nested flex scroll */
}

#selectedImages{
  display:flex;
  flex-direction:column;
  gap: 10px;
  overflow:auto;
  padding-right: 4px;
  flex: 1 1 auto;
  min-height: 0; /* important for nested flex scroll */
}

/* Catalog items */
.imageSelectorItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}

.imageSelectorItem span{
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}

.addButton{
  appearance:none;
  border: 1px solid rgba(105,226,255,.22);
  background: linear-gradient(180deg, rgba(105,226,255,.18), rgba(27,42,74,.12));
  color: var(--text);
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 750;
  cursor:pointer;
  white-space: nowrap;
  transition: transform .08s ease, filter .15s ease;
}

.addButton:hover{ filter: brightness(1.08); }
.addButton:active{ transform: translateY(1px); }

/* Selected items */
.imageItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  cursor: pointer;
}

.imageItem:hover{
  border-color: rgba(105,226,255,.30);
  background: rgba(105,226,255,.06);
}

.imageItem .label{
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}

.imageItem.selected{
  border-color: rgba(105,226,255,.50);
  background: rgba(105,226,255,.10);
  box-shadow: 0 0 0 3px rgba(105,226,255,.12) inset;
}

.removeButton{
  appearance:none;
  border: 1px solid rgba(255,0,51,.30);
  background: rgba(255,0,51,.14);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

.removeButton:hover{ filter: brightness(1.08); }

/* Actions row pinned under list */
.actionsRow{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn{
  appearance:none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--btn2), var(--btn));
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 750;
  cursor:pointer;
  transition: transform .08s ease, filter .15s ease;
  user-select:none;
}

.btn:hover{ filter: brightness(1.08); }
.btn:active{ transform: translateY(1px); }
.btn:focus{ outline:none; box-shadow: 0 0 0 4px var(--focus); }

.btn.secondary{
  background: rgba(255,255,255,.06);
}

.btn.danger{
  border-color: rgba(255,0,51,.28);
  background: linear-gradient(180deg, rgba(255,0,51,.20), rgba(255,0,51,.12));
}

.btn.icon{
  padding: 10px 12px;
  min-width: 46px;
  text-align:center;
  font-size: 16px;
}

.tip{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

/* Preview rail */
.previewWrap{
  /* Make the preview the focal point */
  flex: 1 1 auto;
  position: relative;
  overflow:auto;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background:
    radial-gradient(1200px 300px at 50% 10%, rgba(105,226,255,.10), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.12));
  padding: 14px;
  min-height: clamp(420px, 52vh, 820px);
}

.previewRail{
  position: relative;
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(105,226,255,.12), rgba(255,255,255,0) 55%),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.16));
  border: 1px solid rgba(255,255,255,.08);
  padding: 18px 12px 16px;
  min-height: clamp(400px, 50vh, 780px);
  display:flex;
  align-items:center;
  justify-content:center;
}

.previewRail:before,
.previewRail:after{
  content:"";
  position:absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  background: rgba(255,255,255,.10);
}

.previewRail:before{ top: 18px; }
.previewRail:after{ bottom: 18px; }

#imagesContainer{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 14px;
  flex-wrap: nowrap;
}

.imageWrapper{
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18);
  overflow:hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.imageWrapper.selected{
  border-color: rgba(105,226,255,.55);
  box-shadow: 0 0 0 3px rgba(105,226,255,.14) inset, 0 16px 40px rgba(0,0,0,.45);
}

.imageWrapper img{
  display:block;
  width: 100%;
  height: auto;
}

.orderLabel{
  position:absolute;
  top: 10px;
  left: 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .2px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.28);
  color: var(--text);
  backdrop-filter: blur(6px);
}

.emptyState{
  color: var(--muted);
  font-size: 13px;
  text-align:center;
  padding: 28px 12px;
}

/* Subtle scrollbar styling */
*{
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) rgba(255,255,255,.04);
}
*::-webkit-scrollbar{ width: 10px; height: 10px; }
*::-webkit-scrollbar-track{ background: rgba(255,255,255,.04); border-radius: 999px; }
*::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.16); border-radius: 999px; border: 2px solid rgba(0,0,0,0); background-clip: padding-box; }

/* Desktop-first: hide layout collapse unless truly narrow */
@media (max-width: 980px){
  .top-row{ grid-template-columns: 1fr; }
  .panel.fixed{ height: 520px; }
  .field.searchfield{ min-width: 260px; }
}
