/* TODO: Refactor using Organic CSS */

:root {
	--primary: #5e2ca5;
	--primary-light: #8c54d0;
	--secondary: #20b2aa;
	--accent: #ff7e5f;
	--light: #f8f9fa;
	--dark: #212529;
	--success: #28a745;
	--info: #17a2b8;
	--gray: #6c757d;
	--light-gray: #e9ecef;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
	background-color: var(--light);
	color: var(--dark);
	line-height: 1.6;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

header {
	background-color: white;
	padding: 1rem 2rem;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.logo {
	display: flex;
	align-items: center;
	font-weight: bold;
	font-size: 1.5rem;
	color: var(--primary);
}

.logo svg {
	margin-right: 0.5rem;
}

main {
	flex: 1;
	padding: 2rem;
	max-width: 1200px;
	margin: 0 auto;
	width: 100%;
}

.app-container {
	background: white;
	border-radius: 12px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
	padding: 2rem;
	display: grid;
	grid-template-columns: 1fr;
	gap: 2rem;
}

@media (min-width: 768px) {
	.app-container {
		grid-template-columns: 350px 1fr;
	}
}

.upload-section,
.preview-section {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

h2 {
	color: var(--primary);
	font-weight: 600;
	font-size: 1.25rem;
	margin-bottom: 0.5rem;
}

.upload-box {
	border: 2px dashed var(--light-gray);
	border-radius: 8px;
	padding: 2rem;
	text-align: center;
	cursor: pointer;
	transition: all 0.3s ease;
	background-color: var(--light);
}

.upload-box:hover {
	border-color: var(--primary-light);
	background-color: rgba(94, 44, 165, 0.05);
}

.upload-box svg {
	color: var(--primary);
	margin-bottom: 1rem;
}

.upload-box p {
	margin: 0.5rem 0;
	color: var(--gray);
}

.upload-box strong {
	color: var(--primary);
}

.slider-container {
	margin-top: 1rem;
}

.slider-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.5rem;
}

.slider-header label {
	font-weight: 500;
}

.slider-input-group {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.slider-wrapper {
	display: flex;
	align-items: center;
	width: 100%;
}

input[type='range'] {
	width: 100%;
	height: 6px;
	background: var(--light-gray);
	border-radius: 5px;
	-webkit-appearance: none;
}

input[type='range']::-webkit-slider-thumb {
	-webkit-appearance: none;
	height: 18px;
	width: 18px;
	border-radius: 50%;
	background: var(--primary);
	cursor: pointer;
	transition: all 0.15s ease-in-out;
}

input[type='range']::-webkit-slider-thumb:hover {
	background: var(--primary-light);
	transform: scale(1.1);
}

input[type='number'] {
	width: 80px;
	padding: 0.5rem;
	border: 1px solid var(--light-gray);
	border-radius: 4px;
	text-align: center;
	font-size: 0.875rem;
}

.compression-option {
	padding: 1rem;
	background-color: var(--light);
	border-radius: 8px;
	margin-bottom: 1rem;
}

.compression-title {
	font-weight: 600;
	margin-bottom: 0.5rem;
}

.output-path {
	width: 100%;
	padding: 0.5rem;
	border: 1px solid var(--light-gray);
	border-radius: 4px;
	margin-bottom: 0.5rem;
}

.btn-small {
	padding: 0.25rem 0.75rem;
	font-size: 0.875rem;
	margin-bottom: 0.5rem;
}

.note {
	font-size: 0.75rem;
	color: var(--gray);
	margin-top: 0.5rem;
}

.radio-group {
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
}

.radio-item {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

button {
	cursor: pointer;
	padding: 0.75rem 1.5rem;
	border: none;
	border-radius: 6px;
	font-weight: 600;
	transition: all 0.2s ease;
}

.btn-primary {
	background-color: var(--primary);
	color: white;
}

.btn-primary:hover {
	background-color: var(--primary-light);
}

.btn-outline {
	background-color: transparent;
	border: 1px solid var(--primary);
	color: var(--primary);
}

.btn-outline:hover {
	background-color: rgba(94, 44, 165, 0.1);
}

.file-list {
	margin-top: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.file-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.5rem;
	background-color: var(--light);
	border-radius: 4px;
	font-size: 0.875rem;
}

.file-item .file-name {
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	padding-right: 1rem;
}

.file-item .file-actions {
	display: flex;
	gap: 0.5rem;
}

.file-actions button {
	padding: 0.25rem 0.5rem;
	font-size: 0.75rem;
	background-color: transparent;
	color: var(--gray);
}

.file-actions button:hover {
	color: var(--primary);
}

.preview-section {
	overflow: hidden;
}

.preview-container {
	overflow-y: auto;
	max-height: 600px;
	border: 1px solid var(--light-gray);
	border-radius: 8px;
	padding: 1rem;
	position: relative;
}

.preview-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 400px;
	color: var(--gray);
	text-align: center;
}

.preview-placeholder svg {
	margin-bottom: 1rem;
	color: var(--light-gray);
}

.preview-image {
	position: relative; /* Crucial for absolute positioning of cut lines */
	display: inline-block; /* Adjust as needed for layout */
	/* Ensure it doesn't overflow its container if previewContainer has fixed dimensions */
	max-width: 100%;
	margin-bottom: 1rem;
}

/* The actual <img> tag inside .preview-image */
.preview-image img {
	display: block; /* Removes extra space below image if .preview-image is inline-block */
	max-width: 100%;
	height: auto; /* Maintains aspect ratio */
	border: 1px solid var(--light-gray); /* Added from a later rule, ensure it's intended */
	border-radius: 4px; /* Added from a later rule, ensure it's intended */
}

/* Consolidated .cut-line base styles */
.cut-line {
	position: absolute;
	left: 0;
	right: 0;
	height: 2px;
	z-index: 10;
	pointer-events: none;
	/* Default background for slice mode */
	background-color: rgba(255, 0, 0, 0.6); /* Red color for slice lines */
}

/* Consolidated .cut-line::after base styles */
.cut-line::after {
	content: attr(data-height); /* This displays the data-height attribute */
	position: absolute;
	right: 10px;
	top: -24px; /* Positions the text to have ~8px space above the line */
	color: white;
	padding: 2px 6px;
	border-radius: 4px;
	font-size: 0.75rem;
	/* Default background for slice mode's data-height */
	background: var(--accent); /* var(--accent) is #ff7e5f */
}

/* Styles for Extract Top Section mode */
.cut-line.extract-line {
	background-color: rgba(0, 0, 255, 0.6); /* Blue color for extract line */
}

.cut-line.extract-line::after {
	background: var(--info); /* var(--info) is #17a2b8 for extract mode's data-height */
}

.action-buttons {
	display: flex;
	gap: 1rem;
	margin-top: 1rem;
}

.footer {
	text-align: center;
	padding: 1.5rem;
	color: var(--gray);
	font-size: 0.875rem;
}

.loading {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(255, 255, 255, 0.8);
	z-index: 100;
	justify-content: center;
	align-items: center;
}

.loading-spinner {
	width: 50px;
	height: 50px;
	border: 5px solid var(--light-gray);
	border-top-color: var(--primary);
	border-radius: 50%;
	animation: spin 1s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.split-preview {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.slice-container {
	position: relative;
	border: 1px solid var(--light-gray);
	border-radius: 4px;
}

.slice-container img {
	max-width: 100%;
}

.slice-height {
	position: absolute;
	top: 10px;
	right: 10px;
	background: rgba(0, 0, 0, 0.6);
	color: white;
	padding: 2px 8px;
	border-radius: 4px;
	font-size: 0.75rem;
}

.export-section {
	margin-top: 1rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.export-section select {
	padding: 0.5rem;
	border: 1px solid var(--light-gray);
	border-radius: 4px;
	background-color: white;
}
