/* ===== Tables List (tables-list.php) ===== */
.sidetalk-tables-list-toolbar {
	margin-bottom: 24px;
}

.sidetalk-tables-list-toolbar .sidetalk-button-group {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: 100%;
}

.sidetalk-tables-list-toolbar .page-size-container {
	margin-bottom: 0;
}

.sidetalk-tables-list-toolbar .sidetalk-dashboard-button {
	flex-shrink: 0;
}

/* ===== Tables Editor (tables.php) ===== */
.sidetalk-table-start-guide {
	margin: 0 0 24px;
	padding: 24px;
	background: #fff;
	border-radius: 20px;
	border: 1px solid #eef2f7;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.sidetalk-table-start-cards {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}

.table-start-card {
	position: relative;
	padding: 20px;
	background: #fff;
	border: 1.5px solid #eef2f7;
	border-radius: 16px;
	cursor: pointer;
	transition: all 0.2s ease;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.table-start-card:hover {
	border-color: var(--st-primary);
	background: #f8fbff;
	transform: translateY(-2px);
	box-shadow: 0 8px 20px rgba(22, 119, 242, 0.08);
}

.table-start-card.is-active {
	border-color: var(--st-primary);
	background: #f0f7ff;
}

.table-start-card .card-icon {
	width: 44px;
	height: 44px;
	border-radius: 12px;
	background: #f0f4f8;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	color: #4f566b;
	transition: all 0.2s ease;
}

.table-start-card .card-icon svg {
	width: 22px;
	height: 22px;
	display: block;
}

.table-start-card:hover .card-icon {
	background: var(--st-primary);
	color: #fff;
}

.table-start-card .card-title {
	display: block;
	font-size: 15px;
	font-weight: 700;
	color: #1a1f36;
	margin-bottom: 4px;
}

.table-start-card .card-desc {
	font-size: 13px;
	color: #697386;
	line-height: 1.5;
	margin: 0;
}

.table-start-card .card-badge {
	position: absolute;
	top: 12px;
	right: 12px;
	padding: 3px 8px;
	border-radius: 6px;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
}

.table-start-card .card-badge.sync {
	background: #e0f2fe;
	color: #0369a1;
}

.sidetalk-reset-builder-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 36px;
	padding: 0 14px;
	border: 1px solid #dfe7f1;
	border-radius: 999px;
	background: #fff;
	color: #6b7687;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
	transition: all 0.2s ease;
	text-decoration: none;
	white-space: nowrap;
}

.sidetalk-reset-builder-button:hover {
	border-color: #c8d6e6;
	background: #f8fafc;
	color: #425466;
}

.sidetalk-reset-builder-button:focus {
	outline: none;
	border-color: #9fc2f2;
	box-shadow: 0 0 0 3px rgba(22, 119, 242, 0.14);
}

.sidetalk-table-form-notice {
	margin-bottom: 14px;
	padding: 14px 16px;
	border-radius: 14px;
	background: #eef6ff;
	border: 1px solid #cfe1ff;
}

.sidetalk-table-form-notice strong {
	display: block;
	font-size: 13px;
	font-weight: 700;
	color: #174a7c;
	margin-bottom: 4px;
}

.sidetalk-table-form-notice p {
	margin: 0;
	font-size: 12px;
	line-height: 1.55;
	color: #51657d;
}

#column-side-panel {
	width: 400px;
	max-width: 90vw;
	background: #fff;
	box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05);
	border-left: 1px solid #edf2f7;
}

#column-side-panel .custom-side-panel-content {
	width: 100%;
	max-width: none;
	height: 100%;
	padding: 32px 28px;
	box-sizing: border-box;
	background: #fff;
	overflow-x: hidden;
	overflow-y: auto;
}

#column-side-panel .close-btn {
	top: 20px;
	right: 20px;
	width: 36px;
	height: 36px;
	border-radius: 12px;
	background: none;
	color: var(--st-text-muted);
	font-size: 24px;
	line-height: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

#column-side-panel .close-btn:hover {
	background: var(--st-bg-secondary);
	color: var(--st-text-primary);
}

#column-side-panel h3 {
	margin: 0 0 24px;
	font-size: 20px;
	font-weight: 800;
	color: #1a1f36;
	display: flex;
	align-items: center;
	gap: 10px;
}

.sidetalk-column-panel-copy {
	margin: -2px 0 24px;
}

#column-side-panel .form-field-group {
	margin-bottom: 20px;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 0;
}

#column-side-panel .form-field-group label {
	font-size: 13px;
	font-weight: 600;
	color: #4f566b;
	margin-bottom: 8px;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
}

#column-side-panel .field-help-copy {
	margin: -2px 0 10px;
	font-size: 12px;
	line-height: 1.55;
	color: #7b8496;
}

#column-side-panel .sidetalk-dashboard-input,
#column-side-panel .sidetalk-dashboard-select {
	width: 100%;
	box-sizing: border-box;
	margin: 0;
	border-radius: 12px;
	border: 1px solid var(--st-border);
	background: #fff;
	box-shadow: none;
}

#column-side-panel textarea.sidetalk-dashboard-input {
	min-height: 88px;
	width: 100%;
	padding: 12px 14px;
	font-family: var(--st-font-family);
	font-size: var(--st-font-size-base);
	line-height: 1.5;
	color: var(--st-text-primary);
	resize: vertical;
	appearance: none;
	-webkit-appearance: none;
}

#column-side-panel .sidetalk-dashboard-input:focus,
#column-side-panel .sidetalk-dashboard-select:focus {
	border-color: var(--st-primary);
	box-shadow: 0 0 0 3px var(--st-primary-light);
	outline: none;
}

#column-side-panel .custom-side-panel-controls {
	margin-top: 32px;
	padding-top: 24px;
	border-top: 1px solid #f7fafc;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	align-items: center;
}

#column-side-panel .custom-side-panel-controls .sidetalk-dashboard-button {
	justify-content: center;
	height: 44px;
	border-radius: 10px;
	font-weight: 600;
}

#column-side-panel .field-type-gallery {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin-bottom: 20px;
}

#column-side-panel .type-item {
	padding: 12px 8px;
	border: 1px solid #eef2f7;
	border-radius: 12px;
	text-align: center;
	cursor: pointer;
	transition: all 0.2s ease;
	background: #fff;
	min-width: 0;
}

#column-side-panel .type-item i {
	display: block;
	font-size: 20px;
	margin-bottom: 6px;
	color: #697386;
}

#column-side-panel .type-item span {
	display: block;
	font-size: 11px;
	font-weight: 600;
	color: #4f566b;
	line-height: 1.3;
	word-break: keep-all;
}

#column-side-panel .type-item:hover {
	border-color: var(--st-primary);
	background: #f8fbff;
}

#column-side-panel .type-item.selected {
	border-color: var(--st-primary);
	background: #f0f7ff;
	box-shadow: 0 0 0 1px var(--st-primary);
}

#column-side-panel .type-item.selected i,
#column-side-panel .type-item.selected span {
	color: var(--st-primary);
}

#column-side-panel .sidetalk-column-options-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 10px;
}

#column-side-panel .sidetalk-column-option-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 40px;
	gap: 8px;
	align-items: center;
}

#column-side-panel .sidetalk-column-option-add {
	height: 40px;
	padding: 0 14px;
	border-radius: 10px;
	justify-content: center;
	font-weight: 600;
}

#column-side-panel .sidetalk-column-option-remove {
	width: 40px;
	height: 40px;
	padding: 0;
	border-radius: 10px;
	justify-content: center;
	font-size: 18px;
	line-height: 1;
}

.title-left-wrap {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

#sidetalk-dashboard-content .title-left-wrap .content-title {
	margin: 0;
	line-height: 1.15;
}

/* 테이블 편집 상단 탭 */
#sidetalk-dashboard-content #tables-edit-tabs {
	display: flex;
	align-items: center;
	gap: 8px;
	border-top: 1px solid #ddd !important;
	border-bottom: 0 !important;
	padding-bottom: 0 !important;
	margin-bottom: 0 !important;
}

#tables-edit-tabs a.sidetalk-navigation-btn {
	text-decoration: none;
	color: inherit;
	display: flex;
}

#tables-edit-tabs a.sidetalk-navigation-btn .navigation-text {
	text-decoration: none;
}

/* Drag styles for table header reordering */
#previewHeaderRow th.table-col-draggable {
	position: relative;
}

#previewHeaderRow th.table-col-draggable.dragging {
	opacity: 0.6;
}

#previewHeaderRow th.drop-indicator-th {
	width: 10px;
	min-width: 10px;
	max-width: 10px;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	position: relative;
}

#previewHeaderRow th.drop-indicator-th::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 8px;
	bottom: 8px;
	width: 4px;
	transform: translateX(-50%);
	background: #4f46e5;
	border-radius: 999px;
	opacity: 0.6;
}

/* Preview table layout */
.sidetalk-column-summary-list {
	display: none;
	margin: 0 0 18px;
}

.sidetalk-column-summary-note {
	margin: -2px 0 14px;
	font-size: 12px;
	line-height: 1.6;
	color: #6b7280;
}

.sidetalk-column-summary-card {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 44px;
	gap: 8px;
	align-items: stretch;
	margin-bottom: 10px;
}

.sidetalk-column-summary-card:last-child {
	margin-bottom: 0;
}

.sidetalk-column-summary-chip {
	display: grid;
	grid-template-columns: 32px minmax(0, 1fr);
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 14px 16px;
	border: 1px solid #dbe6f2;
	border-radius: 18px;
	background: #fff;
	color: #334155;
	cursor: pointer;
	transition: all 0.2s ease;
	text-align: left;
	box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
	min-height: 72px;
}

.sidetalk-column-summary-delete {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 100%;
	min-height: 72px;
	padding: 0;
	border: 1px solid #f3d4d4;
	border-radius: 18px;
	background: #fff5f5;
	color: #ef4444;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: all 0.2s ease;
}

.sidetalk-column-summary-delete:hover {
	background: #fee2e2;
	border-color: #f0b7b7;
}

.sidetalk-column-summary-chip:hover {
	border-color: var(--st-primary);
	background: #f8fbff;
	box-shadow: 0 8px 22px rgba(22, 119, 242, 0.08);
}

.sidetalk-column-summary-order {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border-radius: 999px;
	background: #edf4ff;
	color: #1463c4;
	font-size: 12px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.sidetalk-column-summary-meta {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: flex-start;
	min-width: 0;
}

.sidetalk-column-summary-name {
	max-width: none;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.35;
	font-size: 14px;
	font-weight: 700;
	color: #1f2937;
	word-break: keep-all;
}

.sidetalk-column-summary-type {
	margin-top: 4px;
	font-size: 12px;
	line-height: 1.3;
	color: #64748b;
}

.preview-table {
	display: none;
}

.preview-table th,
.preview-table td {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#previewHeaderRow th.table-col-draggable {
	position: relative;
	padding-right: 56px;
	min-height: 56px;
}

#previewHeaderRow th.table-col-draggable .column-name {
	display: inline-block;
	max-width: calc(100% - 72px);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	vertical-align: middle;
}

#previewHeaderRow th.table-col-draggable .delete-column {
	position: absolute !important;
	right: 8px !important;
	top: 50% !important;
	transform: translateY(-50%) !important;
	cursor: pointer !important;
	width: 44px !important;
	height: 44px !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	border-radius: 8px !important;
	background: rgba(0, 0, 0, 0.04) !important;
	font-size: 18px !important;
	line-height: 1 !important;
	color: #ff4d4d !important;
}

#previewHeaderRow th.table-col-draggable .delete-column:active {
	background: rgba(0, 0, 0, 0.06);
}

@media (max-width: 768px) {
	.sidetalk-tables-list-toolbar .sidetalk-button-group {
		flex-direction: column;
		align-items: stretch;
	}

	.sidetalk-tables-list-toolbar .page-size-container,
	.sidetalk-tables-list-toolbar .sidetalk-dashboard-button {
		width: 100%;
	}

	.sidetalk-table-start-cards {
		grid-template-columns: 1fr;
	}

	#previewHeaderRow th.table-col-draggable .column-name {
		max-width: min(58vw, calc(100% - 72px));
	}

	.sidetalk-navigation-wrap {
		display: flex;
		flex-wrap: wrap;
		gap: 8px;
	}

	.sidetalk-dashboard-data-add-wrap .form-controls {
		flex-direction: column;
		gap: 8px;
	}

	.preview-table-container {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.sidetalk-column-summary-list {
		margin-bottom: 16px;
	}

	.sidetalk-column-summary-card {
		grid-template-columns: minmax(0, 1fr) 40px;
	}

	.sidetalk-column-summary-chip {
		min-width: 0;
		padding: 12px 14px;
		min-height: 68px;
	}

	.sidetalk-column-summary-delete {
		min-height: 68px;
	}

	.preview-table {
		min-width: 640px;
		table-layout: auto;
	}

	.preview-table th,
	.preview-table td {
		min-width: 140px;
	}

	#previewHeaderRow th.table-col-draggable {
		padding: 30px 28px 8px 8px;
		min-height: 56px;
	}

	#previewHeaderRow th.table-col-draggable .delete-column {
		position: absolute;
		right: 6px;
		top: 6px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		border-radius: 8px;
	}

	#previewHeaderRow th.table-col-draggable .delete-column:active {
		background: rgba(0, 0, 0, 0.06);
	}

	#previewHeaderRow th.table-col-draggable .column-name {
		font-size: 11px;
		display: -webkit-box;
		line-clamp: 2;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		white-space: normal;
		word-break: keep-all;
		line-height: 1.2;
		max-height: 2.6em;
		max-width: 100%;
		margin-top: 2px;
	}

	.preview-table thead th {
		white-space: normal !important;
	}

	#column-side-panel .custom-side-panel-content {
		width: 100vw !important;
		max-width: 100vw !important;
		height: 100vh;
		border-radius: 12px 12px 0 0;
		padding: 32px 20px 20px;
	}

	#column-side-panel .field-type-gallery {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	#column-side-panel .custom-side-panel-controls {
		grid-template-columns: 1fr;
	}

	.preview-table-buttons {
		display: flex;
		justify-content: center;
		margin: 12px 0 0;
	}

	.preview-table-buttons .add-column-button {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		max-width: 360px;
		padding: 12px 14px;
		font-size: 14px;
	}

	#step-3>.sidetalk-dashboard-button.save-button {
		display: block;
		width: 100%;
		max-width: 360px;
		margin: 12px auto 0;
		padding: 12px 14px;
		font-size: 14px;
	}

	.sidetalk-dashboard-data-add-wrap {
		padding-bottom: max(16px, env(safe-area-inset-bottom));
	}
}
