/* ============================================================
   CVCORE — templates.css
   Templates gallery, filters, color swatches
   ============================================================ */

/* ─── TEMPLATES PAGE LAYOUT ─── */
.templates-page {
  padding-top: var(--nav-h);
  min-height: 100svh;
}

.templates-hero {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

/* ─── FILTER BAR ─── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  padding: 1.125rem 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--nav-h);
  background: rgba(9,9,11,0.92);
  backdrop-filter: blur(20px);
  z-index: 50;
}

.filter-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
}

.filter-tab {
  padding: 0.5rem 1.1rem;
  font-size: 0.855rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 100px;
  transition: all var(--transition);
  user-select: none;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
}

.filter-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.filter-colors {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.filter-color-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 0.25rem;
  white-space: nowrap;
}

.color-swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  position: relative;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg);
}
.color-swatch-all {
  background: conic-gradient(#1a3fa0 0deg 90deg, #16a34a 90deg 180deg, #dc2626 180deg 270deg, #d97706 270deg 360deg);
}

.filter-search {
  margin-left: auto;
  position: relative;
}
.filter-search input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.5rem 1rem 0.5rem 2.2rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.855rem;
  width: 220px;
  transition: all var(--transition);
}
.filter-search input:focus {
  outline: none;
  border-color: var(--accent);
  width: 260px;
  box-shadow: 0 0 0 3px rgba(200,255,71,.06);
}
.filter-search svg {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

/* ─── TEMPLATES GRID ─── */
.templates-content {
  padding: 2.5rem 0 4rem;
  position: relative;
  z-index: 1;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

/* ─── TEMPLATE CARD ─── */
.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

.template-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent-border);
  box-shadow: 0 20px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(200,255,71,0.08);
}

.template-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(200,255,71,0.2);
}

/* ─── TEMPLATE PREVIEW AREA ─── */
.template-thumb {
  aspect-ratio: 3/4;
  background: #f5f5f0;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.template-thumb svg {
  width: 100%;
  height: 100%;
}

/* Overlay on hover */
.template-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9,9,11,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.template-card:hover .template-overlay { opacity: 1; }

.template-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  z-index: 2;
}

/* ─── COLOR DOTS ─── */
.template-colors {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.375rem;
}
.template-color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.3);
  cursor: pointer;
  transition: transform var(--transition);
}
.template-color-dot:hover { transform: scale(1.25); }
.template-color-dot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
}

/* ─── TEMPLATE INFO ─── */
.template-info {
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.template-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.template-style {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.1rem;
}

/* ─── EMPTY STATE ─── */
.templates-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
}
.templates-empty svg { margin: 0 auto 1rem; color: var(--text-faint); }
.templates-empty h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.templates-empty p  { font-size: 0.9rem; color: var(--text-faint); }

/* ─── TEMPLATE COUNT ─── */
.templates-count {
  font-size: 0.83rem;
  color: var(--text-faint);
  margin-bottom: 1.25rem;
}
.templates-count strong { color: var(--text); }

/* ─── FINALIZE PAGE ─── */
.finalize-page {
  padding-top: var(--nav-h);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.finalize-body {
  display: grid;
  grid-template-columns: 1fr 380px;
  flex: 1;
  min-height: calc(100svh - var(--nav-h));
}

.finalize-preview-area {
  background: #2a2a30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2.5rem 2rem;
  overflow-y: auto;
  position: relative;
}

.finalize-resume-paper {
  background: #fff;
  width: 100%;
  max-width: 560px;
  min-height: 790px;
  border-radius: 2px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.6);
  overflow: hidden;
}

.finalize-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.finalize-sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.finalize-sidebar-section {
  padding: 1.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.finalize-sidebar-section:last-child { border-bottom: none; }

.finalize-sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 1rem;
}

/* Format options */
.format-options {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.format-option {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.format-option:hover { border-color: var(--border2); }
.format-option.primary-format {
  background: var(--accent-dim);
  border-color: var(--accent-border);
}

.format-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.format-label { font-size: 0.875rem; font-weight: 600; }
.format-desc  { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }

/* Color theme picker */
.color-theme-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}
.color-theme-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}
.color-theme-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all var(--transition);
}
.color-theme-item:hover .color-theme-circle { transform: scale(1.1); }
.color-theme-item.active .color-theme-circle { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.color-theme-name { font-size: 0.62rem; color: var(--text-faint); }

/* Cover letter upsell */
.coverletter-upsell {
  background: linear-gradient(135deg, rgba(200,255,71,0.06), rgba(255,107,53,0.04));
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.coverletter-upsell-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.35rem; }
.coverletter-upsell-desc  { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

/* ─── RESPONSIVE ─── */
@media (max-width: 1200px) {
  .templates-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .templates-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-wrap: wrap; gap: 1rem; }
  .filter-search { width: 100%; }
  .filter-search input { width: 100%; }
  .finalize-body { grid-template-columns: 1fr; }
  .finalize-sidebar { display: none; }
}

@media (max-width: 600px) {
  .templates-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
}
