/**
 * Dresium Crop Modal Styles
 *
 * Standalone modal for photo cropping - mobile friendly
 *
 * @package Dresium
 * @version 2.1.0
 */

/* ========================================
   CROP MODAL - STANDALONE DIALOG
   ======================================== */

/* RG-WEBDEV 2025-01-18: Standalone crop modal as native <dialog> */
#dresium-crop-modal {
	padding: 0;
	border: none;
	border-radius: 12px;
	background: #ffffff;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	max-width: 800px;
	width: 95%;
	max-height: 90vh;
	overflow: hidden;
	/* Hidden by default - only show when [open] */
	display: none;
}

/* Show dialog when open */
#dresium-crop-modal[open] {
	display: flex;
	flex-direction: column;
}

#dresium-crop-modal::backdrop {
	background-color: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(4px);
}

/* Header styling */
#dresium-crop-modal .dresium-modal__header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	padding: 25px;
	border-bottom: none;
	background: #ffffff;
	flex-shrink: 0;
}

#dresium-crop-modal .dresium-modal__header-content {
	flex: 1;
}

#dresium-crop-modal .dresium-modal__title {
	font-size: 28px;
	font-weight: 700;
	color: #212529;
	margin: 0;
	letter-spacing: -0.5px;
	border-bottom: 1px solid #f4f5f9;
	padding-bottom: 6px;
	margin-bottom: 6px;
}

#dresium-crop-modal .dresium-modal__subtitle {
	font-size: 15px;
	color: #7A7A7A;
	margin: 6px 0 0 0;
	padding-top: 6px;
	line-height: 1.6;
}

#dresium-crop-modal .dresium-modal__close {
	background: none;
	border: none;
	cursor: pointer;
	padding: 8px;
	margin: -8px -8px 0 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Body styling */
#dresium-crop-modal .dresium-modal__body {
	flex: 1;
	padding: 0 25px 25px 25px;
	overflow: auto;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	min-height: 0;
}

/* Footer styling */
#dresium-crop-modal .dresium-modal__footer {
	display: flex;
	padding: 16px 25px;
	background-color: #ffffff;
	border-top: 1px solid #f4f5f9;
	gap: 12px;
	flex-shrink: 0;
}

#dresium-crop-modal .dresium-modal__footer .dresium-btn {
	flex: 1;
	width: 50%;
}

#dresium-crop-modal .dresium-modal__footer .dresium-btn--reset {
	background: #f4f5f9 !important;
	color: #000000 !important;
	font-weight: 500 !important;
	border: none !important;
	border-radius: 8px !important;
	padding: 16px !important;
	font-size: 14px !important;
	cursor: pointer !important;
	transition: all 0.2s ease !important;
}

#dresium-crop-modal .dresium-modal__footer .dresium-btn--reset:hover {
	background: #e8e9ed !important;
}

/* ========================================
   CROP OVERLAY STRUCTURE
   ======================================== */

/* RG-WEBDEV 2025-01-18: Uniformed crop overlay header to match upload modal style */
.dresium-crop-overlay__header {
	position: relative;
	padding: 25px;
	border-bottom: none;
	background: #ffffff;
	flex-shrink: 0;
}

.dresium-crop-overlay__header h3 {
	font-size: 28px;
	font-weight: 700;
	color: #212529;
	margin: 0;
	letter-spacing: -0.5px;
	border-bottom: 1px solid #f4f5f9;
	padding-bottom: 6px;
	margin-bottom: 6px;
}

.dresium-crop-overlay__header p {
	font-size: 15px;
	color: #7A7A7A;
	margin: 6px 0 0 0;
	padding-top: 6px;
	line-height: 1.6;
}

/* RG-WEBDEV 2025-01-18: Uniformed crop overlay body to match upload modal style */
.dresium-crop-overlay__body {
	flex: 1;
	padding: 0 25px 25px 25px;
	overflow: auto; /* Allow scrolling if content is too tall */
	display: flex;
	flex-direction: column;
	gap: 1rem;
	min-height: 0; /* Allow flex item to shrink below content size */
}

/* RG-WEBDEV 2025-01-18: Uniformed crop overlay footer to match upload modal style */
.dresium-crop-overlay__footer {
	display: flex;
	padding: 16px 25px;
	background-color: #ffffff;
	border-top: 1px solid #f4f5f9;
	gap: 12px;
	flex-shrink: 0;
}

/* RG-WEBDEV 2025-01-18: Footer buttons - 50% width each, same as upload modal */
.dresium-crop-overlay__footer .dresium-btn {
	flex: 1;
	width: 50%;
}

/* RG-WEBDEV 2025-01-18: Reset button style for crop overlay - same as upload modal */
.dresium-crop-overlay__footer .dresium-btn--reset {
	background: #f4f5f9 !important;
	color: #000000 !important;
	font-weight: 500 !important;
	border: none !important;
	border-radius: 8px !important;
	padding: 16px !important;
	font-size: 14px !important;
	cursor: pointer !important;
	transition: all 0.2s ease !important;
	justify-content: center !important;
}

.dresium-crop-overlay__footer .dresium-btn--reset:hover {
	background: #e8e9ed !important;
}

/* RG-WEBDEV 2025-01-18: Loading state for crop save button */
.dresium-crop-overlay__footer .dresium-btn--loading,
#dresium-main-modal .dresium-crop-overlay__footer .dresium-btn--loading,
#dresium-upload-modal .dresium-crop-overlay__footer .dresium-btn--loading {
	position: relative !important;
	pointer-events: none !important;
}

/* Hide text when loading */
.dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__text,
#dresium-main-modal .dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__text,
#dresium-upload-modal .dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__text {
	display: none !important;
}

/* Disable the generic ::after spinner */
.dresium-crop-overlay__footer .dresium-btn--loading::after,
#dresium-main-modal .dresium-crop-overlay__footer .dresium-btn--loading::after,
#dresium-upload-modal .dresium-crop-overlay__footer .dresium-btn--loading::after {
	display: none !important;
	content: none !important;
}

/* Spinner container */
.dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__spinner,
#dresium-main-modal .dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__spinner,
#dresium-upload-modal .dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__spinner {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 20px !important;
	height: 20px !important;
	border: none !important;
	background: transparent !important;
	animation: none !important;
}

/* The actual spinner circle via ::before pseudo-element */
.dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__spinner::before,
#dresium-main-modal .dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__spinner::before,
#dresium-upload-modal .dresium-crop-overlay__footer .dresium-btn--loading .dresium-btn__spinner::before {
	content: "" !important;
	display: inline-block !important;
	width: 20px !important;
	height: 20px !important;
	border: 2px solid rgba(255, 255, 255, 0.3) !important;
	border-top-color: #ffffff !important;
	border-radius: 50% !important;
	animation: dresium-spin 0.8s linear infinite !important;
	position: absolute !important;
	top: 50% !important;
	left: 50% !important;
}

/* ========================================
   CROP MODAL - LARGE SIZE
   ======================================== */

.dresium-modal--large .dresium-modal__dialog {
	max-width: 95%;
	width: 900px;
}

@media (min-width: 768px) {
	.dresium-modal--large .dresium-modal__dialog {
		max-width: 90%;
	}
}

/* ========================================
   CROP CONTAINER
   ======================================== */

/* RG-WEBDEV 2025-01-18: Reduced height for desktop since zoom is available */
.dresium-crop-container {
	width: 100%;
	height: 45vh;
	min-height: 280px;
	max-height: 450px;
	background: #f5f5f5;
	border-radius: 8px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	/* Touch-friendly on mobile */
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}

@media (min-width: 768px) {
	.dresium-crop-container {
		height: 50vh;
		max-height: 500px;
	}
}

.dresium-crop-container img {
	max-width: 100%;
	max-height: 100%; /* Fill container height */
	display: block;
}

/* ========================================
   CROP CONTROLS
   ======================================== */

.dresium-crop-controls {
	display: flex !important;
	flex-direction: row !important; /* RG-WEBDEV 2025-01-18: Ensure horizontal layout */
	align-items: center !important;
	gap: 0.5rem !important;
	justify-content: center !important;
	flex-wrap: wrap !important;
	padding: 0.5rem 0 !important;
	width: 100%;
}

@media (min-width: 768px) {
	.dresium-crop-controls {
		gap: 0.75rem;
	}
}

.dresium-crop-control {
	width: 40px;
	height: 40px;
	min-width: 40px;
	min-height: 40px;
	padding: 0;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	background: var(--dresium-white, #ffffff);
	border: 1px solid var(--dresium-gray-200, #e5e7eb);
	border-radius: var(--dresium-radius-md, 8px);
	color: var(--dresium-gray-700, #374151);
	cursor: pointer;
	transition: all 0.15s ease;
	/* Prevent double-tap zoom on mobile */
	touch-action: manipulation;
}

.dresium-crop-control:hover {
	background: #4362db;
	border-color: #4362db;
	color: #ffffff;
}

.dresium-crop-control svg {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}

@media (min-width: 768px) {
	.dresium-crop-control {
		width: 44px;
		height: 44px;
		min-width: 44px;
		min-height: 44px;
	}

	.dresium-crop-control svg {
		width: 22px;
		height: 22px;
	}
}

.dresium-crop-control:active {
	transform: scale(0.95);
}

/* ========================================
   BUTTON SPINNER
   ======================================== */

.dresium-btn__spinner {
	display: inline-block;
	animation: dresium-spin 1s linear infinite;
}

/* RG-WEBDEV: Animation defined in dresium-base.css to avoid duplication */

/* ========================================
   CROPPER.JS OVERRIDES FOR MOBILE
   ======================================== */

/* Make crop box handles larger on mobile */
.cropper-point {
	width: 12px;
	height: 12px;
}

@media (max-width: 767px) {
	.cropper-point {
		width: 20px;
		height: 20px;
	}
}

/* Touch-friendly crop box */
.cropper-crop-box {
	touch-action: none;
}

/* Better visibility for crop lines on mobile */
@media (max-width: 767px) {
	.cropper-line {
		background-color: rgba(255, 255, 255, 0.4);
	}

	.cropper-view-box {
		outline: 2px solid rgba(255, 255, 255, 0.8);
	}
}

/* ========================================
   MODAL ADJUSTMENTS FOR MOBILE
   ======================================== */

@media (max-width: 767px) {

	#dresium-crop-overlay.dresium-crop-overlay.dresium-crop-overlay--visible {
		position: unset;
	}

	#dresium-crop-overlay.dresium-crop-overlay.dresium-crop-overlay--visible ~ div {
		display: none !important;
	}

	.dresium-crop-overlay__body {
		flex: unset;
	}

	/* RG-WEBDEV 2025-01-18: Reduce crop container height to fit everything without scroll */
	.dresium-crop-container {
		height: 35vh !important;
		min-height: 150px !important;
		max-height: 220px !important;
	}

	/* RG-WEBDEV 2025-01-18: Compact header on mobile */
	.dresium-crop-overlay__header {
		padding: 12px 16px !important;
	}

	.dresium-crop-overlay__header h3 {
		font-size: 18px !important;
		margin-bottom: 2px !important;
		padding-bottom: 2px !important;
	}

	.dresium-crop-overlay__header p {
		font-size: 12px !important;
		margin-top: 2px !important;
	}

	/* RG-WEBDEV 2025-01-18: Compact body on mobile */
	.dresium-crop-overlay__body {
		padding: 0 16px 12px 16px !important;
		gap: 8px !important;
	}

	/* RG-WEBDEV 2025-01-18: Crop controls in 2 rows (4+3), evenly distributed */
	.dresium-crop-controls {
		display: grid !important;
		grid-template-columns: repeat(4, 1fr) !important;
		gap: 6px !important;
		padding: 8px 0 !important;
		justify-items: center !important;
	}

	.dresium-crop-control {
		display: inline-flex !important;
		width: 36px !important;
		height: 36px !important;
		min-width: 36px !important;
		min-height: 36px !important;
	}

	.dresium-crop-control svg {
		width: 16px !important;
		height: 16px !important;
	}

	/* RG-WEBDEV 2025-01-18: Footer buttons - reversed order, full width */
	.dresium-crop-overlay__footer {
		flex-direction: column-reverse !important;
		padding: 12px 16px !important;
		gap: 8px !important;
	}

	.dresium-crop-overlay__footer .dresium-btn {
		width: 100% !important;
	}

	.dresium-modal--large .dresium-modal__dialog {
		margin: 0;
		max-height: 100vh;
		border-radius: 0;
	}

	.dresium-modal__body {
		max-height: calc(100vh - 140px);
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.dresium-modal__footer {
		position: sticky;
		bottom: 0;
		background: white;
		border-top: 1px solid #e5e5e5;
	}
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus states */
.dresium-crop-control:focus {
	outline: 2px solid #4C6EF5;
	outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
	.cropper-view-box {
		outline: 3px solid currentColor;
	}

	.cropper-line {
		background-color: currentColor;
	}
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
	.dresium-btn__spinner {
		animation: none;
	}

	.dresium-crop-control:active {
		transform: none;
	}
}
