/* ── Templates Layout ────────────────────────── */
.templates-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Pages Panel ─────────────────────────────── */
.pages-panel {
  width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.pages-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 12px;
  border-bottom: 1px solid var(--border);
}

.pages-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.page-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  gap: 8px;
}

.page-item:hover { background: var(--bg3); color: var(--text); }

.page-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.page-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-item-count {
  font-size: 11px;
  color: var(--text3);
  font-family: 'Open Sans', monospace;
  background: var(--bg3);
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.page-item.active .page-item-count {
  background: var(--accent-light);
  color: var(--accent);
}

.page-delete-btn {
  background: none;
  border: none;
  color: var(--text3);
  padding: 2px;
  border-radius: 4px;
  display: none;
  cursor: pointer;
  flex-shrink: 0;
}

.page-item:hover .page-delete-btn { display: flex; }
.page-delete-btn:hover { color: var(--red); }
.page-delete-btn svg { width: 13px; height: 13px; }

/* ── Templates Panel ─────────────────────────── */
.templates-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.templates-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.templates-panel-header h2 {
  font-family: 'Open Sans', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.templates-grid {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  align-content: start;
}

/* ── Template Card ───────────────────────────── */
.template-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.template-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.template-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.template-thumb img { width: 100%; height: 100%; object-fit: cover; }

.template-thumb-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text3);
}

.template-thumb-placeholder svg { width: 28px; height: 28px; opacity: 0.3; }
.template-thumb-placeholder span { font-size: 11px; }

.template-thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.template-card:hover .template-thumb-overlay { opacity: 1; }

.template-info {
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}

.template-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-meta {
  font-size: 10.5px;
  color: var(--text3);
  font-family: 'Open Sans', monospace;
  flex-shrink: 0;
}

.template-action-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  backdrop-filter: blur(4px);
}

.template-action-btn:hover { background: rgba(255,255,255,0.25); }
.template-action-btn svg { width: 14px; height: 14px; }

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  .templates-layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .pages-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 200px;
  }

  .pages-panel-header { padding: 12px; }

  .templates-panel { overflow: visible; }

  .templates-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    padding: 16px;
    gap: 12px;
  }

  .templates-panel-header { padding: 14px 16px; }
}

