/* ==================================================================
   AI API Gateway — Theme Settings drawer
   ==================================================================
   A right-side sheet, opened from the palette icon in the full
   panel header (data-aiapi-theme-drawer-trigger). Structurally and
   visually it mirrors the plugin's existing "Create API Key" drawer
   (see .aiapi-keys-drawer in keys-tab.css) — same overlay, same
   slide-in-from-the-end panel, same header/body/footer split — so it
   reuses the same --aiapi-* design tokens and needs no styling of
   its own for colors, only for its own layout.
   ================================================================== */

.aiapi-theme-drawer-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .45);
	z-index: 95;
	opacity: 0;
	pointer-events: none;
	transition: opacity .18s ease;
}
.aiapi-theme-drawer-overlay.is-open {
	opacity: 1;
	pointer-events: auto;
}

.aiapi-theme-drawer {
	position: fixed;
	top: 0;
	bottom: 0;
	inset-inline-end: 0;
	width: min(400px, 100vw);
	background: var(--aiapi-card);
	z-index: 96;
	display: flex;
	flex-direction: column;
	box-shadow: var(--aiapi-shadow-md);
	opacity: 0;
	visibility: hidden;
	transition: opacity .18s ease, visibility 0s linear .18s;
}
.aiapi-theme-drawer.is-open {
	opacity: 1;
	visibility: visible;
	transition: opacity .18s ease, visibility 0s linear 0s;
}

.aiapi-theme-drawer-header {
	position: relative;
	padding: 16px 44px 16px 20px;
	border-bottom: 1px solid var(--aiapi-card-border);
	flex-shrink: 0;
}
[dir="rtl"] .aiapi-theme-drawer-header { padding: 16px 20px 16px 44px; }
.aiapi-theme-drawer-header h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--aiapi-foreground); }
.aiapi-theme-drawer-header p { margin: 4px 0 0; font-size: 12px; color: var(--aiapi-muted-foreground); }
.aiapi-theme-drawer-close { position: absolute; top: 12px; inset-inline-end: 12px; }

.aiapi-theme-drawer-body {
	flex: 1;
	overflow-y: auto;
	padding: 18px 20px;
	display: flex;
	flex-direction: column;
	gap: 22px;
}

.aiapi-theme-drawer-footer {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	padding: 14px 20px;
	border-top: 1px solid var(--aiapi-card-border);
	flex-shrink: 0;
}

/* ---- Shared section heading ---- */
.aiapi-theme-section-title {
	font-size: 12.5px;
	font-weight: 700;
	color: var(--aiapi-muted-foreground);
	margin-bottom: 10px;
}

/* ---- Generic option row (Theme / Font / Density / Direction) ---- */
.aiapi-theme-option-row {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 10px;
}

.aiapi-theme-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 6px;
	background: var(--aiapi-muted);
	border: 1px solid var(--aiapi-card-border);
	border-radius: var(--aiapi-radius-sm);
	color: var(--aiapi-muted-foreground);
	font-size: 11.5px;
	font-weight: 600;
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.aiapi-theme-option:hover {
	border-color: var(--aiapi-card-border-strong);
	color: var(--aiapi-foreground);
}

.aiapi-theme-option[aria-checked="true"] {
	border-color: var(--aiapi-primary);
	background: var(--aiapi-primary-soft);
	color: var(--aiapi-primary);
}

.aiapi-theme-option-icon { display: inline-flex; }
.aiapi-theme-option-label { line-height: 1.3; text-align: center; }

/* Font preview glyphs ("Aa") */
.aiapi-theme-option-glyph {
	font-size: 17px;
	font-weight: 600;
	color: var(--aiapi-foreground);
	line-height: 1;
}

/* ---- Color preset swatch grid ---- */
.aiapi-theme-swatch-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 10px;
}

.aiapi-theme-swatch {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
}

.aiapi-theme-swatch-color {
	position: relative;
	height: 40px;
	border-radius: var(--aiapi-radius-xs);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	transition: border-color .15s ease, box-shadow .15s ease;
}

/* The check icon only shows once a preset is selected. */
.aiapi-theme-swatch-color svg { opacity: 0; transition: opacity .15s ease; }

.aiapi-theme-swatch[aria-checked="true"] .aiapi-theme-swatch-color {
    border: 1px solid var(--aiapi-primary);
}

.aiapi-theme-swatch[aria-checked="true"] .aiapi-theme-swatch-color svg {
	opacity: 1;
}

.aiapi-theme-swatch-label {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--aiapi-muted-foreground);
	text-align: center;
}

.aiapi-theme-swatch[aria-checked="true"] .aiapi-theme-swatch-label {
	color: var(--aiapi-foreground);
}

/* ---- Border radius grid (visual corner previews) ---- */
.aiapi-theme-radius-grid {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 8px;
}

.aiapi-theme-radius-preview {
	width: 22px;
	height: 22px;
	border-top: 2px solid var(--aiapi-muted-foreground-soft);
	border-inline-start: 2px solid var(--aiapi-muted-foreground-soft);
}

.aiapi-theme-option[aria-checked="true"] .aiapi-theme-radius-preview {
	border-color: var(--aiapi-primary);
}

/* ---- Density bar previews ---- */
.aiapi-theme-density-preview {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	justify-content: center;
	gap: 4px;
	width: 100%;
	height: 18px;
}

.aiapi-theme-density-preview span {
	display: block;
	height: 2px;
	border-radius: 999px;
	background: var(--aiapi-muted-foreground-soft);
}

.aiapi-theme-option[aria-checked="true"] .aiapi-theme-density-preview span {
	background: var(--aiapi-primary);
}

.aiapi-theme-density-preview-compact { gap: 3px; }
.aiapi-theme-density-preview-comfortable { gap: 0; justify-content: center; }

/* ---- Danger-soft footer button (Reset) ---- */
.aiapi-btn-danger-soft {
	background: var(--aiapi-danger-bg);
	color: var(--aiapi-danger);
	border-color: transparent;
}
.aiapi-btn-danger-soft:hover {
	background: var(--aiapi-danger-border);
}

@media (max-width: 480px) {
	.aiapi-theme-drawer { width: 100%; }
	.aiapi-theme-swatch-grid,
	.aiapi-theme-radius-grid { grid-template-columns: repeat(3, 1fr); }
}