/* ═══════════════════════════════════════════════════════
   Content Factory — Redesign Iteration 3
   Loaded AFTER redesign2.css
   Fixes: logo in corner, square nav tiles, 2-col char panel,
          shotlist cards, script table, adaptivity
═══════════════════════════════════════════════════════ */

/* ── 0. LOGO IN CORNER — topbar starts at sidebar edge ── */
#topbar {
  left: var(--sb) !important;
  padding: 0 18px !important;
}

/* Sidebar full height — logo sits in the corner */
#sidebar {
  top: 0 !important;
  height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  border-right: 1px solid rgba(212,176,106,0.14) !important;
}

/* Logo zone = exact topbar height so they align visually */
#sb-logo {
  height: 64px !important;
  min-height: 64px !important;
  max-height: 64px !important;
  padding: 0 10px !important;
  margin-bottom: 0 !important;
  gap: 8px !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  border-bottom: 1px solid rgba(212,176,106,0.14) !important;
  overflow: hidden;
  flex-shrink: 0;
  box-sizing: border-box;
}

#sb-icon {
  width: 38px !important;
  height: 38px !important;
  border-radius: 10px !important;
  flex-shrink: 0 !important;
}

#sb-title {
  text-align: left !important;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sb-logo-brand {
  font-size: 7.5px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-logo-name {
  font-size: 7px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav scrollable */
#sb-nav {
  flex: 1 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 6px 0 !important;
  scrollbar-width: none;
}
#sb-nav::-webkit-scrollbar { display: none; }

/* ── 1. SQUARE NAV TILES ── */
.sb-section {
  font-size: 8px !important;
  padding: 10px 8px 4px !important;
  letter-spacing: 0.14em !important;
  color: rgba(212,176,106,0.45) !important;
  text-align: center !important;
  margin: 0 !important;
}

.sbn {
  width: 100% !important;
  height: var(--sb) !important;
  min-height: unset !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  position: relative;
  border: none !important;
  border-bottom: 1px solid rgba(212,176,106,0.07) !important;
  transition: background 0.13s, color 0.13s !important;
  flex-shrink: 0;
}

.sbn:hover {
  background: rgba(212,176,106,0.09) !important;
}

.sbn.active {
  background: rgba(212,176,106,0.15) !important;
  color: #D4B06A !important;
  border-bottom: 1px solid rgba(212,176,106,0.2) !important;
  border-left: 3px solid #D4B06A !important;
  box-shadow: none !important;
}
.sbn.active::before { display: none !important; }

.sbn-ic {
  width: 34px !important;
  height: 34px !important;
}
.sbn-ic svg {
  width: 28px !important;
  height: 28px !important;
}
.sbn-l {
  font-size: 10px !important;
  font-weight: 700 !important;
  text-align: center;
  line-height: 1.2 !important;
  padding: 0 8px;
}

/* sb-bottom minimal */
#sb-bottom {
  padding: 6px 0 !important;
  border-top: 1px solid rgba(212,176,106,0.1) !important;
  flex-shrink: 0;
}

/* ── 2. CHARACTER / ENV / BIBLE DETAIL — 2-COLUMN LAYOUT ── */
.cf-form-page {
  max-width: none !important;
  padding: 20px 24px 80px !important;
  column-count: 2;
  column-gap: 18px;
}

.cf-form-page .cf-page-header {
  column-span: all;
  margin-bottom: 18px !important;
}

.cf-form-page .cf-form-section {
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 14px !important;
}

.cf-form-page .cf-bottom-actions {
  column-span: all;
  margin-top: 4px;
}

#edit-char-msg, #edit-env-msg {
  column-span: all;
}

/* Photo grid — bigger thumbnails */
.cf-photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
  gap: 8px !important;
}

.cf-photo-card img {
  height: 110px !important;
  object-fit: cover;
}

/* Photo wrap with type selector */
.cf-photo-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cf-photo-cat-sel {
  width: 100%;
  font-size: 10px;
  padding: 3px 6px;
  background: #0C0A07;
  border: 1px solid rgba(212,176,106,0.2);
  color: #F8F4EA;
  border-radius: 5px;
}

/* ── 3. SHOTLIST INFO CARDS ── */
.sp-info-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.sp-info-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  border-bottom: 1px solid rgba(212,176,106,0.1);
  background: #0C0A07;
  transition: background 0.15s;
  min-height: 260px;
}

.sp-info-card:nth-child(even) {
  background: #110D09;
}
.sp-info-card:hover {
  background: rgba(212,176,106,0.04);
}

.sp-info-card-hdr {
  grid-column: 1 / -1;
  padding: 16px 24px 12px;
  border-bottom: 1px solid rgba(212,176,106,0.1);
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.sp-info-card-num {
  font-size: 20px !important;
  font-weight: 900 !important;
  color: #D4B06A !important;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--cf-font, inherit);
}

.sp-info-card-desc {
  font-size: 13px !important;
  color: #D8CCBA !important;
  line-height: 1.55;
  flex: 1;
}

.sp-info-card-body {
  display: contents;
}

.sp-info-media {
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #080604;
  min-height: 200px;
  position: relative;
}

.sp-info-media:first-of-type {
  border-right: 1px solid rgba(212,176,106,0.08);
}

.sp-info-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block;
  position: absolute;
  inset: 0;
}

.sp-info-vid {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block;
}

.sp-info-loading {
  font-size: 12px;
  color: rgba(212,176,106,0.25);
}

/* ── 4. SCRIPT TABLE — COLUMN WIDTHS ── */
.sc-table th:nth-child(4),
.sc-table td:nth-child(4) {
  max-width: 200px !important;
  min-width: 120px !important;
}

.sc-table th:nth-child(5),
.sc-table td:nth-child(5),
.sc-table th:nth-child(6),
.sc-table td:nth-child(6) {
  min-width: 120px !important;
  max-width: 170px !important;
}

.sc-table th.col-light,
.sc-table td.sc-light {
  min-width: 120px !important;
  max-width: 170px !important;
  white-space: normal !important;
  overflow: visible !important;
}

/* ── 5. UI POLISH ── */

/* Project cards slight gradient */
.cf-proj-card {
  background: linear-gradient(145deg, #1C1612 0%, #14110D 100%) !important;
  transition: transform 0.15s, box-shadow 0.15s !important;
}
.cf-proj-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(212,176,106,0.18) !important;
}

.cf-media-card {
  transition: transform 0.15s, box-shadow 0.15s !important;
}
.cf-media-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 28px rgba(0,0,0,0.4) !important;
}

/* Consistent button heights */
.cf-btn, .cf-btn-primary, .cf-btn-secondary, .cf-btn-ghost, .cf-btn-danger {
  height: 42px !important;
  border-radius: 10px !important;
}

.cf-gen-btn {
  height: 42px !important;
  border-radius: 10px !important;
}

/* Studio fullpage height */
.studio-fullpage {
  height: calc(100vh - var(--topbar-h, 64px) - 60px) !important;
}

/* ── 6. ADAPTIVITY ── */

/* Tablet 768–1100px: single column forms, smaller sidebar */
@media (max-width: 1100px) {
  :root { --sb: 82px; }

  .sb-logo-brand, .sb-logo-name { display: none !important; }
  #sb-logo { justify-content: center !important; gap: 0 !important; padding: 0 !important; }

  .cf-form-page { column-count: 1 !important; }

  .sp-info-card {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* Mobile ≤ 640px */
@media (max-width: 640px) {
  :root { --sb: 0px; }

  #sidebar {
    transform: translateX(-240px);
    transition: transform 0.25s ease;
    width: 240px !important;
    z-index: 1100 !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }
  #sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  #sidebar.mobile-open .sbn {
    width: 100% !important;
    height: 54px !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 14px !important;
    padding: 0 20px !important;
    border-left: none !important;
  }
  #sidebar.mobile-open .sbn-l { font-size: 13px !important; padding: 0 !important; }
  #sidebar.mobile-open .sbn-ic { width: 28px !important; height: 28px !important; flex-shrink: 0 !important; }

  #topbar {
    left: 0 !important;
    height: 56px !important;
  }
  #main {
    margin-left: 0 !important;
    margin-top: 56px !important;
  }
  #hdr {
    top: 56px !important;
  }

  .cf-page { padding: 16px 14px 60px !important; }
  .cf-card-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important; }
  .cf-form-page { column-count: 1 !important; padding: 16px 14px 60px !important; }

  .sp-info-card {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto !important;
  }
  .sp-info-media:first-of-type {
    border-right: none !important;
    border-bottom: 1px solid rgba(212,176,106,0.1) !important;
  }
  .sp-info-card-num { font-size: 16px !important; }
  .sp-info-card-hdr { padding: 12px 14px 10px !important; }

  .sc-table { font-size: 12px !important; }
  .sc-table th, .sc-table td { padding: 8px !important; }

  /* Mobile menu button in topbar */
  #tb-menu-btn { display: flex !important; }
}

/* Show mobile menu button only on mobile */
#tb-menu-btn { display: none; }


/* ── LOGO: только иконка в углу, название в топбаре ── */
#sb-title { display: none !important; }

#sb-logo {
  justify-content: center !important;
  padding: 0 !important;
  gap: 0 !important;
}

#sb-icon {
  width: 52px !important;
  height: 52px !important;
  border-radius: 14px !important;
}

/* Название в топбаре по центру */
#tb-brand-name {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 800;
  color: rgba(212,176,106,0.7);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
}

/* ── SCRIPT TABLE: широкие столбцы персонажи/локация/свет ── */
/* Overrides from redesign3.css — make even wider */
.sc-table th:nth-child(5),
.sc-table td:nth-child(5) {
  min-width: 160px !important;
  width: 160px !important;
  max-width: 200px !important;
  white-space: normal !important;
}
.sc-table th:nth-child(6),
.sc-table td:nth-child(6) {
  min-width: 160px !important;
  width: 160px !important;
  max-width: 200px !important;
  white-space: normal !important;
}
.sc-table th.col-light,
.sc-table td.sc-light {
  min-width: 160px !important;
  width: 160px !important;
  max-width: 200px !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
}
.sc-table .editable-cell {
  white-space: normal !important;
  word-break: break-word !important;
}

/* ── SP-MODE-BAR: спрятать переключатель режимов в раскадровке ── */
#sp-mode-bar { display: none !important; }

/* ── АДАПТИВНОСТЬ — дополнения ── */
@media (max-width: 640px) {
  #tb-brand-name { display: none !important; }
  .tb-sc-btn span { display: none; }
  .tb-sc-btn { min-width: 36px !important; padding: 0 8px !important; }
}
