/* ============================================================
 * VIA Description Builder — Admin Styles
 * Metabox trên trang chỉnh sửa sản phẩm WooCommerce
 * ============================================================ */

/* === WRAPPER === */
.via-db-wrapper {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* === TOOLBAR === */
.via-db-toolbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	padding: 14px 16px;
	background: linear-gradient(135deg, #f8f9fb 0%, #eef1f6 100%);
	border: 1px solid #d5dae3;
	border-radius: 8px;
	margin-bottom: 16px;
}

.via-db-toolbar__left,
.via-db-toolbar__right {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

/* === BUTTONS === */
.via-db-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 8px 16px;
	border: none;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
	line-height: 1.4;
	white-space: nowrap;
}

.via-db-btn .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
	line-height: 16px;
}

.via-db-btn--primary {
	background: #3858e9;
	color: #fff;
	box-shadow: 0 2px 6px rgba(56, 88, 233, 0.3);
}
.via-db-btn--primary:hover {
	background: #2a47cc;
	box-shadow: 0 4px 12px rgba(56, 88, 233, 0.4);
	transform: translateY(-1px);
}

.via-db-btn--secondary {
	background: #fff;
	color: #3858e9;
	border: 1px solid #c7cfe6;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.via-db-btn--secondary:hover {
	background: #f0f3ff;
	border-color: #3858e9;
}

.via-db-btn--success {
	background: #16a34a;
	color: #fff;
	box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
}
.via-db-btn--success:hover {
	background: #15803d;
	box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
	transform: translateY(-1px);
}

.via-db-btn--outline {
	background: #fff;
	color: #475569;
	border: 1px solid #cbd5e1;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.via-db-btn--outline:hover {
	background: #f1f5f9;
	border-color: #94a3b8;
	color: #1e293b;
}

.via-db-btn--danger {
	background: #fff;
	color: #dc2626;
	border: 1px solid #fca5a5;
}
.via-db-btn--danger:hover {
	background: #fef2f2;
	border-color: #dc2626;
}

.via-db-btn--small {
	padding: 5px 12px;
	font-size: 12px;
	background: #fff;
	color: #555;
	border: 1px solid #ccc;
	border-radius: 4px;
}
.via-db-btn--small:hover {
	background: #f0f0f0;
}

.via-db-btn--copy {
	color: #3858e9;
	border-color: #c7cfe6;
}
.via-db-btn--copy:hover {
	background: #f0f3ff;
	border-color: #3858e9;
}
.via-db-btn--copy.via-db-btn--copied {
	color: #16a34a;
	border-color: #86efac;
	background: #f0fdf4;
}

/* === EMPTY STATE === */
.via-db-empty-state {
	text-align: center;
	padding: 40px 20px;
	color: #8899a6;
	border: 2px dashed #d5dae3;
	border-radius: 10px;
	background: #fafbfc;
}

.via-db-empty-state .dashicons {
	font-size: 48px;
	width: 48px;
	height: 48px;
	color: #c4cdd9;
	display: block;
	margin: 0 auto 12px;
}

.via-db-empty-state p {
	font-size: 14px;
	margin: 0;
	line-height: 1.6;
}

/* === SECTION CARD === */
.via-db-section {
	background: #fff;
	border: 1px solid #d5dae3;
	border-radius: 8px;
	margin-bottom: 12px;
	overflow: hidden;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
	position: relative;
}

.via-db-section:hover {
	border-color: #a5b4fc;
	box-shadow: 0 2px 12px rgba(56, 88, 233, 0.08);
}

.via-db-section.via-db-section--dragging {
	opacity: 0.5;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.via-db-section.via-db-section--drag-over {
	border-color: #3858e9;
	border-style: dashed;
}

/* Section header */
.via-db-section__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	background: linear-gradient(135deg, #f8f9fb 0%, #f0f2f7 100%);
	border-bottom: 1px solid #e5e7eb;
	cursor: pointer;
	user-select: none;
	transition: background 0.15s ease;
}

.via-db-section__header:hover {
	background: linear-gradient(135deg, #eef1f6 0%, #e8ebf2 100%);
}

.via-db-section__drag-handle {
	color: #b0bec5;
	font-size: 18px;
	flex-shrink: 0;
	cursor: grab;
}

.via-db-section__drag-handle:active {
	cursor: grabbing;
}

.via-db-section__number {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	background: #3858e9;
	color: #fff;
	border-radius: 50%;
	font-size: 12px;
	font-weight: 700;
	flex-shrink: 0;
}

.via-db-section__header-title {
	flex: 1;
	font-size: 13px;
	font-weight: 600;
	color: #334155;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.via-db-section__actions {
	display: flex;
	gap: 6px;
	flex-shrink: 0;
}

.via-db-section__toggle-btn {
	background: none;
	border: 1px solid #d5dae3;
	border-radius: 4px;
	width: 28px;
	height: 28px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #64748b;
	transition: all 0.2s ease;
	padding: 0;
}

.via-db-section__toggle-btn:hover {
	background: #f1f5f9;
	color: #334155;
}

.via-db-section__delete-btn {
	background: none;
	border: 1px solid #fca5a5;
	border-radius: 4px;
	width: 28px;
	height: 28px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #dc2626;
	transition: all 0.2s ease;
	padding: 0;
}

.via-db-section__delete-btn:hover {
	background: #fef2f2;
	border-color: #dc2626;
}

.via-db-section__delete-btn .dashicons,
.via-db-section__toggle-btn .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
	line-height: 16px;
}

/* Section body */
.via-db-section__body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	transition: padding 0.2s ease;
}

.via-db-section__body.via-db-section__body--collapsed {
	display: none;
}

/* Collapsed section — hide bottom border of header */
.via-db-section--collapsed .via-db-section__header {
	border-bottom-color: transparent;
}

/* Field groups */
.via-db-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.via-db-field__label {
	font-size: 12px;
	font-weight: 600;
	color: #475569;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.via-db-field__input {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid #d5dae3;
	border-radius: 6px;
	font-size: 14px;
	color: #1e293b;
	background: #fff;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	box-sizing: border-box;
}

.via-db-field__input:focus {
	outline: none;
	border-color: #3858e9;
	box-shadow: 0 0 0 3px rgba(56, 88, 233, 0.1);
}

.via-db-field__textarea {
	width: 100%;
	min-height: 120px;
	padding: 12px 14px;
	border: 1px solid #d5dae3;
	border-radius: 6px;
	font-size: 14px;
	color: #1e293b;
	background: #fff;
	resize: vertical;
	line-height: 1.6;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	box-sizing: border-box;
	font-family: inherit;
}

.via-db-field__textarea:focus {
	outline: none;
	border-color: #3858e9;
	box-shadow: 0 0 0 3px rgba(56, 88, 233, 0.1);
}

/* WP Editor wrapper */
.via-db-editor-wrap {
	border: 1px solid #d5dae3;
	border-radius: 6px;
	overflow: hidden;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.via-db-editor-wrap:focus-within {
	border-color: #3858e9;
	box-shadow: 0 0 0 3px rgba(56, 88, 233, 0.1);
}

/* Override WP editor internal borders to blend */
.via-db-editor-wrap .wp-editor-wrap {
	border: none !important;
}

.via-db-editor-wrap .wp-editor-container {
	border: none !important;
	width: 100%;
	box-sizing: border-box;
}

.via-db-editor-wrap .wp-editor-tabs {
	padding: 2px 4px 0;
}

.via-db-editor-wrap .mce-tinymce {
	box-shadow: none !important;
	border: none !important;
	width: 100% !important;
}

.via-db-editor-wrap .mce-top-part::before {
	box-shadow: none !important;
}

/* Quicktags toolbar */
.via-db-editor-wrap .quicktags-toolbar {
	border-bottom: 1px solid #e5e7eb;
	background: #f8f9fb;
	padding: 4px;
}

/* Fix: Text mode textarea — giữ đúng kích thước khi chuyển từ Visual sang Text */
.via-db-editor-wrap .wp-editor-area,
.via-db-editor-wrap textarea.via-db-section__content-textarea {
	width: 100% !important;
	max-width: 100% !important;
	min-height: 250px !important;
	height: 250px;
	margin: 0 !important;
	padding: 10px 14px !important;
	font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
	font-size: 13px;
	line-height: 1.7;
	color: #1e293b;
	resize: vertical;
	box-sizing: border-box !important;
	border: none !important;
	border-top: 1px solid #e5e7eb !important;
}

.via-db-field__hint {
	font-size: 11px;
	color: #94a3b8;
	line-height: 1.4;
}

/* === PREVIEW AREA === */
.via-db-preview-area {
	margin-top: 16px;
	border: 1px solid #d5dae3;
	border-radius: 8px;
	overflow: hidden;
}

.via-db-preview-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 16px;
	background: linear-gradient(135deg, #f8f9fb 0%, #eef1f6 100%);
	border-bottom: 1px solid #e5e7eb;
}

.via-db-preview-header h4 {
	margin: 0;
	font-size: 13px;
	font-weight: 600;
	color: #334155;
	display: flex;
	align-items: center;
	gap: 6px;
}

.via-db-preview-header h4 .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

.via-db-preview-actions {
	display: flex;
	gap: 6px;
	align-items: center;
}

.via-db-preview-content {
	padding: 16px;
	background: #1e293b;
	font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
	font-size: 12px;
	line-height: 1.7;
	white-space: pre-wrap;
	word-break: break-all;
	color: #e2e8f0;
	max-height: 400px;
	overflow-y: auto;
	margin: 0;
	border-radius: 0;
}

.via-db-preview-content::-webkit-scrollbar {
	width: 6px;
}
.via-db-preview-content::-webkit-scrollbar-track {
	background: #334155;
}
.via-db-preview-content::-webkit-scrollbar-thumb {
	background: #64748b;
	border-radius: 3px;
}

/* === NOTIFICATIONS === */
.via-db-notification {
	position: fixed;
	top: 50px;
	right: 20px;
	z-index: 99999;
	padding: 12px 20px;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	animation: via-db-slideIn 0.3s ease, via-db-slideOut 0.3s ease 2.7s forwards;
	max-width: 400px;
}

.via-db-notification--success {
	background: #16a34a;
}

.via-db-notification--error {
	background: #dc2626;
}

.via-db-notification--info {
	background: #3858e9;
}

@keyframes via-db-slideIn {
	from {
		transform: translateX(100%);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes via-db-slideOut {
	from {
		transform: translateX(0);
		opacity: 1;
	}
	to {
		transform: translateX(100%);
		opacity: 0;
	}
}

/* === ADD SECTION ANIMATION === */
.via-db-section--new {
	animation: via-db-fadeInUp 0.3s ease;
}

@keyframes via-db-fadeInUp {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* === RESPONSIVE === */
@media (max-width: 782px) {
	.via-db-toolbar {
		flex-direction: column;
		align-items: stretch;
	}

	.via-db-toolbar__left,
	.via-db-toolbar__right {
		justify-content: center;
	}

	.via-db-section__header {
		flex-wrap: wrap;
	}
}
