// FlexStock → Analytics locked preview: "See it in Google Sheets" mockup (teaser + modal).
// Pure CSS imitation of a Google Sheet with the FlexStock Analytics sidebar. Local fonts only.

$sd-line: #e1e3e6;
$sd-head: #f8f9fa;
$sd-purple: #7e1fd0; // Darker than --ssgsw-purple so white text passes contrast.
$sd-ink: #202124;
$sd-muted: #5f6368;
$sd-callout-gap: 34px;

.ssgsw-react .ssgsw-sheet-demo {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid $sd-line;
	border-radius: 10px;
	background: #fff;
	color: $sd-ink;
	font: 12px/1.35 Arial, Helvetica, sans-serif;
	text-align: start;

	// ---- Window chrome --------------------------------------------------------------------------

	&__chrome {
		border-bottom: 1px solid $sd-line;
		background: #f9fbfd;
	}

	&__titlebar {
		display: flex;
		align-items: center;
		gap: 10px;
		padding: 8px 12px 4px;
	}

	&__logo {
		flex: none;
		width: 20px;
		height: 26px;
	}

	&__filename {
		display: block;
		font-size: 15px;
	}

	&__menus {
		display: flex;
		flex-wrap: wrap;
		gap: 2px 12px;
		margin-top: 2px;
		color: #444746;

		.is-plugin {
			color: $sd-purple;
			font-weight: 700;
		}
	}

	&__toolbar {
		display: flex;
		align-items: center;
		gap: 6px;
		margin: 4px 10px 6px;
		padding: 7px 12px;
		overflow: hidden;
		border-radius: 20px;
		background: #edf2fa;

		span {
			flex: none;
			height: 10px;
			border-radius: 3px;
			background: #c4c7c5;
		}
	}

	&__formula {
		display: flex;
		align-items: center;
		gap: 10px;
		padding: 4px 12px;
		border-top: 1px solid $sd-line;
		background: #fff;
		color: #444746;

		span:first-child {
			width: 56px;
			border-inline-end: 1px solid $sd-line;
		}
	}

	&__fx {
		color: #80868b;
		font-style: italic;
	}

	// ---- Grid + sidebar -------------------------------------------------------------------------

	&__body {
		position: relative;
		display: flex;
		align-items: stretch;
	}

	&__grid-wrap {
		flex: 1 1 auto;
		min-width: 0;
		overflow: hidden;
		background: #fff;
	}

	&__grid {
		border-collapse: collapse;
		white-space: nowrap;

		th,
		td {
			height: 24px;
			padding: 3px 8px;
			border: 1px solid $sd-line;
			font-weight: 400;
			text-align: start;
		}

		td.is-num {
			text-align: end;
		}

		td.is-instock {
			color: #137333;
			font-weight: 700;
		}
	}

	&__letters th {
		min-width: 56px;
		background: $sd-head;
		color: $sd-muted;
		font-size: 11px;
		text-align: center;
	}

	&__grid &__corner,
	&__grid &__rownum {
		width: 36px;
		min-width: 36px;
		background: $sd-head;
		color: $sd-muted;
		font-size: 11px;
		text-align: center;
	}

	// Frozen header row.
	&__head th:not(.ssgsw-sheet-demo__rownum) {
		border-bottom: 3px solid #bdc1c6;
		background: $sd-purple;
		color: #fff;
		font-weight: 700;
	}

	&__head td,
	&__head th.ssgsw-sheet-demo__rownum {
		border-bottom: 3px solid #bdc1c6;
	}

	&__side {
		position: relative;
		display: flex;
		flex: 0 0 300px;
		flex-direction: column;
		width: 300px;
		border-inline-start: 1px solid $sd-line;
		background: #fff;
		box-shadow: -4px 0 12px rgba(60, 64, 67, 0.08);
	}

	&__side-head {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 8px;
		padding: 10px 12px;
		background: $sd-purple;
		color: #fff;

		strong {
			display: block;
			font-size: 14px;
		}

		span {
			font-size: 11px;
		}
	}

	&__side-body {
		display: flex;
		flex-direction: column;
		gap: 8px;
		padding: 10px 12px 12px;
	}

	&__chips {
		display: flex;
		flex-wrap: wrap;
		gap: 4px;
	}

	&__chip {
		padding: 2px 8px;
		border: 1px solid $sd-line;
		border-radius: 999px;
		color: #444746;
		font-size: 11px;

		&.is-active {
			border-color: #c99bf9;
			background: #f3e8fe;
			color: #5b1597;
			font-weight: 700;
		}
	}

	&__compare {
		position: relative;
		display: flex;
		align-items: center;
		gap: 6px;
	}

	&__check {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 14px;
		height: 14px;
		border-radius: 3px;
		background: $sd-purple;
		color: #fff;
		font-size: 10px;
		line-height: 1;
	}

	&__tabs {
		display: flex;
		justify-content: space-between;
		border-bottom: 1px solid $sd-line;
	}

	&__tab {
		display: inline-flex;
		padding: 6px 4px;
		border-bottom: 2px solid transparent;
		color: $sd-muted;

		&.is-active {
			border-bottom-color: $sd-purple;
			color: $sd-purple;
		}
	}

	&__icon {
		display: block;
		width: 16px;
		height: 16px;
	}

	&__caption {
		margin: 0;
		color: $sd-muted;
		font-size: 11px;
	}

	&__kpis {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 6px;
	}

	&__kpi {
		display: flex;
		flex-direction: column;
		gap: 1px;
		min-width: 0;
		padding: 6px 8px;
		border: 1px solid $sd-line;
		border-radius: 6px;
	}

	&__kpi-label {
		overflow: hidden;
		color: $sd-muted;
		font-size: 10.5px;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	&__kpi-value {
		font-size: 15px;
		font-variant-numeric: tabular-nums;
	}

	&__kpi-meta {
		color: $sd-muted;
		font-size: 10px;
	}

	&__delta {
		font-weight: 700;

		&.is-good {
			color: #137333;
		}

		&.is-bad {
			color: #c5221f;
		}
	}

	&__section {
		position: relative;
		display: flex;
		flex-direction: column;
		gap: 4px;
	}

	&__section-title {
		font-size: 12px;
		font-weight: 700;
	}

	&__spark {
		display: block;
		width: 100%;
		height: 56px;
	}

	&__alert-row {
		display: flex;
		flex-wrap: wrap;
		gap: 6px;

		span {
			padding: 3px 7px;
			border-radius: 6px;
			font-size: 11px;
		}

		.is-bad {
			background: #fce8e6;
			color: #a50e0e;
		}

		.is-warn {
			background: #fef7e0;
			color: #6b4200;
		}
	}

	// ---- Callouts (modal only): label to the left of the sidebar with a dashed pointer -------------

	&__callout {
		position: absolute;
		top: 50%;
		inset-inline-end: calc(100% + #{$sd-callout-gap});
		z-index: 2;
		padding: 6px 10px;
		border-radius: 6px;
		background: #141b38;
		color: #fff;
		font: 600 12px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
		white-space: nowrap;
		box-shadow: 0 4px 14px rgba(20, 27, 56, 0.25);
		transform: translateY(-50%);

		&::after {
			content: '';
			position: absolute;
			top: 50%;
			inset-inline-start: 100%;
			width: $sd-callout-gap;
			border-top: 2px dashed #141b38;
		}
	}

	&__side-body &__callout {
		inset-inline-end: calc(100% + #{$sd-callout-gap} + 12px);

		&::after {
			width: $sd-callout-gap + 12px;
		}
	}

	// ---- Motion ---------------------------------------------------------------------------------

	&.is-animated &__side {
		animation: ssgsw-sd-slide 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
	}

	&.is-animated &__callout {
		animation: ssgsw-sd-fade 0.4s ease-out 0.6s both;
	}
}

body.rtl .ssgsw-react .ssgsw-sheet-demo.is-animated .ssgsw-sheet-demo__side {
	animation-name: ssgsw-sd-slide-rtl;
}

@keyframes ssgsw-sd-slide {
	from {
		opacity: 0;
		transform: translateX(48px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ssgsw-sd-slide-rtl {
	from {
		opacity: 0;
		transform: translateX(-48px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ssgsw-sd-fade {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ssgsw-react .ssgsw-sheet-demo.is-animated .ssgsw-sheet-demo__side,
	.ssgsw-react .ssgsw-sheet-demo.is-animated .ssgsw-sheet-demo__callout {
		animation: none;
	}
}

// ---- Modal --------------------------------------------------------------------------------------

.ssgsw-react .ssgsw-sheet-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(20, 27, 56, 0.55);

	&__dialog {
		display: flex;
		flex-direction: column;
		width: 100%;
		max-width: 1180px;
		max-height: calc(100vh - 48px);
		overflow: hidden;
		border-radius: 12px;
		outline: none;
		background: #fff;
		box-shadow: 0 12px 32px rgba(15, 23, 42, 0.24);
	}

	&__head {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
		gap: 12px;
		padding: 16px 20px;
		border-bottom: 1px solid var(--ssgsw-border);

		> div {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			gap: 6px 12px;
		}
	}

	&__title {
		margin: 0;
		color: var(--ssgsw-text);
		font-size: 17px;
		font-weight: 600;
		line-height: 1.4;
	}

	&__x {
		flex: none;
		padding: 6px;
		border: 0;
		border-radius: 6px;
		background: none;
		color: var(--ssgsw-muted);
		cursor: pointer;

		&:hover {
			background: var(--ssgsw-surface);
			color: var(--ssgsw-text);
		}

		&:focus-visible {
			outline: none;
			box-shadow: var(--ssgsw-focus-ring);
		}

		.ssgsw-sheet-demo__icon {
			width: 18px;
			height: 18px;
		}
	}

	&__body {
		overflow: auto;
		padding: 20px;
		background: #f1f3f4;
	}

	&__foot {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		gap: 18px;
		padding: 12px 20px;
		border-top: 1px solid var(--ssgsw-border);
	}
}

// ---- Narrow screens: modal full width, grid scrolls sideways, sidebar under it, no callouts --------

@media only screen and (max-width: 899px) {
	.ssgsw-react .ssgsw-sheet-modal {
		padding: 0;

		&__dialog {
			max-width: none;
			height: 100%;
			max-height: none;
			border-radius: 0;
		}

		&__body {
			flex: 1 1 auto;
			padding: 12px;
		}

		&__foot {
			flex-wrap: wrap;
			padding: 12px;

			.ssgsw-analytics-btn {
				flex: 1 1 100%;
				justify-content: center;
				text-align: center;
			}
		}

		.ssgsw-sheet-demo__menus {
			display: none;
		}

		.ssgsw-sheet-demo__body {
			flex-direction: column;
		}

		.ssgsw-sheet-demo__grid-wrap {
			overflow-x: auto;
		}

		.ssgsw-sheet-demo__side {
			flex: none;
			width: auto;
			border-top: 1px solid $sd-line;
			border-inline-start: 0;
			box-shadow: none;
		}

		.ssgsw-sheet-demo__callout {
			display: none;
		}
	}
}
