/**
 * Camera-Only Image Upload — frontend styles.
 *
 * Styles the capture button, live preview stage (<video>/<canvas>),
 * captured thumbnail, secondary actions, and status/error messages used by
 * the form injection in includes/camera-upload.php and assets/js/camera-capture.js.
 *
 * Arabic / RTL site: spacing uses logical properties (inline/block) so the
 * layout mirrors correctly. Mobile-first, consistent with the theme palette
 * (slate primary, gold accent) and whatsapp.css aesthetic (rounded, simple).
 *
 * Requirements: 1.2 (single "capture" button as the only way to add an image), 9 (error handling / messages).
 */

.ph-camera-field {
	--ph-cam-primary: #1e293b;
	--ph-cam-primary-hover: #334155;
	--ph-cam-accent: #cc8e35;
	--ph-cam-success: #16a34a;
	--ph-cam-error: #dc2626;
	--ph-cam-border: #e5e7eb;
	--ph-cam-muted: #6b7280;
	--ph-cam-radius: 12px;

	display: block;
	margin-block: 16px;
	font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	text-align: start;
}

/* ---------------------------------------------------------------------------
 * Primary capture button
 * ------------------------------------------------------------------------- */
.ph-camera-capture-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	max-width: 420px;
	min-height: 56px;
	padding: 14px 22px;
	border: 0;
	border-radius: var(--ph-cam-radius);
	background: linear-gradient(135deg, var(--ph-cam-primary) 0%, var(--ph-cam-primary-hover) 100%);
	color: #fff;
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(30, 41, 59, 0.25);
	transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.ph-camera-capture-btn .ph-camera-icon {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
}

.ph-camera-capture-btn .ph-camera-icon svg {
	width: 100%;
	height: 100%;
	fill: currentColor;
}

.ph-camera-capture-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 26px rgba(30, 41, 59, 0.32);
}

.ph-camera-capture-btn:active {
	transform: translateY(0);
	box-shadow: 0 4px 12px rgba(30, 41, 59, 0.28);
}

.ph-camera-capture-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(204, 142, 53, 0.45);
}

.ph-camera-capture-btn:disabled,
.ph-camera-capture-btn[disabled],
.ph-camera-capture-btn.is-disabled {
	cursor: not-allowed;
	opacity: 0.55;
	transform: none;
	box-shadow: none;
}

/* ---------------------------------------------------------------------------
 * Live preview stage (holds <video> while streaming and <canvas> on capture)
 * ------------------------------------------------------------------------- */
.ph-camera-stage {
	position: relative;
	width: 100%;
	max-width: 480px;
	margin-block: 14px;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: var(--ph-cam-radius);
	background: #0f172a;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

.ph-camera-stage video,
.ph-camera-stage canvas {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Fallback for browsers without aspect-ratio support */
@supports not (aspect-ratio: 4 / 3) {
	.ph-camera-stage video,
	.ph-camera-stage canvas {
		height: auto;
	}
}

/* ---------------------------------------------------------------------------
 * Captured thumbnail preview
 * ------------------------------------------------------------------------- */
.ph-camera-preview {
	width: 100%;
	max-width: 480px;
	margin-block: 14px;
}

.ph-camera-preview img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--ph-cam-radius);
	border: 1px solid var(--ph-cam-border);
	background: #f5f4f1;
}

/* ---------------------------------------------------------------------------
 * Secondary actions: shoot (take the shot) + retake
 * ------------------------------------------------------------------------- */
.ph-camera-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-block: 12px;
}

/* When the actions bar sits over the live camera / captured preview it lives
 * INSIDE the fixed-ratio, overflow-hidden stage. Overlay it at the bottom (as
 * an absolute layer above the video) so the "shoot"/"retake" button is always
 * visible and tappable instead of being clipped below the video. */
.ph-camera-stage .ph-camera-actions {
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	z-index: 2;
	margin: 0;
	padding: 12px;
	justify-content: center;
	background: linear-gradient(to top, rgba(15, 23, 42, 0.65), rgba(15, 23, 42, 0));
}

.ph-camera-shoot-btn,
.ph-camera-retake-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 48px;
	padding: 12px 20px;
	border-radius: var(--ph-cam-radius);
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	cursor: pointer;
	transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.ph-camera-shoot-btn {
	border: 0;
	background: var(--ph-cam-accent);
	color: #fff;
	box-shadow: 0 6px 16px rgba(204, 142, 53, 0.3);
}

.ph-camera-shoot-btn:hover {
	transform: translateY(-2px);
	background: #b87a2e;
}

.ph-camera-shoot-btn:active {
	transform: translateY(0);
}

.ph-camera-retake-btn {
	border: 1px solid var(--ph-cam-border);
	background: #fff;
	color: var(--ph-cam-primary);
}

.ph-camera-retake-btn:hover {
	background: #f5f4f1;
	border-color: #d1d5db;
}

.ph-camera-shoot-btn:focus-visible,
.ph-camera-retake-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(204, 142, 53, 0.4);
}

.ph-camera-shoot-btn:disabled,
.ph-camera-retake-btn:disabled,
.ph-camera-shoot-btn[disabled],
.ph-camera-retake-btn[disabled] {
	cursor: not-allowed;
	opacity: 0.55;
	transform: none;
}

/* ---------------------------------------------------------------------------
 * Status / info / error / success messages
 * ------------------------------------------------------------------------- */
.ph-camera-message {
	margin-block: 12px;
	padding: 12px 14px;
	border-radius: var(--ph-cam-radius);
	border: 1px solid var(--ph-cam-border);
	background: #f5f4f1;
	color: #334155;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.6;
	text-align: start;
}

.ph-camera-message--error {
	border-color: rgba(220, 38, 38, 0.35);
	background: #fef2f2;
	color: var(--ph-cam-error);
}

.ph-camera-message--success {
	border-color: rgba(22, 163, 74, 0.35);
	background: #f0fdf4;
	color: var(--ph-cam-success);
}

/* ---------------------------------------------------------------------------
 * Helper toggled by JS
 * ------------------------------------------------------------------------- */
.ph-camera-hidden {
	display: none !important;
}

/* Visually-hidden native file input that STAYS clickable.
 * Must NOT use display:none — iOS Safari won't open the camera when a
 * display:none file input is triggered via .click(). */
.ph-camera-file-input {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	border: 0 !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
	opacity: 0 !important;
}

/* ---------------------------------------------------------------------------
 * Mobile tweaks
 * ------------------------------------------------------------------------- */
@media (max-width: 600px) {
	.ph-camera-capture-btn {
		max-width: none;
		font-size: 15px;
	}

	.ph-camera-actions {
		flex-direction: column;
	}

	.ph-camera-shoot-btn,
	.ph-camera-retake-btn {
		width: 100%;
	}
}

/* ---------------------------------------------------------------------------
 * Notice / hint box above the capture button (add-listing form)
 * ------------------------------------------------------------------------- */
.ph-camera-notice {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin-block: 12px;
	padding: 14px 16px;
	border: 1px solid rgba(204, 142, 53, 0.35);
	border-inline-start: 4px solid #cc8e35;
	border-radius: var(--ph-cam-radius, 12px);
	background: #fffaf2;
	text-align: start;
}

.ph-camera-notice__icon {
	font-size: 22px;
	line-height: 1.2;
	flex: 0 0 auto;
}

.ph-camera-notice__text strong {
	display: block;
	margin-bottom: 4px;
	color: #1e293b;
	font-size: 15px;
	font-weight: 700;
}

.ph-camera-notice__text p {
	margin: 0;
	color: #64748b;
	font-size: 13.5px;
	line-height: 1.7;
}

/* ---------------------------------------------------------------------------
 * Trust badge shown on the published single listing
 * ------------------------------------------------------------------------- */
.ph-camera-trust-badge {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 18px;
	padding: 12px 16px;
	border-radius: 12px;
	background: #f0fdf4;
	border: 1px solid rgba(22, 163, 74, 0.35);
	color: #166534;
	font-size: 14px;
	line-height: 1.6;
	text-align: start;
	direction: rtl;
}

.ph-camera-trust-badge__icon {
	display: inline-flex;
	flex: 0 0 auto;
	color: #16a34a;
}

.ph-camera-trust-badge__text strong {
	font-weight: 700;
}
