/*!
 * MolViewer.css — © 2026 Jan Overwaul · https://playground.jan-overwaul.de/molecule_viewer/
 * Lizenziert unter der MIT-Lizenz: https://opensource.org/licenses/MIT
 */

/**
 * MolViewer.css
 *
 * Notwendige Styles für die MolViewer-Library.
 * Alle Klassen sind mit "molviewer-" oder "mv-" präfixiert.
 */

/* ------------------------------------------------------------ */
/* Container                                                    */
/* ------------------------------------------------------------ */
.molviewer-container {
	position: relative;
	/* Anker für Gear, Menü, Toast */
	display: block;
	background: #ffffff;
}

/* ------------------------------------------------------------ */
/* Render-Bereich (3Dmol-Canvas / SVG-Fallback / Spinner)       */
/* ------------------------------------------------------------ */
.molviewer-render {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

/* ------------------------------------------------------------ */
/* Overlay (Spinner / Fehlermeldung)                            */
/* ------------------------------------------------------------ */
.molviewer-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.95);
	z-index: 5;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 0.9rem;
	text-align: center;
	padding: 1rem;
	color: #555;
}

.molviewer-overlay.molviewer-error {
	background: #ffe6e6;
	color: #d32f2f;
	font-weight: 500;
}

/* ------------------------------------------------------------ */
/* Spinner                                                      */
/* ------------------------------------------------------------ */
.molviewer-spinner {
	width: 32px;
	height: 32px;
	border: 4px solid #f3f3f3;
	border-top-color: #333;
	border-radius: 50%;
	animation: molviewer-spin 1s linear infinite;
}

@keyframes molviewer-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ------------------------------------------------------------ */
/* SVG-Fallback                                                 */
/* ------------------------------------------------------------ */
.molviewer-svg-wrap {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.molviewer-svg-wrap svg {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
}

/* ------------------------------------------------------------ */
/* Zahnrad-Button (Controls)                                    */
/* ------------------------------------------------------------ */
.molviewer-gear {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 28px;
	height: 28px;
	padding: 5px;
	background: #ffffff;
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	color: #444;
	cursor: pointer;
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	transition: background 0.15s, color 0.15s, border-color 0.15s;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.molviewer-gear:hover {
	background: #f5f5f5;
	color: #111;
	border-color: #888;
}

.molviewer-gear:focus {
	outline: 2px solid #4a8eff;
	outline-offset: 1px;
}

.molviewer-gear svg {
	width: 100%;
	height: 100%;
	display: block;
}

/* ------------------------------------------------------------ */
/* Menü                                                         */
/* ------------------------------------------------------------ */
.molviewer-menu {
	position: absolute;
	top: 42px;
	right: 8px;
	/* breiter als vorher, damit zwei Spalten Platz haben */
	min-width: 320px;
	max-width: 360px;
	background: #ffffff;
	border: 1px solid #d0d0d0;
	border-radius: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
	z-index: 1000;
	padding: 10px;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 0.85rem;
	color: #333;
	user-select: none;
}

.molviewer-menu[hidden] {
	display: none;
}

/* 2-spaltiges Grid: Stil|Farbschema, Anzeige|Oberfläche, Rotation|Export */
.mv-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px 12px;
}

.mv-cell {
	min-width: 0; /* damit Buttons in schmalen Zellen schrumpfen dürfen */
}

/* Trennlinie zwischen den Grid-Reihen — visueller Anker */
.mv-cell:nth-child(n+3) {
	padding-top: 8px;
	border-top: 1px solid #eee;
}

/* Zurücksetzen-Sektion am Ende: separator + volle Breite */
.mv-reset-section {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid #eee;
}

/* ------------------------------------------------------------ */
/* Pattern-Info (RepSMILES — Original + Expansion als Inputs)   */
/* ------------------------------------------------------------ */
.mv-pattern-section {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid #eee;
}

.mv-pattern-label-2 {
	margin-top: 8px;
}

/* Reihe: input + kompakter Copy-Button daneben */
.mv-pattern-row {
	display: flex;
	gap: 4px;
	align-items: stretch;
}

/* Readonly-Input für Pattern bzw. expandierten SMILES.
   Optik wie eine Code-Box, aber selektierbar und kopierbar. */
.mv-pattern-input {
	flex: 1 1 auto;
	min-width: 0; /* damit das Input im flex-row schrumpfen darf */
	background: #f5f5f5;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
	padding: 5px 7px;
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-size: 0.74rem;
	line-height: 1.4;
	color: #222;
	cursor: text;
	/* Input ist single-line: bei langen SMILES horizontal scrollbar via
	   browser-eigene overflow-Logik; Wrapping wäre in input nicht möglich. */
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
	transition: border-color 0.12s, background 0.12s;
}

.mv-pattern-input:hover {
	background: #f0f0f0;
}

.mv-pattern-input:focus {
	outline: none;
	border-color: #4a8eff;
	background: #ffffff;
	/* Wenn fokussiert: kein Ellipsis, voller Inhalt sichtbar (scrollt) */
	text-overflow: clip;
}

.mv-pattern-source {
	color: #1a4a8a;
	font-weight: 500;
}

.mv-pattern-expanded {
	color: #444;
}

/* Kompakter Copy-Button rechts neben dem Input. Quadratisch, Icon-only. */
.mv-pattern-copy {
	flex: 0 0 auto;
	width: 28px;
	padding: 4px;
}

.mv-pattern-copy svg {
	width: 14px;
	height: 14px;
}

.mv-section {
	padding: 4px 2px;
}

.mv-label {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #888;
	font-weight: 600;
	margin-bottom: 5px;
	padding: 0 2px;
}

.mv-row {
	display: flex;
	gap: 4px;
}

/* Stil-Buttons: nur Icons, gleichmäßig in einer Reihe */
.mv-style-row .mv-mi {
	flex: 1 1 0;
	min-width: 0;
	padding: 6px 4px;
}

/* Menu Item — Basis-Button */
.mv-mi {
	background: #f5f5f5;
	border: 1px solid transparent;
	border-radius: 5px;
	color: #333;
	padding: 6px 10px;
	font: inherit;
	font-size: 0.82rem;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.mv-mi:hover {
	background: #e5e5e5;
	color: #111;
}

.mv-mi.is-active {
	background: #333;
	color: #fff;
	border-color: #333;
}

.mv-mi.is-active:hover {
	background: #555;
}

.mv-mi svg {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	display: block;
}

/* Stil-Icons etwas größer als Action-Icons */
.mv-style-icon svg {
	width: 18px;
	height: 18px;
}

/* Rotation-Buttons: gleichgroß, mittig */
.mv-rot {
	flex: 1 1 0;
	padding: 6px 8px;
}

/* Toggle-Buttons (H sichtbar/versteckt, 2D/3D) — kompakt nebeneinander */
.mv-toggle-btn {
	flex: 1 1 0;
	padding: 6px 8px;
	font-size: 0.78rem;
}

/* Surface-Buttons: 4 schmale Buttons in einer Reihe */
.mv-surf-row .mv-surf-btn {
	flex: 1 1 0;
	min-width: 0;
	padding: 6px 2px;
	font-size: 0.78rem;
}

/* Aktions-Buttons (PNG, SMILES, Reset) — nebeneinander, gleich breit */
.mv-actions .mv-action {
	flex: 1 1 0;
	padding: 6px 8px;
	gap: 5px;
	font-size: 0.78rem;
}

/* Disabled Button (z.B. 3D nicht verfügbar) */
.mv-mi:disabled,
.mv-mi.mv-disabled {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

/* Spinner mit Beschriftung (z.B. "Lade 3D…") */
.mv-loading-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.mv-loading-label {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 0.8rem;
	color: #666;
}

/* ------------------------------------------------------------ */
/* Toast (kurze Bestätigungs-Hinweise)                          */
/* ------------------------------------------------------------ */
.molviewer-toast {
	position: absolute;
	left: 50%;
	bottom: 12px;
	transform: translate(-50%, 8px);
	background: rgba(20, 20, 20, 0.92);
	color: #fff;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 0.82rem;
	padding: 6px 14px;
	border-radius: 4px;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.18s, transform 0.18s;
	z-index: 1010;
	white-space: nowrap;
}

.molviewer-toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ------------------------------------------------------------ */
/* Maximize-Button (Vollbild öffnen)                            */
/* ------------------------------------------------------------ */
.molviewer-maximize {
	position: absolute;
	top: 8px;
	/* Links neben dem Zahnrad: 8px Rand + 28px Gear + 6px Abstand = 42px */
	right: 42px;
	width: 28px;
	height: 28px;
	padding: 6px;
	background: #ffffff;
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	color: #444;
	cursor: pointer;
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.molviewer-maximize:hover {
	background: #f5f5f5;
	color: #111;
	border-color: #888;
}

.molviewer-maximize:focus {
	outline: 2px solid #4a8eff;
	outline-offset: 1px;
}

.molviewer-maximize svg {
	width: 100%;
	height: 100%;
	display: block;
}

/* ------------------------------------------------------------ */
/* Modal / Vollbild-Overlay                                     */
/* ------------------------------------------------------------ */
.molviewer-modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15, 15, 20, 0.78);
	z-index: 9000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2vh 2vw;
	/* sanftes Einblenden */
	animation: molviewer-modal-fade 0.18s ease-out;
}

@keyframes molviewer-modal-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.molviewer-modal-content {
	position: relative;
	width: 100%;
	height: 100%;
	max-width: 1400px;
	max-height: 90vh;
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.molviewer-modal-close:focus {
	outline: 2px solid #4a8eff;
	outline-offset: 1px;
}

.molviewer-modal-close {
	position: absolute;
	top: 8px;        /* bündig mit Zahnrad-Mitte (22px ab top) */
	right: 45px;     /* links vom Zahnrad mit Luft dazwischen */
	width: 28px;
	height: 28px;
	padding: 8px;
	background: rgba(255, 255, 255, 0.95);
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	color: #333;
	cursor: pointer;
	z-index: 30;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
	transition: background 0.15s, color 0.15s, transform 0.12s;
}

/* Der Klon-Viewer im Modal — füllt den verfügbaren Raum komplett */
.molviewer-modal-viewer {
	flex: 1;
	width: 100%;
	min-height: 300px;
}