.cgdp-wrap, .cgdp-cat-wrap, .cgdp-single { --cgdp-primary: #4A9236; --cgdp-accent: #D4AE67; --cgdp-primary-dark: #3B7A2B; --cgdp-primary-tint: #EEF6EC; }
.cgdp-wrap { margin: 20px 0; position: relative; z-index: 0; isolation: isolate; }
.cgdp-cat-wrap { position: relative; z-index: 0; isolation: isolate; }
.cgdp-single { position: relative; z-index: 0; isolation: isolate; }
.cgdp-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.cgdp-search-input, .cgdp-cat-select { padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.cgdp-search-input { flex: 1; min-width: 220px; }
.cgdp-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--cgdp-primary); color: #fff !important; border: none; padding: 10px 18px; border-radius: 6px; cursor: pointer; text-decoration: none; font-size: 14px; font-weight: 600; transition: background .2s ease; }
.cgdp-btn:hover { background: var(--cgdp-primary-dark); }
.cgdp-btn-download .dashicons { font-size: 16px; width: 16px; height: 16px; }
.cgdp-btn-large { padding: 14px 26px; font-size: 16px; margin: 20px 0; }

.cgdp-grid { display: grid; gap: 20px; grid-template-columns: repeat(1, 1fr); }
.cgdp-grid.cgdp-columns-2 { grid-template-columns: repeat(2, 1fr); }
.cgdp-grid.cgdp-columns-3 { grid-template-columns: repeat(3, 1fr); }
.cgdp-grid.cgdp-columns-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 782px) { .cgdp-grid.cgdp-columns-2, .cgdp-grid.cgdp-columns-3, .cgdp-grid.cgdp-columns-4 { grid-template-columns: 1fr; } }

.cgdp-card { display: flex; flex-direction: column; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06); transition: box-shadow .2s ease, transform .2s ease; position: relative; }
.cgdp-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.09); transform: translateY(-2px); }
.cgdp-card.cgdp-featured { border-color: var(--cgdp-accent); }
.cgdp-card-icon { background: #f3f4f6; display: flex; align-items: center; justify-content: center; padding: 24px; }
.cgdp-card-icon img { max-height: 120px; object-fit: cover; width: 100%; }
.cgdp-card-icon .dashicons { font-size: 56px; width: 56px; height: 56px; color: var(--cgdp-primary); }
.cgdp-card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.cgdp-badge { align-self: flex-start; background: var(--cgdp-accent); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; letter-spacing: .04em; }
.cgdp-card-title { margin: 0; font-size: var(--cgdp-document-title-size, 15px); font-weight: 600; line-height: 1.3; }
.cgdp-card-title a { color: #111827; text-decoration: none; }
.cgdp-card-title a:hover { color: var(--cgdp-primary); }
.cgdp-card-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cgdp-tag-pill { background: var(--cgdp-primary-tint); color: var(--cgdp-primary); font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.cgdp-card-excerpt { color: #4b5563; font-size: 13.5px; margin: 0; flex: 1; }
.cgdp-card-meta { display: flex; gap: 12px; font-size: 12px; color: #6b7280; align-items: center; }
.cgdp-card-meta .dashicons { font-size: 14px; width: 14px; height: 14px; vertical-align: middle; }

.cgdp-pagination { margin-top: 24px; display: flex; gap: 6px; justify-content: center; }
.cgdp-pagination .page-numbers { padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 6px; text-decoration: none; color: #374151; }
.cgdp-pagination .page-numbers.current { background: var(--cgdp-primary); color: #fff; border-color: var(--cgdp-primary); }

.cgdp-no-results { padding: 30px; text-align: center; color: #6b7280; background: #f9fafb; border-radius: 8px; }

.cgdp-single-title { margin: 0 0 6px; font-size: 24px; font-weight: 700; line-height: 1.3; color: #111827; }
.cgdp-single-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13.5px; color: #4b5563; margin-bottom: 16px; }
.cgdp-single-desc { margin-bottom: 20px; line-height: 1.7; }
.cgdp-preview { margin: 20px 0; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
.cgdp-versions ul { list-style: none; margin: 0; padding: 0; }
.cgdp-versions li { padding: 6px 0; border-bottom: 1px dashed #e5e7eb; }
.cgdp-version-notes { color: #6b7280; font-size: 12.5px; }

.cgdp-category-list { list-style: none; margin: 0; padding: 0; }
.cgdp-category-list li { border-bottom: 1px solid #f0f0f0; }
.cgdp-category-list a { display: flex; justify-content: space-between; padding: 10px 4px; text-decoration: none; color: #111827; }
.cgdp-category-list a:hover { color: var(--cgdp-primary); }
.cgdp-count { color: #9ca3af; }

.cgdp-most-downloaded { padding-left: 22px; }
.cgdp-most-downloaded li { margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; }

.cgdp-history-table { width: 100%; border-collapse: collapse; }
.cgdp-history-table th, .cgdp-history-table td { text-align: left; padding: 10px; border-bottom: 1px solid #e5e7eb; font-size: 13.5px; }

.cgdp-notice { background: #fff7ed; border: 1px solid #fed7aa; padding: 12px 16px; border-radius: 8px; color: #9a3412; }

/* ============ Toolbar extras ============ */
.cgdp-sort-select, .cgdp-pp-select { padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13.5px; background: #fff; }
.cgdp-view-toggle { display: inline-flex; border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; }
.cgdp-view-btn { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; background: #fff; color: #6b7280; text-decoration: none; border-right: 1px solid #d1d5db; }
.cgdp-view-btn:last-child { border-right: none; }
.cgdp-view-btn.is-active { background: var(--cgdp-primary); color: #fff; }
.cgdp-view-btn .dashicons { font-size: 18px; width: 18px; height: 18px; }
.cgdp-btn-sm { padding: 7px 14px; font-size: 13px; flex-shrink: 0; }

/* ============ Category icon badge (shared) ============ */
.cgdp-cat-icon { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; overflow: hidden; }
.cgdp-cat-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ============ List row templates ============ */
.cgdp-list { display: flex; flex-direction: column; gap: 12px; }
.cgdp-row { display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 16px; transition: box-shadow .2s ease; }
.cgdp-row:hover { box-shadow: 0 3px 12px rgba(0,0,0,.06); }
.cgdp-row.cgdp-featured { border-color: var(--cgdp-accent); }
.cgdp-row-icon { flex-shrink: 0; }
.cgdp-row-icon-lg { align-self: flex-start; }
.cgdp-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cgdp-row-title { font-size: var(--cgdp-document-title-size, 15px); font-weight: 600; line-height: 1.3; color: #111827; text-decoration: none; }
.cgdp-row-title:hover { color: var(--cgdp-primary); }
.cgdp-row-excerpt { margin: 2px 0; font-size: 13.5px; color: #4b5563; }
.cgdp-row-meta { display: flex; gap: 12px; font-size: 12px; color: #6b7280; align-items: center; flex-wrap: wrap; }
.cgdp-row-meta .dashicons { font-size: 14px; width: 14px; height: 14px; vertical-align: middle; }
.cgdp-row-detailed { align-items: flex-start; }

/* ============ Call-to-action row template ============ */
.cgdp-cta-row { display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid #e5e7eb; border-left: 4px solid var(--cgdp-primary); border-radius: 8px; padding: 14px 18px; margin-bottom: 12px; }
.cgdp-cta-icon { width: 52px; height: 52px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.cgdp-cta-icon .dashicons { font-size: 26px; width: 26px; height: 26px; }
.cgdp-cta-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.cgdp-cta-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cgdp-cta-title { font-size: var(--cgdp-document-title-size, 15px); font-weight: 600; line-height: 1.3; color: #111827; text-decoration: none; }
.cgdp-cta-title:hover { text-decoration: underline; }
.cgdp-cta-btn { display: inline-flex; align-items: center; gap: 6px; color: #fff !important; padding: 10px 18px; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 13.5px; white-space: nowrap; flex-shrink: 0; }
.cgdp-cta-btn .dashicons { font-size: 16px; width: 16px; height: 16px; }

/* ============ Minimal link list template ============ */
.cgdp-minimal-list { list-style: none; margin: 0; padding: 0; }
.cgdp-minimal-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #f0f0f0; }
.cgdp-minimal-item .dashicons:first-child { color: var(--cgdp-primary); font-size: 18px; width: 18px; height: 18px; }
.cgdp-minimal-item a { text-decoration: none; color: #111827; flex: 1; min-width: 0; }
.cgdp-minimal-item a:hover { color: var(--cgdp-primary); }
.cgdp-minimal-size { color: #9ca3af; font-size: 12px; flex-shrink: 0; }
.cgdp-minimal-dl { display: flex !important; flex: 0 0 auto !important; color: var(--cgdp-primary) !important; }
.cgdp-minimal-dl .dashicons { font-size: 16px; width: 16px; height: 16px; }

/* ============ Category directory ([cgdp_categories]) ============ */
.cgdp-cat-wrap.cgdp-cat-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); }
.cgdp-cat-wrap.cgdp-cat-grid.cgdp-columns-2 { grid-template-columns: repeat(2, 1fr); }
.cgdp-cat-wrap.cgdp-cat-grid.cgdp-columns-3 { grid-template-columns: repeat(3, 1fr); }
.cgdp-cat-wrap.cgdp-cat-grid.cgdp-columns-4 { grid-template-columns: repeat(4, 1fr); }
.cgdp-cat-wrap.cgdp-cat-grid.cgdp-columns-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .cgdp-cat-wrap.cgdp-cat-grid { grid-template-columns: repeat(2, 1fr) !important; } }
@media (max-width: 560px) { .cgdp-cat-wrap.cgdp-cat-grid { grid-template-columns: 1fr !important; } }

.cgdp-cat-item { display: flex; align-items: center; gap: 14px; text-decoration: none; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease; }
.cgdp-cat-item:hover { box-shadow: 0 6px 16px rgba(0,0,0,.08); border-color: var(--cgdp-cat-color, var(--cgdp-primary)); transform: translateY(-2px); }
.cgdp-cat-grid .cgdp-cat-item { flex-direction: column; text-align: center; }
.cgdp-cat-grid .cgdp-cat-item .cgdp-cat-item-arrow { display: none; }
.cgdp-cat-item-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.cgdp-cat-item-name { font-weight: 600; color: #111827; font-size: var(--cgdp-category-title-size, 15px); line-height: 1.3; }
.cgdp-cat-item-desc { color: #6b7280; font-size: 12.5px; }
.cgdp-cat-item-count { color: var(--cgdp-cat-color, var(--cgdp-primary)); font-size: 12px; font-weight: 600; }
.cgdp-cat-item-arrow { margin-left: auto; color: #d1d5db; flex-shrink: 0; }
.cgdp-cat-list.cgdp-cat-wrap { display: flex; flex-direction: column; gap: 10px; }
.cgdp-cat-list .cgdp-cat-item { flex-direction: row; }


/* ============ Archive page protection / theme conflict fix ============ */
/*
 * Some WordPress themes apply very large or positioned styles to the generic
 * .page-title selector. Keep the plugin's archive title in normal document
 * flow so it cannot cover the navigation or document list.
 */
.cgdp-archive-page .cgdp-container {
	max-width: 1100px;
	width: 100%;
	margin: 40px auto;
	padding: 0 20px;
	box-sizing: border-box;
	position: relative;
	z-index: 1;
}

.cgdp-archive-page .page-header {
	position: relative !important;
	inset: auto !important;
	float: none !important;
	display: block !important;
	width: 100% !important;
	height: auto !important;
	min-height: 0 !important;
	max-height: none !important;
	margin: 0 0 24px !important;
	padding: 0 !important;
	overflow: visible !important;
	transform: none !important;
}

.cgdp-archive-page .page-header .page-title {
	position: relative !important;
	inset: auto !important;
	float: none !important;
	display: block !important;
	width: 100% !important;
	max-width: 100% !important;
	height: auto !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	box-sizing: border-box !important;
	overflow-wrap: anywhere;
	word-break: normal;
	transform: none !important;
	font-size: var(--cgdp-archive-title-size, 32px) !important;
	line-height: 1.2 !important;
	font-weight: 700 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-align: left !important;
	color: var(--cgdp-primary, #4A9236) !important;
	background: transparent !important;
	box-shadow: none !important;
	border: 0 !important;
}

.cgdp-archive-page .cgdp-wrap {
	clear: both;
	position: relative;
	z-index: 1;
	margin-top: 0;
}

@media (max-width: 782px) {
	.cgdp-archive-page .cgdp-container {
		margin: 24px auto;
		padding: 0 16px;
	}
	.cgdp-archive-page .page-header {
		margin-bottom: 18px !important;
	}
	.cgdp-archive-page .page-header .page-title {
		font-size: calc(var(--cgdp-archive-title-size, 32px) * .85) !important;
	}
	.cgdp-row,
	.cgdp-cta-row {
		align-items: flex-start;
		flex-wrap: wrap;
	}
	.cgdp-row .cgdp-btn-download,
	.cgdp-cta-btn {
		margin-left: auto;
	}
}
