/* css/builder.css */

/* =========================================================
   FIXED CARD LAYOUT (builder / bases / logo-editor list)
   - body nie scrolluje
   - main + karta mają stałą wysokość viewport
   - scroll jest WYŁĄCZNIE wewnątrz .grid
   - .builder-bottom zawsze widoczny
========================================================= */

:root {
  --radius: 16px;
  --tab-width: 220px;
  --tab-height: 48px;
  --tab-extra: 1px;
  --corner-bottom: 0px;
  --corner-shift: 1px;
  --border-fudge: 2px;

  --page-bg: var(--bg);
  --surface: #111827;
  --inactive-text: rgba(255,255,255,.70);
  --border-color: var(--line2);
}

/* --- BODY / MAIN: viewport-locked + internal layout --- */
body.builder-body{
  height: 100vh;
  min-height: 100vh;
  background: var(--bg);
  color: #fff;

  display: flex;
  flex-direction: column;
  overflow: hidden;               /* 🔑 brak scrolla strony */
}

/* main.wrap musi być flex-kolumną, żeby bar + shell weszły w viewport */
body.builder-body > main.wrap{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;               /* 🔑 scroll tylko w środku karty */
}

/* Mobile landscape: allow full-page scroll and let cards stretch (prevents "trapped" UI) */
@media (max-width: 900px) and (orientation: landscape){
  body.builder-body{
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  body.builder-body > main.wrap{
    overflow: visible;
  }

  .builder-card,
  .builder-shell,
  .grid{
    max-height: none !important;
  }
}

/* W builder.css masz własną .wrap – przywracamy sensowny padding (żeby nie lepiło do krawędzi). */
.wrap{
  margin: 0 auto;
  padding: 18px;
  box-sizing: border-box;
}


@media (max-width: 900px){
  .wrap{
    padding: 15px;
  }
  #btnPlay{ display: none; }
}

/* --- BAR (nagłówek listy) nie może rozpychać wysokości --- */
.bar{
  flex: 0 0 auto;

  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;

  padding-bottom: 14px;
  border-bottom: 1px solid var(--line2);
  margin-bottom: 12px;
}

@media (max-width: 900px) and (orientation: portrait){
  .bar{
    display: block;
  }
}

.title{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.hint{
  margin-top: 4px;
  font-size: 12px;
  opacity: .75;
}

.actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px;
}

/* --- BUILDER SHELL: wypełnia resztę ekranu --- */
.builder-shell{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================================
   TABS CARD (builder)
========================================================= */
.tabs-card{
  width: 100%;
  margin: 16px auto 0;
  position: relative;

  /* 🔑 najważniejsze: tabs-card musi być flex-kolumną */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tabs-strip{
  flex: 0 0 auto;

  display: flex;
  height: var(--tab-height);
  align-items: stretch;
  background: var(--page-bg);
  position: relative;
  z-index: 1;
}

.tab-label,
.tab-slot{
  position: relative;
  display: flex;
  justify-content: center;
}

.tab-slot{
  width: var(--tab-width);
  flex: 1 1 0;
  align-items: stretch;
}

.tab-label{
  border: 0;
  background: transparent;
  color: var(--inactive-text);

  width: 100%;
  height: var(--tab-height);
  line-height: var(--tab-height);

  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;

  cursor: pointer;
  white-space: nowrap;
  align-items: center;

  padding: 0;
  margin: 0;
}

.tab-label.active{ color: #f9fafb; }
.tab-label:not(.active):hover{ color: #fff; }

.tab-label::after{
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: rgba(0,0,0,.35);
  display: none;
}
.tab-label.active::after{ display: none !important; }

.tab-label::before{
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  top: 14%;
  bottom: 14%;
  border-radius: calc(var(--radius)*.9);
  background: rgba(255,255,255,.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.tab-label:not(.active):hover::before{ opacity: 1; }

.tab-wrapper{
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 2;
  display: none;
}

/* Twoje warunki pokazywania wrappera */
.tab-slot:has(.tab-label.active) .tab-wrapper,
/* Separatory między nieaktywnymi zakładkami (lewa krawędź zakładki N gdy N-1 też nieaktywna) */
.tabs-card:has(#tabPollText.active)   .slot-prepared   .tab-label::after,
.tabs-card:has(#tabPollText.active)   .slot-market      .tab-label::after,
.tabs-card:has(#tabPollPoints.active) .slot-market      .tab-label::after,
.tabs-card:has(#tabPrepared.active)   .slot-pollPoints  .tab-label::after,
.tabs-card:has(#tabMarket.active)     .slot-pollPoints  .tab-label::after,
.tabs-card:has(#tabMarket.active)     .slot-prepared    .tab-label::after{
  display: block;
}

.tab-active,
.tab-corner::before{
  border: 1px solid var(--border-color);
}

.tab-active{
  height: calc(var(--tab-height) + var(--tab-extra));
  width: 100%;
  line-height: var(--tab-height);
  text-align: center;

  background: var(--surface);
  border-bottom: none;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);

  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #f9fafb;

  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.tab-corner{
  position: absolute;
  bottom: var(--corner-bottom);
  width: var(--radius);
  height: var(--radius);
  overflow: hidden;
  background-color: transparent;
  z-index: 3;
  pointer-events: none;
}

.tab-corner-left{
  left: 0;
  transform: translateX(calc(-100% + var(--corner-shift)));
  background-image: radial-gradient(circle at 0% 0%, transparent var(--radius), var(--surface) var(--radius));
}

.tab-corner-right{
  right: 0;
  transform: translateX(calc(100% - var(--corner-shift)));
  background-image: radial-gradient(circle at 100% 0%, transparent var(--radius), var(--surface) var(--radius));
}

.tab-corner::before{
  content: "";
  position: absolute;
  width: calc(2 * var(--radius));
  height: calc(2 * var(--radius));
  border-radius: 50%;
  background: transparent;
}

.tab-corner-left::before{
  top: calc(-1 * var(--radius) - var(--border-fudge));
  left: calc(-1 * var(--radius) - var(--border-fudge));
}
.tab-corner-right::before{
  top: calc(-1 * var(--radius) - var(--border-fudge));
  right: calc(-1 * var(--radius) - var(--border-fudge));
}

.tabs-card:has(#tabPollText.active) .slot-pollText .tab-corner-left,
.tabs-card:has(#tabMarket.active) .slot-market .tab-corner-right{
  display: none;
}

/* =========================================================
   BUILDER CARD: stała wysokość + grid scroll + bottom fixed
========================================================= */
.card.builder-card,
.builder-card.card{
  margin-top: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  position: relative;
  z-index: 0;
  box-shadow: 0 18px 36px rgba(0,0,0,.45);
  box-sizing: border-box;

  /* 🔑 klucz: karta jako flex-kolumna, wypełnia resztę viewport */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* scroll ma być w .grid */
}

/* Zaokrąglenia pod wypustki */
.tabs-card:has(#tabPollText.active) .builder-card{
  border-top-left-radius: 0;
  border-top-right-radius: var(--radius);
}
.tabs-card:has(#tabPollPoints.active) .builder-card{
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.tabs-card:has(#tabPrepared.active) .builder-card{
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.tabs-card:has(#tabMarket.active) .builder-card{
  border-top-left-radius: var(--radius);
  border-top-right-radius: 0;
}

/* Grid staje się scroll-contenerem */
.grid{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;                 /* 🔑 tu jest scroll */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  align-content: start;           /* nie rozciąga w pionie */
  padding: 5px;             /* drobny luz na scrollbar */
  -webkit-overflow-scrolling: touch;
}

/* Kafelki w gridzie – bez zmian funkcjonalnych */
.builder-body .grid .card{
  position: relative;
  background: #070b16;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.22);
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: transform .12s ease-out, box-shadow .12s ease-out, border-color .12s ease-out, background .12s ease-out;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 130px;
}

.builder-body .grid .card .x{
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 14px;
  opacity: .7;
}
.builder-body .grid .card .x:hover{ opacity: 1; }

.builder-body .grid .card .name{
  font-weight: 900;
  font-size: 14px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding-right: 22px;
  color: #fdfdfd;
  line-height: 1.3;

  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.builder-body .grid .card .meta{
  margin-top: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(236,239,244,.9);
}

.addCard:hover,
.builder-body .grid .card:hover{
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
}
.builder-body .grid .card:hover{
  border-color: var(--gold);
  background: #0b1020;
}
.builder-body .grid .card.selected{
  border-color: rgba(255,234,166,.9);
  background: rgba(255,234,166,.10);
  box-shadow:
    0 0 0 2px rgba(255,234,166,.55),
    0 10px 22px rgba(0,0,0,.35);
}

/* Add card */
.addCard{
  border-radius: 18px;
  border: 1px dashed rgba(255,234,166,.35);
  background: rgba(255,234,166,.06);
  padding: 14px;
  min-height: 130px;
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  text-align: center;
  transition: background .12s ease-out, border-color .12s ease-out, transform .12s ease-out, box-shadow .12s ease-out;
}
.addCard:hover{
  background: rgba(255,234,166,.1);
  border-color: rgba(255,234,166,.85);
}
.addCard .plus{
  font-size: 28px;
  color: var(--gold);
  line-height: 1;
}
.addCard .txt{
  font-weight: 1000;
  letter-spacing: .06em;
}
.addCard .sub{
  opacity: .78;
  font-size: 12px;
  line-height: 1.35;
}

/* Bottom zawsze widoczny: siedzi poza .grid i nie scrolluje */
.builder-bottom{
  flex: 0 0 auto;
  margin-top: 12px;               /* mniejszy odstęp, bo grid już scrolluje */
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
}

.builder-bottom-right{
  display: flex;
  gap: 8px;
}

/* =========================================================
   MODALS (jak było)
========================================================= */
.overlay{
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.82);
  display: grid;
  place-items: center;
  z-index: 50;
}

.modal{
  width: min(860px, 94vw);
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 30px 90px rgba(0,0,0,.85);
  padding: 18px;
  max-height: 92vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.mTitle{
  font-weight: 1000;
  font-size: 18px;
  letter-spacing: .06em;
  color: var(--gold);
}
.mSub{
  opacity: .8;
  font-size: 13px;
  margin-top: 6px;
}

.importRow{
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.importTa{
  width: 100%;
  min-height: 220px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line2);
  background: rgba(0,0,0,.25);
  color: #fff;
  outline: 0;
  resize: vertical;
  font-weight: 800;
}

.importMsg{
  margin-left: auto;
  opacity: .85;
  font-weight: 900;
  color: var(--gold);
  padding: 6px 0;
}

/* =========================================================
   ICON BUTTON (btnInstall, btnManual)
========================================================= */
.icon-btn {
  min-width: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}

/* =========================================================
   ACCOUNT DROPDOWN
========================================================= */
.account-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-btn #who {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.account-chevron {
  font-size: 11px;
  opacity: 0.7;
  flex-shrink: 0;
}

.account-menu {
  position: fixed;
  z-index: 1000;
  display: grid;
  gap: 4px;
  padding: 8px;
  min-width: 180px;
  background: var(--card, #111827);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
}

.account-menu[hidden] {
  display: none;
}

.account-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s;
}

.account-menu-item:hover {
  background: rgba(255, 255, 255, 0.10);
}

/* =========================================================
   OVERFLOW NAV (nav-more)
========================================================= */
.nav-more {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-more-dropdown {
  position: fixed;
  z-index: 1000;
  display: grid;
  gap: 4px;
  padding: 8px;
  min-width: 180px;
  background: var(--card, #111827);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
}

.nav-more-dropdown[hidden] {
  display: none;
}

.nav-more-dropdown .btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.nav-more-dropdown .btn:hover {
  background: rgba(255, 255, 255, 0.10);
}

/* =========================================================
   MOBILE
========================================================= */
@media (max-width: 600px){
  :root{
    --tab-height: 56px;
    --tab-extra: 2px;
  }

  .tabs-strip{
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
  }

  /* Krótkie nazwy zakładek na mobilkach */
  .tabs-strip .only-desktop { display: none !important; }
  .tabs-strip .only-mobile  { display: inline !important; }

  .tab-slot{
    width: 100%;
    flex: none;
    justify-content: center;
  }

  .tab-active,
  .tab-label{
    line-height: var(--tab-height);
  }

  .tab-label{
    height: var(--tab-height);
    z-index: 2;
  }

  .tab-active{
    height: calc(var(--tab-height) + var(--tab-extra));
    color: transparent; /* jak było */
  }

  .tab-label.active::after,
  .tab-label::after{
    display: none !important;
  }

  .tab-wrapper{ z-index: 1; }

  .grid{
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Preview modal ───────────────────────────────────── */
.bld-preview-modal {
  width: min(680px, 94vw);
}

.bld-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.bld-preview-questions {
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.bld-q-block {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
}

.bld-q-text {
  font-weight: 900;
  font-size: 14px;
  margin-bottom: 7px;
}

.bld-q-answers {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bld-q-answers li {
  font-size: 13px;
  opacity: .85;
}

.bld-pts {
  font-size: 11px;
  font-weight: 900;
  color: var(--gold);
  opacity: .7;
}

.bld-no-q {
  font-size: 13px;
  opacity: .55;
  text-align: center;
  padding: 16px 0;
}
