/* ============================================================================
   SETTINGS MODAL STYLES
   Built on the theme variables from main.css so the dialog follows the UI theme.
   ============================================================================ */

.settings-modal {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(var(--theme-bg-primary-rgb), 0.7);
	z-index: 23000;
	align-items: center;
	justify-content: center;
}

.settings-modal.active {
	display: flex;
}

.settings-content {
	background: var(--theme-bg-secondary);
	border: 1px solid var(--theme-border-primary);
	border-radius: 12px;
	padding: 2.5rem;
	min-width: 750px;
	max-width: 900px;
	width: 90%;
	max-height: 90vh;
	overflow-y: auto;
	color: var(--theme-text-primary);
	box-shadow: var(--theme-shadow-primary);
	animation: settingsSlideIn 0.3s ease-out;
}

@keyframes settingsSlideIn {
	from {
		opacity: 0;
		transform: scale(0.95) translateY(-20px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

.settings-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 2rem;
	padding-bottom: 1.25rem;
	border-bottom: 2px solid var(--theme-border-primary);
}

.settings-header h2 {
	color: var(--theme-text-accent);
	font-size: 1.75rem;
	font-weight: 600;
	letter-spacing: 0.5px;
	margin: 0;
}

.close-settings {
	background: transparent;
	border: none;
	color: var(--theme-text-secondary);
	font-size: 2rem;
	cursor: pointer;
	padding: 0.5rem;
	line-height: 1;
	transition: background 0.2s ease, color 0.2s ease;
	border-radius: 4px;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.close-settings:hover {
	color: var(--theme-text-primary);
	background: var(--theme-bg-hover);
}

.settings-group {
	margin-bottom: 2rem;
}

.settings-label {
	display: block;
	margin-bottom: 0.75rem;
	color: var(--theme-text-primary);
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.3px;
}

.settings-select {
	width: 100%;
	padding: 1rem 1.25rem;
	background: var(--theme-bg-primary);
	border: 2px solid var(--theme-border-primary);
	border-radius: 8px;
	color: var(--theme-text-primary);
	font-size: 1rem;
	cursor: pointer;
	transition: border-color 0.2s ease;
}

.settings-select:hover {
	border-color: var(--theme-primary);
}

.settings-select:focus {
	outline: none;
	border-color: var(--theme-primary);
	box-shadow: var(--theme-shadow-accent);
}

.theme-preview {
	margin-top: 1rem;
	padding: 1.25rem;
	background: var(--theme-bg-primary);
	border: 2px solid var(--theme-border-primary);
	border-radius: 8px;
	font-family: 'Courier New', monospace;
	font-size: 0.95rem;
	line-height: 1.6;
	transition: border-color 0.2s ease;
}

.theme-preview:hover {
	border-color: var(--theme-primary);
}

.color-picker {
	width: 100%;
	height: 40px;
	border: 1px solid var(--theme-border-primary);
	border-radius: 4px;
	cursor: pointer;
	margin-top: 0.25rem;
}

.color-picker:hover {
	border-color: var(--theme-primary);
}

/* ============================================================================
   LAYOUT HELPERS
   ============================================================================ */

.settings-row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.settings-row.wrap {
	flex-wrap: wrap;
}

.settings-stack {
	margin-top: 0.5rem;
}

.settings-row > .settings-label {
	margin: 0;
}

.settings-row > .toggle-switch,
.settings-row > .settings-select,
.settings-row > .settings-input {
	margin-left: auto;
	flex-shrink: 0;
}

.settings-row > .settings-select {
	width: auto;
	min-width: 100px;
}

.settings-row > .settings-input {
	width: 200px;
}

.settings-row > .settings-input.grow {
	flex: 1;
	width: auto;
	margin-left: 0;
}

.settings-hint {
	color: var(--theme-text-secondary);
	font-size: 0.85rem;
}

.settings-help {
	display: block;
	margin-top: 0.5rem;
	color: var(--theme-text-secondary);
}

.settings-help .accent {
	color: var(--theme-text-accent);
}

.settings-section {
	border-top: 2px solid var(--theme-border-primary);
	padding-top: 2rem;
	margin-top: 2rem;
}

.settings-section-title {
	color: var(--theme-text-accent);
	font-size: 1.25rem;
	margin: 0 0 1rem 0;
}

.settings-subsection {
	margin-top: 0.75rem;
	padding-top: 0.5rem;
	border-top: 1px solid var(--theme-border-primary);
}

.settings-subsection-title {
	color: var(--theme-text-secondary);
	font-size: 0.85rem;
	font-weight: 600;
}

.settings-color-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
	margin-top: 1rem;
}

.settings-color-grid label {
	font-size: 0.85rem;
	color: var(--theme-text-secondary);
}

.settings-check-group {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.settings-check-group label {
	display: flex;
	align-items: center;
	gap: 0.35rem;
}

.settings-provider-list {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	margin: 1rem 0;
}

.settings-provider {
	border: 1px solid var(--theme-border-primary);
	border-radius: 6px;
	padding: 0.65rem;
}

.settings-provider .settings-label {
	margin-top: 0.35rem;
}

.settings-provider-head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.25rem;
}

.settings-provider-head strong {
	color: var(--theme-text-accent);
}

.settings-provider-actions {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 0.35rem;
}

.settings-note {
	margin-top: 0.5rem;
	padding: 0.75rem;
	border-radius: 6px;
	background: var(--theme-bg-primary);
}

.settings-note ul {
	margin: 0;
	padding-left: 1.2rem;
	color: var(--theme-text-secondary);
	font-size: 0.9rem;
	line-height: 1.4;
}

.settings-test-result {
	margin-top: 0.5rem;
	padding: 6px 10px;
	border-radius: 6px;
	border: 1px solid var(--theme-border-primary);
	background: var(--theme-bg-primary);
	color: var(--theme-text-secondary);
	font-size: 0.8rem;
	word-break: break-word;
}

.settings-test-result.is-success {
	border-color: rgba(40, 167, 69, 0.55);
	color: var(--theme-text-primary);
}

.settings-test-result.is-error {
	border-color: rgba(239, 68, 68, 0.5);
	background: rgba(239, 68, 68, 0.08);
	color: var(--theme-text-primary);
}

.settings-test-result .line {
	display: block;
}

.settings-test-result .warning {
	color: var(--theme-text-secondary);
}

.ai-test-result {
	font-size: 0.9rem;
}

.ai-test-pending {
	background: var(--theme-bg-hover);
	color: var(--theme-text-primary);
}

/* ============================================================================
   THEME CARDS
   ============================================================================ */

.theme-category {
	margin-bottom: 2rem;
}

.theme-category:last-child {
	margin-bottom: 0;
}

.theme-category-title {
	color: var(--theme-text-secondary);
	font-size: 0.95rem;
	font-weight: 600;
	margin: 0 0 1rem 0;
}

.theme-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 1rem;
	margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
	.theme-grid {
		grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
		gap: 0.75rem;
	}

	.theme-card-preview {
		height: 70px;
		font-size: 0.7rem;
		padding: 0.5rem;
	}

	.theme-card-label {
		padding: 0.5rem;
		font-size: 0.8rem;
	}
}

.theme-card {
	cursor: pointer;
	border-radius: 8px;
	overflow: hidden;
	transition: border-color 0.2s ease;
	border: 2px solid var(--theme-border-primary);
	background: var(--theme-bg-primary);
}

.theme-card:hover,
.theme-card.active {
	border-color: var(--theme-primary);
}

.paper-card {
	cursor: pointer;
	border-radius: 8px;
	overflow: hidden;
	transition: border-color 0.2s ease;
	border: 2px solid var(--theme-border-primary);
	background: var(--theme-bg-sunken);
}

.paper-card:hover,
.paper-card.active,
.paper-card:focus-visible {
	border-color: var(--theme-primary);
	outline: none;
}

.paper-card-preview {
	height: 80px;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* The three gradients draw text lines on the page. The markup sets the page
   colour with background-color; the background shorthand would remove them. */
.paper-card-page {
	width: 42px;
	height: 56px;
	box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
	background-image: linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor);
	background-repeat: no-repeat;
	background-size: 16px 3px, 28px 2px, 22px 2px;
	background-position: 7px 10px, 7px 20px, 7px 27px;
}

.theme-card-preview {
	height: 80px;
	padding: 0.75rem;
	font-family: 'Courier New', monospace;
	font-size: 0.75rem;
	line-height: 1.4;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.theme-card-preview.custom {
	align-items: center;
}

.theme-card-preview.custom svg {
	width: 28px;
	height: 28px;
}

.theme-card-label {
	padding: 0.75rem;
	background: var(--theme-bg-tertiary);
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 0.85rem;
	color: var(--theme-text-primary);
	font-weight: 500;
}

.theme-badge {
	background: var(--theme-primary);
	color: var(--theme-on-primary);
	font-size: 0.7rem;
	padding: 0.2rem 0.5rem;
	border-radius: 4px;
	font-weight: 600;
}

/* ============================================================================
   COLLAPSIBLE SECTION
   ============================================================================ */

.collapsible-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	cursor: pointer;
	padding: 0.5rem 0;
	user-select: none;
	transition: opacity 0.2s ease;
}

.collapsible-header:hover {
	opacity: 0.8;
}

.collapsible-header .settings-label {
	margin: 0;
	flex: 1;
	cursor: pointer;
}

.collapse-toggle {
	background: transparent;
	border: none;
	color: var(--theme-text-accent);
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
	transition: background 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.collapse-toggle:hover {
	background: var(--theme-bg-hover);
}

.collapse-icon {
	display: inline-block;
	transition: transform 0.3s ease;
	font-size: 0.8rem;
}

.collapsible-header.collapsed .collapse-icon {
	transform: rotate(-90deg);
}

.collapsible-content {
	overflow: hidden;
	transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
	max-height: 2000px;
	opacity: 1;
	padding-top: 0.5rem;
}

.collapsible-content.collapsed {
	max-height: 0;
	opacity: 0;
	padding-top: 0;
	padding-bottom: 0;
	margin-top: 0;
}

.collapsible-content > .settings-hint {
	margin: 0.5rem 0 0.75rem;
}

/* ============================================================================
   INPUTS AND BUTTONS
   ============================================================================ */

.settings-input {
	width: 100%;
	padding: 1rem 1.25rem;
	background: var(--theme-bg-primary);
	border: 2px solid var(--theme-border-primary);
	border-radius: 8px;
	color: var(--theme-text-primary);
	font-size: 1rem;
	transition: border-color 0.2s ease;
	font-family: inherit;
}

.settings-input::placeholder {
	color: var(--theme-text-muted);
}

.settings-input:hover {
	border-color: var(--theme-primary);
}

.settings-input:focus {
	outline: none;
	border-color: var(--theme-primary);
	box-shadow: var(--theme-shadow-accent);
}

.settings-button {
	background: var(--theme-primary);
	color: var(--theme-on-primary);
	border: none;
	padding: 0.75rem 1.5rem;
	border-radius: 4px;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease;
}

.settings-button:hover {
	background: var(--theme-primary-hover);
	color: var(--theme-on-primary);
}

.settings-button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.settings-button.secondary {
	background: var(--theme-secondary);
	color: var(--theme-text-primary);
}

.settings-button.secondary:hover {
	background: var(--theme-secondary-hover);
}

.settings-button.small {
	padding: 0.35rem 0.65rem;
	font-size: 0.85rem;
}

.settings-button.grow {
	flex: 1;
}

.settings-button.block {
	width: 100%;
}

/* Old .history-item / .snapshot-item styles removed — see version-history-panel.css */

/* ============================================================================
   DIFF VIEW STYLES
   ============================================================================ */

.diff-view {
	font-family: 'Courier New', monospace;
	font-size: 0.9rem;
	line-height: 1.6;
	background: var(--theme-bg-primary);
	border-radius: 6px;
	overflow: hidden;
}

.diff-line {
	display: flex;
	padding: 0.25rem 0.5rem;
	border-left: 3px solid transparent;
	transition: background-color 0.2s ease;
}

.diff-line:hover {
	background: rgba(var(--theme-overlay-rgb), 0.05);
}

.diff-line-number {
	display: inline-block;
	min-width: 3rem;
	padding-right: 1rem;
	color: var(--theme-text-muted);
	text-align: right;
	user-select: none;
	font-size: 0.85rem;
}

.diff-content {
	flex: 1;
	white-space: pre-wrap;
	word-break: break-word;
}

.diff-equal {
	color: var(--theme-text-primary);
}

.diff-delete {
	background: rgba(231, 76, 60, 0.15);
	border-left-color: #e74c3c;
	color: var(--theme-text-error);
}

.diff-delete .diff-line-number {
	color: var(--theme-text-error);
}

.diff-insert {
	background: rgba(46, 204, 113, 0.15);
	border-left-color: #2ecc71;
	color: var(--theme-text-success);
}

.diff-insert .diff-line-number {
	color: var(--theme-text-success);
}

.diff-word {
	padding: 0.1rem 0.2rem;
	border-radius: 2px;
}

.diff-word.diff-equal {
	background: transparent;
}

.diff-word.diff-delete {
	background: rgba(231, 76, 60, 0.3);
	text-decoration: line-through;
}

.diff-word.diff-insert {
	background: rgba(46, 204, 113, 0.3);
}

.diff-viewer {
	background: var(--theme-bg-primary);
	border-radius: 6px;
	padding: 1rem;
	max-height: 500px;
	overflow-y: auto;
	margin-top: 1rem;
}

.diff-viewer-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--theme-border-primary);
}

.diff-viewer-title {
	color: var(--theme-text-accent);
	font-weight: 600;
	font-size: 1rem;
}

.diff-viewer-close {
	background: transparent;
	border: none;
	color: var(--theme-text-secondary);
	cursor: pointer;
	font-size: 1.5rem;
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
	transition: all 0.2s ease;
}

.diff-viewer-close:hover {
	color: var(--theme-text-error);
	background: rgba(231, 76, 60, 0.1);
}

.diff-file-header {
	background: var(--theme-bg-tertiary);
	padding: 0.75rem 1rem;
	border-radius: 6px;
	margin-bottom: 0.5rem;
	font-weight: 600;
	color: var(--theme-text-accent);
	font-size: 0.9rem;
}

.diff-stats {
	display: flex;
	gap: 1rem;
	margin-top: 0.5rem;
	font-size: 0.85rem;
	color: var(--theme-text-secondary);
}

.diff-stat {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.diff-stat-additions {
	color: var(--theme-text-success);
}

.diff-stat-deletions {
	color: var(--theme-text-error);
}

.diff-stat-changes {
	color: var(--theme-text-accent);
}

