/* CVforGulf – builder under site header/footer (mobile-first) */

/* Desktop / laptop: tall editor, screen-based max */
html.builder-page {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
body.builder-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
}

body.builder-page > .skip-link { flex: none; }
body.builder-page > .site-header { flex: 0 0 auto; }
body.builder-page > .verify-banner { flex: 0 0 auto; }

/* Builder: min 1200px on PC so form + preview never collapse */
body.builder-page > main.builder-shell,
body.builder-page > .builder-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #eef0f5;
  /* PC / laptop */
  min-height: 1200px;
  height: max(1200px, calc(100dvh - 64px));
  max-height: none;
}

body.builder-page > .site-footer {
  flex: 0 0 auto;
  position: relative;
  z-index: 5;
}

.builder-shell {
  --rb-accent: #0b2540;
  --rb-gold: #c9963e;
}

.builder-banner {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid #e3e6ee;
  font-size: 12px;
  color: #374151;
}
.builder-banner strong { color: #0b2540; }
.builder-banner a { color: #0b2540; font-weight: 600; }
.builder-banner .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f0f4f8;
  font-size: 11px;
  font-weight: 600;
}
.builder-banner .pill.gold { background: #f8f0e0; color: #7a5a1a; }

.builder-shell .mtabs { flex: 0 0 auto; }

/* App grid: left form + right preview — MUST fill remaining height */
.builder-shell .app {
  flex: 1 1 0 !important;
  min-height: 1100px !important;
  height: auto !important;
  max-height: none !important;
  display: grid !important;
  grid-template-columns: minmax(280px, 400px) 1fr;
  overflow: hidden !important;
}

.builder-shell .panel {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.builder-shell .pane {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.builder-shell .pane .topbar,
.builder-shell .pane .page-info {
  flex: 0 0 auto;
}

.builder-shell .pane .scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.topbar .btn-save-top {
  background: #0b2540 !important;
  color: #fff !important;
  border: none !important;
}
.topbar .btn-save-top:disabled { opacity: 0.55; cursor: not-allowed; }

.page-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #f0f4f8;
  border-bottom: 1px solid #e3e6ee;
  font-size: 12px;
  color: #475569;
}
.page-info.warn { background: #fff7ed; color: #9a3412; font-weight: 600; }
.page-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0b2540;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex: none;
}
.page-info.warn .page-info-icon { background: #c2410c; }
.page-info #pages { font-size: 12px; color: inherit; font-weight: inherit; }

/* Compact template cards */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  padding: 12px 14px 28px;
}
.tpl-card {
  border: 2px solid #e3e6ee;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  text-align: center;
  padding: 0;
  font: inherit;
  color: inherit;
  max-width: 100px;
  justify-self: center;
  width: 100%;
}
.tpl-card:hover { border-color: #9ca3af; }
.tpl-card.is-active { border-color: #0b2540; box-shadow: 0 0 0 1px #0b2540; }
.tpl-card.is-locked { opacity: 0.65; cursor: not-allowed; }
.tpl-card img,
.tpl-card .tpl-ph {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  object-position: top center;
  background: #f3f4f6;
}
.tpl-card .tpl-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  padding: 6px;
  line-height: 1.25;
}
.tpl-card .tpl-meta { padding: 5px 4px 7px; }
.tpl-card .tpl-name {
  font-size: 10px;
  font-weight: 700;
  color: #0b2540;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tpl-card .tpl-tier { display: none; }

#cvfgToast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #0b2540;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  max-width: min(92vw, 420px);
  text-align: center;
  display: none;
}
#cvfgToast.err { background: #7f1d1d; }
#cvfgToast.ok { background: #14532d; }

.ai-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.ai-row button {
  border: 1px solid #cfd5e1;
  background: #f8fafc;
  border-radius: 8px;
  padding: 7px 11px;
  font: 600 12px/1.2 system-ui, sans-serif;
  cursor: pointer;
  color: #1f2937;
}
.ai-row button:hover { background: #eef2ff; border-color: #a5b4fc; }
.ai-row button:disabled { opacity: 0.55; cursor: wait; }
.ai-note { font-size: 11px; color: #6b7280; margin: -4px 0 10px; }

@media (max-width: 900px) {
  html.builder-page,
  body.builder-page {
    height: auto;
    max-height: none;
    overflow: auto;
    display: block;
  }
  body.builder-page > main.builder-shell,
  body.builder-page > .builder-shell {
    min-height: 0 !important;
    height: auto !important;
    overflow: visible;
  }
  .builder-shell .app {
    min-height: 0 !important;
  }
  body.builder-page > .site-footer {
    max-height: none;
  }
  .builder-shell .app {
    grid-template-columns: 1fr !important;
    overflow: visible !important;
    height: auto !important;
  }
  .builder-shell .panel,
  .builder-shell .pane .scroll {
    max-height: min(70vh, 640px);
    height: auto;
  }
  .tpl-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .tpl-card img,
  .tpl-card .tpl-ph { height: 120px; }
}

/* Neutralise site.css on CV preview WITHOUT overriding template .name / .title rules.
   (Previously font-size:inherit on #resume h1 beat .tpl-peach .name and flattened the full name.) */
.builder-shell #preview h1:not(.name),
.builder-shell #preview h2,
.builder-shell #preview h3,
.builder-shell #resume h1:not(.name),
.builder-shell #resume h2,
.builder-shell #resume h3 {
  margin: 0;
}
/* Full name: only kill site marketing h1 defaults; leave size/color/weight to tpl-*.css */
.builder-shell #resume h1.name,
.builder-shell #preview h1.name {
  margin: 0;
  /* do NOT set font-size, color, letter-spacing, text-transform — templates own these */
}
