@use "../../../components/multipleSelect/editor.scss";

.sp-real-settings-page-container {
	gap: 32px;
	// min-height: 360px;
	align-items: flex-start;
	background: transparent;

	ul,
	li {
		margin: 0;
		padding: 0;
	}

	// sidebar wrapper.
	.sp-real-setting-tabs-wrapper {
		width: 248px;
		background: #ffffff;
		border: 1px solid #dddddd;
		border-radius: 12px;
		padding: 16px;
		box-shadow: 0 1px 2px 0 rgba(17, 17, 17, 0.04);
	}

	.sp-real-setting-tabs {
		list-style: none;
	}

	// tab nav item style.
	.sp-real-setting-tab {
		font-size: 14px;
		line-height: 1.4px;
		font-weight: 500;
		color: #1e1e1e;
		background: transparent;
		padding: 11px 8px 11px 20px;
		border-radius: 6px;
		transition: all 0.3s ease-in-out;
		list-style: none;
		border: 1px solid transparent;

		.sp-real-setting-icon {
			display: inline-flex;
			align-items: center;
			justify-content: center;

			svg {
				height: 16px;
				width: 16px;
			}

			path {
				transition: stroke 0.3s ease;
			}
		}

		.sp-real-setting-tab-arrow {
			display: inline-flex;
			align-items: center;
			color: var(--sp-real-primary-color);
		}

		&:hover:not(.active) {
			background: #f9fafb;
		}

		&.active {
			color: var(--sp-real-primary-color);
			border-color: var(--sp-real-primary-color);

			.sp-real-setting-icon path {
				fill: var(--sp-real-primary-color);
			}
		}
	}

	// tab content wrapper.
	.sp-real-setting-tab-content-wrapper {
		flex: 1;
		background: #ffffff;
		border: 1px solid #dddddd;
		border-radius: 12px;
		overflow: hidden;
	}

	// tab content.
	.sp-real-setting-tab-content {
		height: 100%;
		padding: 32px;
	}

	// separator line style.
	.sp-real-settings-separator {
		width: 100%;
		height: 1px;
		background-color: #f3f4f6;
	}
}

// License key manage tab styles.
.sp-real-dashboard-license-settings {
	height: 100%;
	padding: 60px 0;

	.sp-real-license-tab-section-title {
		font-size: 22px;
		font-weight: 600;
		line-height: 28px;
		margin: 0 0 12px;
		color: #111827;
	}

	.sp-real-help-text {
		color: #6b7280;
		font-size: 14px;
		font-weight: 400;
		line-height: 22px;

		a {
			color: var(--sp-real-link-color, #2563eb);
			text-decoration: none;

			&:hover {
				text-decoration: underline;
			}
		}
	}

	// input control.
	.sp-real-input-control {
		width: 380px;

		.components-input-control__input {
			height: 42px !important;
		}

		.sp-real-input-control-header-left {
			display: none;
		}

		.components-base-control {
			flex: 1;
			max-width: 460px;
			position: relative;
		}

		.key-icon {
			left: 12px;
			position: absolute;
			top: 11px;
		}

		.components-input-control__input {
			padding-left: 40px !important;
		}
	}

	.components-input-control__backdrop {
		border: 1px solid #d1d5db !important;
		border-radius: 6px !important;
	}

	.components-base-control__help {
		margin: 0;
		padding: 0;
	}

	.sp-real-settings-option {
		margin-top: 24px;
		gap: 8px;
	}

	.sp-real-license-action-btn {
		font-size: 14px;
		font-weight: 600;
		line-height: 20px;
		padding: 0 22px;
		border-radius: 6px;
		border: none;
		outline: none;
		height: 42px;

		&.deactivate {
			color: rgb(220, 53, 69);
			background-color: rgb(246, 247, 247);
			border: 1px solid rgb(220, 53, 69);

			.components-spinner {
				color: rgb(220, 53, 69);
			}
		}

		&.active {
			color: #ffffff;
			background-color: var(--sp-real-link-color, #2563eb);

			&:hover {
				background-color: #1d4ed8;
			}
		}

		&.disabled {
			opacity: 0.6;
			pointer-events: none;
		}
	}

	.sp-real-settings-option.license-active {
		input {
			pointer-events: none;
			color: #757575 !important;
		}
	}

	.active-status {
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		right: 7px;
		padding: 4px 10px;
		border-radius: 3px;
		line-height: 20px;
		color: #fff;
		background-color: #28a745;
	}

	.sp-real-api-integration-notice {
		background-color: #fff3cd;
		color: #856404;
		font-size: 14px;
		padding: 12px 20px;
		margin-top: 12px;
		border-radius: 2px;
		max-width: 476px;
		width: 100%;
	}
}

// performance + advanced controls tab styles.
.sp-real-dashboard-advanced-settings {
	.sp-real-component-title {
		min-width: 600px;
	}

	.sp-real-component-help {
		color: #6b7280;
		font-size: 13px;
		font-weight: 400;
		line-height: 1.4;
		letter-spacing: 0;
	}

	.sp-real-flush-cache-btn {
		color: #ffffff;
		background-color: var(--sp-real-link-color, #2563eb);
		padding: 8px 16px;
		border: none;
		border-radius: 6px;
		font-size: 13px;
		font-weight: 500;

		&:hover {
			background-color: #1d4ed8;
		}
	}

	.sp-real-settings-option {
		gap: 24px;
	}

	// numeric input with unit suffix.
	.sp-real-settings-number-input-wrapper {
		gap: 8px;

		.sp-real-settings-number-input {
			width: 90px;
			height: 40px;
			padding: 0 12px;
			border-radius: 6px;
			border: 1px solid #d1d5db;
			font-size: 14px;
			color: #1f2937;
			background-color: #ffffff;
			transition:
				border-color 0.15s ease,
				box-shadow 0.15s ease;

			&:focus,
			&:focus-visible {
				outline: none;
				border-color: #3b5bfe;
				box-shadow: 0 0 0 3px rgba(59, 91, 254, 0.2);
			}
		}

		.sp-real-settings-number-unit {
			font-size: 14px;
			font-weight: 500;
			color: #6b7280;
		}
	}

	// segmented control.
	.sp-real-settings-button-set {
		border: 1px solid #d1d5db;
		border-radius: 6px;
		overflow: hidden;

		.sp-real-settings-button-set-option {
			padding: 8px 16px;
			font-size: 13px;
			font-weight: 500;
			color: #1f2937;
			background-color: #ffffff;
			border: none;
			border-right: 1px solid #d1d5db;
			transition:
				background-color 0.15s ease,
				color 0.15s ease;

			&:last-child {
				border-right: none;
			}

			&:hover:not(.active) {
				background-color: #f9fafb;
			}

			&.active {
				color: #ffffff;
				background-color: var(--sp-real-link-color, #2563eb);
			}
		}
	}
}

// tools tab styles.
.sp-real-dashboard-tools-settings {
	gap: 36px;

	.sp-real-tools-title {
		min-width: 120px;
		padding-top: 4px;
	}

	.sp-real-tools-control {
		width: 65%;
	}

	.sp-real-tools-radio {
		.sp-real-tools-radio-option {
			font-size: 14px;
			color: #1f2937;
		}
	}

	.sp-real-tools-action-btn {
		align-self: flex-start;
		color: #ffffff;
		padding: 10px 16px;
		border: none;
		border-radius: 6px;
		font-size: 14px;
		line-height: 1.4;
		font-weight: 600;
		margin-top: 12px;
		transition: background-color 0.3s ease;

		&.primary {
			background-color: var(--sp-real-link-color, #2563eb);

			&:hover {
				background-color: #1d4ed8;
			}

			&:disabled {
				opacity: 0.6;
				pointer-events: none;
			}
		}

		&.secondary {
			background-color: #9ca3af;

			&.active {
				background-color: var(--sp-real-link-color, #2563eb);

				&:hover {
					background-color: #1d4ed8;
				}
			}

			&.disabled,
			&:disabled {
				cursor: not-allowed;
				pointer-events: none;
			}
		}
	}

	.sp-real-tools-file {
		.sp-real-tools-file-label {
			display: inline-flex;
			align-items: center;
			padding: 7px 14px;
			border: 1px solid #4b5563;
			border-radius: 4px;
			background-color: #ffffff;
			color: #1f2937;
			font-size: 13px;
			font-weight: 500;

			&:hover {
				background-color: #f9fafb;
			}
		}

		.sp-real-tools-file-name {
			color: #6b7280;
			font-size: 13px;
		}

		&.dragging {
			border: 2px dashed var(--sp-real-link-color, #2563eb);
			background-color: #f0f9ff;
			padding: 10px;
			border-radius: 4px;
			transition: all 0.2s ease;
		}
	}

	.sp-real-tools-status {
		padding: 10px 14px;
		border-radius: 6px;
		font-size: 14px;
	}

	.sp-real-tools-status-success {
		background-color: #ecfdf5;
		color: #047857;
	}

	.sp-real-tools-status-error {
		background-color: #fef2f2;
		color: #b91c1c;
	}
}

// custom css and js styles.
.sp-real-settings-custom-assets {
	.sp-real-code-editor-component {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		gap: 16px;
	}

	// CodeMirror sizes itself via setSize(), so the column must not pin a height.
	// min-width keeps a long unwrapped line from blowing out the flex row.
	.sp-real-code-editor {
		width: 78%;
		min-width: 0;
	}

	// Dark skin for the WP core code editor, scoped to this tab so nothing else
	// inherits it. WP ships no CodeMirror theme stylesheet, so the token colors
	// are set here — this is what preserves the previous vs-dark appearance.
	.CodeMirror {
		background: #1e1e1e;
		color: #d4d4d4;
		border-color: #3c3c3c;
	}

	.CodeMirror-gutters {
		background: #1e1e1e;
		border-right-color: #3c3c3c;
	}

	.CodeMirror-linenumber {
		color: #6e7681;
	}

	.CodeMirror-cursor {
		border-left-color: #d4d4d4;
	}

	.CodeMirror-selected,
	.CodeMirror-focused .CodeMirror-selected {
		background: #264f78;
	}

	.CodeMirror-activeline-background {
		background: #2a2a2a;
	}

	.CodeMirror-matchingbracket {
		color: #ffd700;
		outline: none;
	}

	.cm-comment {
		color: #6a9955;
	}

	.cm-atom,
	.cm-number {
		color: #b5cea8;
	}

	.cm-keyword,
	.cm-tag {
		color: #569cd6;
	}

	.cm-property,
	.cm-attribute,
	.cm-def,
	.cm-variable-2 {
		color: #9cdcfe;
	}

	.cm-string,
	.cm-string-2 {
		color: #ce9178;
	}

	.cm-operator,
	.cm-punctuation,
	.cm-bracket {
		color: #d4d4d4;
	}

	.cm-variable,
	.cm-variable-3,
	.cm-qualifier {
		color: #dcdcaa;
	}

	.cm-error {
		color: #f48771;
	}
}

.sp-real-tools-select-list {
	.sp-real-component-title {
		display: block;
	}

	input {
		&:focus {
			outline: none;
			box-shadow: none;
		}
	}
}

/* Classic Settings tab — legacy framework settings surfaced in React. */
.sp-real-classic-settings {
	// horizontal sub-tab bar (Custom Menu / Control Assets).
	.sp-real-classic-sub-tabs {
		list-style: none;
		border-bottom: 1px solid #e5e7eb;
		margin: 0 0 28px;
		gap: 8px;
	}

	.sp-real-classic-sub-tab {
		position: relative;
		padding: 10px 4px;
		margin-right: 24px;
		font-size: 14px;
		font-weight: 500;
		color: #6b7280;
		border-bottom: 2px solid transparent;
		transition:
			color 0.2s ease,
			border-color 0.2s ease;
		list-style: none;

		&:hover:not(.active) {
			color: var(--sp-real-primary-color);
		}

		&.active {
			color: var(--sp-real-primary-color);
			border-bottom-color: var(--sp-real-primary-color);
		}
	}

	// text input (Custom Menu names).
	.sp-real-settings-text-input {
		width: 280px;
		height: 40px;
		padding: 0 12px;
		border-radius: 6px;
		border: 1px solid #d1d5db;
		font-size: 14px;
		color: #1f2937;
		background-color: #ffffff;
		transition:
			border-color 0.15s ease,
			box-shadow 0.15s ease;

		&:focus,
		&:focus-visible {
			outline: none;
			border-color: #3b5bfe;
			box-shadow: 0 0 0 3px rgba(59, 91, 254, 0.2);
		}
	}
}
