/*
 * PATH: css/main.css
 */
:root {
	--primary-bg: #333333;
	--secondary-bg: #4449;
	--panel-bg: #222;
	--panel-header-bg: #2e2e2e80;
	--border-color: #404040;
	--border-light: #505050;
	--text-primary: #e5e5e5;
	--text-secondary: #99999999;
	--text-muted: #ffffff66;
	--accent: #0066ff;
	--accent-hover: #0052cc;
	--warning: #ff9500;
	--success: #28a745;
	--danger: #dc3545;
	--transition-fast: all 0.2s ease;
}
* {
	box-sizing: border-box;
}
body {
	font-family: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI",
		system-ui, sans-serif;
	background: var(--primary-bg);
	color: var(--text-primary);
	margin: 0;
	overflow: hidden;
	height: 100vh;
	display: flex;
	flex-direction: column;
	font-size: 13px;
}
.main-container {
	background: var(--panel-bg);
	border-bottom: 1px solid var(--border-color);
	padding: 8px;
	flex-shrink: 0;
}
.main-toolbar {
	display: flex;
	gap: 6px;
	align-items: center;
}

.window {
	position: absolute;
	background: transparent;
	border: none;
	overflow: visible;
	min-width: 190px;
	min-height: 72px;
	resize: none;
	box-sizing: border-box;
	perspective: 1000px;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}
.window-viewport {
	width: 100%;
	height: 100%;
	overflow: visible;
}
.window.hidden {
	display: none;
}
.window.is-minimized {
	height: 36px !important;
	min-height: 1px !important;
	resize: none;
	border-radius: 6px;
}
.window--palette.window.is-minimized {
	height: 28px !important;
}
.window.is-minimized .window__header {
	border-radius: 6px;
	border-bottom: none;
}

.window.is-maximized {
	border-radius: 0;
	resize: none;
}

.window.is-minimized .window__content {
	display: none;
}

.window__content {
	padding: 8px;
	flex-grow: 1;
	display: flex;
	flex-direction: column;
	overflow: auto;
	background: transparent;
	min-height: 0; /* <-- AÑADIR ESTA LÍNEA */
}

.window__header {
	height: 32px;
	border-radius: 6px 6px 0 0;
	border-bottom: 1px solid var(--border-color);
	display: flex;
	align-items: center;
	padding: 0 8px;
	cursor: move;
	user-select: none;
	flex-shrink: 0;
	gap: 6px;
}

.window--document.active .window__header {
	background: rgba(0, 0, 0, 0.2);
}

.window__header-controls {
	display: flex;
	margin-left: -4px;
}
.window__actions {
	display: flex;
	gap: 4px;
	margin-left: auto;
}
.window__title {
	flex: 1;
	font-weight: 500;
	font-size: 12px;
	color: var(--text-primary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.window-animation-container {
	width: 100%;
	height: 100%;
	position: relative;
	transform-style: preserve-3d;
	transition: transform 0.7s ease;
	box-sizing: border-box;
}

.window-face {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	background: rgba(20, 20, 20, 0.5);
	backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 6px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	animation: windowAppear 0.25s ease-out;
	transform: translateZ(0);
}

.window--palette .window-face {
	background: rgba(40, 40, 40, 0.7);
}
.active .window-face {
	background: rgba(40, 40, 40, 0.85);
}

.window--document:not(.active) .window__toolbar {
	opacity: 0.5;
}
.window--document:not(.active) .window__toolbar .window__action-button.active {
	background-color: #666;
	border-color: #666;
}

.window-face--front {
	transform: rotateY(0deg) translateZ(0);
	z-index: 2;
}

.window-face--back {
	transform: rotateY(180deg) translateZ(0);
	z-index: 1;
}

.window .window__actions [data-action="toggleFlip"] {
	display: none;
}

.window.window-has-flip .window__actions [data-action="toggleFlip"] {
	display: flex;
}

.window.is-flipped .window-animation-container {
	transform: rotateY(180deg);
}
.window-face--back .window__content {
	padding: 12px;
	overflow: auto;
	flex: 1;
}
.resize-handles-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 99;
}
.resize-handle {
	position: absolute;
	pointer-events: auto;
}
.resize-handle.n {
	top: -5px;
	left: 5px;
	right: 5px;
	height: 10px;
	cursor: n-resize;
}
.resize-handle.s {
	bottom: -5px;
	left: 5px;
	right: 5px;
	height: 10px;
	cursor: s-resize;
}
.resize-handle.e {
	right: -5px;
	top: 5px;
	bottom: 5px;
	width: 10px;
	cursor: e-resize;
}
.resize-handle.w {
	left: -5px;
	top: 5px;
	bottom: 5px;
	width: 10px;
	cursor: w-resize;
}
.resize-handle.ne {
	top: -5px;
	right: -5px;
	width: 12px;
	height: 12px;
	cursor: ne-resize;
}
.resize-handle.nw {
	top: -5px;
	left: -5px;
	width: 12px;
	height: 12px;
	cursor: nw-resize;
}
.resize-handle.se {
	bottom: -5px;
	right: -5px;
	width: 12px;
	height: 12px;
	cursor: se-resize;
}
.resize-handle.sw {
	bottom: -5px;
	left: -5px;
	width: 12px;
	height: 12px;
	cursor: sw-resize;
}

.image-viewer {
	height: 100%;
	background: linear-gradient(
			45deg,
			#1a1a1a 25%,
			transparent 25%,
			transparent 75%,
			#1a1a1a 75%,
			#1a1a1a
		),
		linear-gradient(
			45deg,
			#1a1a1a 25%,
			transparent 25%,
			transparent 75%,
			#1a1a1a 75%,
			#1a1a1a
		);
	background-size: 20px 20px;
	background-position: 0 0, 10px 10px;
	flex-grow: 1;
	overflow: hidden;
	position: relative;
	border-radius: 6px;
	outline: 1px solid rgba(255, 255, 255, 0.1);
	margin: 0 -8px -8px;
	border-radius: 0 0 8px 8px;
}
.image-viewer[data-tool="pan"] {
	cursor: grab;
}
.image-viewer[data-tool="pan"].is-panning {
	cursor: grabbing;
}
.image-viewer[data-tool="zoom"] {
	cursor: zoom-in;
}
.image-viewer[data-tool="zoom"].is-zooming-out {
	cursor: zoom-out;
}
.image-viewer[data-tool="picker"] {
	cursor: crosshair;
}

.image-viewer__splitter {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	width: 2px;
	background: var(--accent);
	cursor: ew-resize;
	transform: translateX(-50%);
	z-index: 10;
}
.image-viewer__splitter:hover {
	background: var(--accent-hover);
	width: 4px;
}

.window__toolbar {
	display: flex;
	gap: 4px;
	padding: 8px 0;
	margin-top: -8px;
	align-items: center;
}
.toolbar-spacer {
	flex-grow: 1;
}
.toolbar-right-group {
	display: flex;
	gap: 4px;
	align-items: center;
}
.header-action-separator {
	width: 1px;
	height: 16px;
	background: var(--border-color);
	margin: 0 4px;
}

#windows-container {
	width: 100%;
	height: 100%;
}
.status-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 4px 12px;
	background: var(--panel-header-bg);
	border-top: 1px solid var(--border-color);
	font-size: 11px;
	color: var(--text-muted);
	flex-shrink: 0;
	height: 24px;
}
#status-processing.processing {
	color: var(--warning);
	animation: pulse 1.5s ease-in-out infinite;
}

body.window-dragging {
	cursor: move !important;
	user-select: none;
	-webkit-user-select: none;
}

@keyframes windowAppear {
	from {
		opacity: 0;
		transform: scale(0.95);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}
@keyframes pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.6;
	}
}
::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}
::-webkit-scrollbar-track {
	background: var(--secondary-bg);
}
::-webkit-scrollbar-thumb {
	background: var(--border-color);
	border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
	background: var(--border-light);
}

.window__header {
	height: 28px;
	font-size: 12px;
}

.window--document .window__header {
	height: 36px;
}
.window--palette .window__header {
	height: 28px;
	background: rgba(20, 20, 20, 0.2);
}
.window--palette .window__title {
	font-size: 11px;
}
.window--palette .window__header-controls {
	gap: 0;
}
.window--palette .window__control-button {
	width: 16px;
	height: 16px;
}

.overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.7);
	backdrop-filter: blur(5px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10000;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}
.overlay__content {
	color: white;
	font-size: 24px;
	font-weight: bold;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
	border: 2px dashed rgba(255, 255, 255, 0.5);
	padding: 40px 60px;
	border-radius: 12px;
}
body.is-dragging-over .overlay {
	opacity: 1;
	pointer-events: all;
}

.window-face {
	box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
	transition: box-shadow 0.3s ease;
}
.window.window--document.active .window-face {
	box-shadow: 0 10px 40px rgba(0, 0, 0, 1);
	border: 1px solid rgba(255, 255, 255, 0.3);
}

.window__action-triconstrast {
	width: 30px !important;
	height: 24px !important;
	padding: 2px 0;
}
.window__action-triconstrast .tricontrast-status-icon {
	width: 100%;
	height: 100%;
}

.window.is-minimized .svg-container,
.window.hidden .svg-container {
	visibility: hidden !important;
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
	clip: rect(1px, 1px, 1px, 1px) !important;
}
.window.is-minimized svg,
.window.hidden svg {
	contain: layout style paint !important;
	content-visibility: visible !important;
}
svg {
	shape-rendering: crispEdges;
	text-rendering: optimizeLegibility;
	forced-color-adjust: none;
}

.window.is-dock-target .window-face--front::after {
	content: "";
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 4px;
	background: #00aaff;
	box-shadow: 0 0 10px #00aaff;
	z-index: 100;
	border-radius: 5px 5px 0 0;
	pointer-events: none;
	animation: pulse-blue 1.5s infinite ease-in-out;
}
.window.is-docking-candidate {
	opacity: 0.5;
	transition: opacity 0.2s ease-in-out;
}
@keyframes pulse-blue {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.7;
	}
}

/* Ocultar el botón de cierre en paletas acopladas que no son la principal */
.window.is-dock-child [data-action="close"],
.window.is-dock-middle [data-action="close"] {
	display: none;
}

.window .window-face {
	border-radius: 6px;
}
.window .window__header {
	border-radius: 6px 6px 0 0;
}
.window.is-dock-parent .window-face {
	border-top-left-radius: 6px;
	border-top-right-radius: 6px;
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
	border-bottom: none;
}
.window.is-dock-child .window-face {
	border-top-left-radius: 0;
	border-top-right-radius: 0;
	border-bottom-left-radius: 6px;
	border-bottom-right-radius: 6px;
}
.window.is-dock-middle .window-face {
	border-radius: 0;
	border-bottom: none;
}
.window.is-dock-middle .window__header,
.window.is-dock-child .window__header {
	border-bottom-color: transparent;
	border-top-left-radius: 0;
	border-top-right-radius: 0;
	background: transparent;
}
.window.is-dock-middle .window__header {
	border-radius: 0;
}

@keyframes highlight-flash {
	from {
		box-shadow: 0 0 20px 3px rgba(0, 150, 255, 0.7);
		border-color: rgba(0, 150, 255, 0.8);
		background-color: #ccc1;
	}
	to {
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
		border-color: rgba(255, 255, 255, 0.2);
	}
}
.window.is-highlighted .window-face {
	animation: highlight-flash 1.1s ease-out;
}

.window.window-has-no-image
	.window-face--front
	.window__actions
	[data-action="toggleFlip"] {
	pointer-events: none;
	opacity: 0.4;
	cursor: not-allowed;
}
.window.window-has-no-image
	.window-face--back
	.window__actions
	[data-action="toggleFlip"] {
	display: none;
}

.text-overlay-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 9;
	pointer-events: none;
	overflow: auto;
	padding: 12px;
	display: none;
	flex-direction: column;
	gap: 2px;
	justify-content: center;
    padding-bottom: 50px;
}

.text-overlay-container.is-blurred-bg .sample-text-line-wrapper {
    backdrop-filter: blur(20px);
}


.image-viewer.is-showing-text-overlay .text-overlay-container {
	display: flex;
}


.sample-text {
	padding: 2px 6px;
	border-radius: 3px;
	white-space: nowrap;
    text-shadow: none;
}

.sample-text-line-wrapper {
    border-radius: 3px;
    width: fit-content;
}



.sample-text-header {
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
    flex-shrink: 0;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    width: fit-content;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.viewer-signature {
	position: absolute;
	bottom: 10px;
	right: 15px;
	z-index: 16;
	pointer-events: none;
	text-align: right;
}
.viewer-signature p {
	margin: 0;
	line-height: 1.3;
}
.viewer-signature .signature__line-1 {
	font-size: 14px;
	font-weight: 400;
	color: #ffffff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.viewer-signature .signature__line-2 {
	font-size: 12px;
	font-weight: 400;
	color: #ffffff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.image-viewer__overlay {
	position: absolute;
	top: 0;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	z-index: 20;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.spinner-container {
	position: absolute;
	top: 0;
	height: 100%;
	z-index: 21;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.spinner {
	width: 40px;
	height: 40px;
	border: 4px solid var(--border-color);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 1s linear infinite;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.image-viewer.is-loading .image-viewer__overlay,
.image-viewer.is-loading .spinner-container {
	opacity: 1;
}

.image-viewer.is-processing .spinner-container {
	opacity: 1;
}

.image-viewer.is-long-process .image-viewer__overlay {
	opacity: 1;
	pointer-events: auto;
}

.image-viewer.is-temp-picker-tricontrast {
	cursor: crosshair;
}

.text-overlay-container.is-inverted-bg .sample-text-line-wrapper {
    width: 100%;
}
.text-overlay-container.is-inverted-bg .sample-text {
    padding: 0;
}
