/* Template Builder page styles — extends theme.css variables */

/* === MAIN LAYOUT === */
.tpl-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 100px 32px 80px;
}

.tpl-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 48px;
}

.tpl-header-left { flex: 1; }

.dash-headline {
  font-family: var(--font-head);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 10px;
}

.dash-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 0;
}

/* === TEMPLATE GRID === */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}

.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.tpl-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.tpl-card:hover {
  border-color: rgba(245, 158, 11, 0.3);
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.05);
  transform: translateY(-2px);
}

.tpl-card:hover::before { opacity: 1; }

.tpl-card.active {
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.08);
}

.tpl-card.active::before { opacity: 1; }

.tpl-card-icon {
  font-size: 2rem;
  margin-bottom: 16px;
}

.tpl-card-label {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.tpl-card-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 20px;
}

.tpl-card-actions {
  display: flex;
  gap: 8px;
}

.tpl-action-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.tpl-action-btn:hover {
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--accent);
}

.tpl-action-btn.primary {
  background: var(--accent-dim);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--accent);
}

.tpl-action-btn.primary:hover {
  background: rgba(245, 158, 11, 0.2);
}

/* === PREVIEW PANEL === */
.tpl-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-top: 32px;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.preview-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.preview-name {
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.preview-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-tab-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-dim);
  text-decoration: none;
  transition: all 0.15s;
}

.preview-tab-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.preview-tab-btn:hover:not(.active) {
  color: var(--text);
}

.btn-copy {
  background: var(--accent);
  color: #000;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 7px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-copy:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.preview-frame-wrap {
  background: #fff;
  min-height: 400px;
}

.preview-iframe {
  width: 100%;
  height: 600px;
  border: none;
  display: block;
}

.preview-iframe.mobile {
  max-width: 390px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* === COPY MODAL === */
.copy-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.copy-modal-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 700px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.copy-modal-title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.copy-textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  padding: 16px;
  resize: none;
  min-height: 300px;
  line-height: 1.5;
}

.copy-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.btn-close, .btn-done {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.btn-close:hover { color: var(--text); border-color: var(--text-muted); }

.btn-done {
  background: var(--accent);
  border: none;
  color: #000;
}

.btn-done:hover { box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .tpl-main { padding: 90px 16px 40px; }
  .tpl-grid { grid-template-columns: 1fr; }
  .tpl-header { flex-direction: column; gap: 16px; }
  .preview-bar { flex-wrap: wrap; }
  .preview-bar-right { gap: 6px; }
  .copy-modal-inner { padding: 20px; }
  .preview-iframe.mobile { max-width: 100%; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }