/**
 * Yüzde Hesaplama Calculator v1.2 — tabs, live calc, layouts
 */

.yhz-widget {
	--yhz-primary: var(--nv-primary-accent, #2563eb);
	--yhz-primary-hover: var(--nv-secondary-accent, #1d4ed8);
	--yhz-text: var(--nv-text-color, #1e293b);
	--yhz-muted: #64748b;
	--yhz-border: #e2e8f0;
	--yhz-bg: #ffffff;
	--yhz-surface: var(--nv-light-bg, #eff6ff);
	--yhz-error-bg: #fef2f2;
	--yhz-error-border: #fecaca;
	--yhz-error-text: #b91c1c;
	--yhz-radius: 14px;
	--yhz-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);

	margin: 0;
	max-width: 100%;
}

.yhz-widget--width-full {
	width: 100%;
	max-width: none;
}

.yhz-widget--width-compact {
	max-width: 420px;
}

.yhz-widget--width-default {
	max-width: 720px;
}

/* Shell */
.yhz-shell {
	background: var(--yhz-bg);
	border: 1px solid var(--yhz-border);
	border-radius: var(--yhz-radius);
	box-shadow: var(--yhz-shadow);
	overflow: hidden;
}

/* Intro */
.yhz-intro {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	padding: 16px 18px;
	margin-bottom: 0;
	background: var(--yhz-surface);
	border: 1px solid color-mix(in srgb, var(--yhz-primary) 18%, var(--yhz-border));
	border-left: 4px solid var(--yhz-primary);
	border-radius: var(--yhz-radius);
	position: relative;
	transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.35s ease, margin 0.35s ease, padding 0.35s ease;
}

.yhz-intro.is-dismissible {
	padding-right: 46px;
}

.yhz-intro.is-closed {
	opacity: 0;
	transform: translateY(-6px);
	max-height: 0;
	margin-bottom: 0;
	padding-top: 0;
	padding-bottom: 0;
	border-width: 0;
	overflow: hidden;
	pointer-events: none;
}

.yhz-intro__icon {
	flex-shrink: 0;
	color: var(--yhz-primary);
	margin-top: 2px;
}

.yhz-intro__title {
	margin: 0 0 8px;
	font-weight: 700;
	font-size: 1rem;
	color: var(--yhz-text);
}

.yhz-intro__steps {
	margin: 0;
	padding-left: 1.15rem;
	color: var(--yhz-muted);
	font-size: 0.925rem;
	line-height: 1.55;
}

.yhz-intro__steps li + li {
	margin-top: 4px;
}

.yhz-intro__close {
	position: absolute;
	top: 10px;
	right: 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--yhz-muted);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.yhz-intro__close:hover,
.yhz-intro__close:focus {
	background: rgba(255, 255, 255, 0.8);
	color: var(--yhz-text);
}

/* Tabs */
.yhz-tabs {
	display: flex;
	gap: 6px;
	padding: 10px 10px 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	background: #f8fafc;
	border-bottom: 1px solid var(--yhz-border);
}

.yhz-tabs::-webkit-scrollbar {
	display: none;
}

.yhz-tabs__btn {
	flex: 1 0 auto;
	min-width: max-content;
	padding: 12px 16px;
	border: 0;
	border-radius: 10px 10px 0 0;
	background: transparent;
	color: var(--yhz-muted);
	font: inherit;
	font-size: 0.9rem;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
	white-space: nowrap;
}

.yhz-tabs__btn:hover,
.yhz-tabs__btn:focus {
	color: var(--yhz-text);
	background: rgba(255, 255, 255, 0.7);
}

.yhz-tabs__btn.is-active {
	color: var(--yhz-primary);
	background: var(--yhz-bg);
	box-shadow: 0 -1px 0 var(--yhz-bg), inset 0 -2px 0 var(--yhz-primary);
}

.yhz-panel {
	padding: 20px;
}

.yhz-panel__head {
	margin-bottom: 18px;
}

.yhz-panel__title {
	margin: 0;
	font-size: 1.15rem;
	color: var(--yhz-text);
}

.yhz-panel__desc {
	margin: 6px 0 0;
	font-size: 0.9rem;
	color: var(--yhz-muted);
	line-height: 1.5;
}

/* Accordion */
.yhz-calculator-group--accordion {
	display: flex;
	flex-direction: column;
}

.yhz-accordion__item {
	border-bottom: 1px solid var(--yhz-border);
}

.yhz-accordion__item:last-child {
	border-bottom: 0;
}

.yhz-accordion__trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 16px 20px;
	border: 0;
	background: #f8fafc;
	color: var(--yhz-text);
	font: inherit;
	font-size: 0.95rem;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
	transition: background 0.15s ease;
}

.yhz-accordion__item.is-open .yhz-accordion__trigger {
	background: var(--yhz-bg);
	color: var(--yhz-primary);
}

.yhz-accordion__chevron {
	width: 10px;
	height: 10px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	transition: transform 0.2s ease;
	margin-left: 12px;
	flex-shrink: 0;
}

.yhz-accordion__item.is-open .yhz-accordion__chevron {
	transform: rotate(-135deg);
}

.yhz-accordion__panel {
	padding: 0 20px 20px;
}

/* Stack */
.yhz-calculator-group--stack {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 16px;
}

.yhz-calculator-group--stack .yhz-calculator {
	border: 1px solid var(--yhz-border);
	border-radius: 12px;
	box-shadow: none;
}

/* Calculator form */
.yhz-calculator {
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.yhz-calculator.is-hidden {
	display: none;
}

.yhz-calculator:focus-within {
	outline: none;
}

.yhz-calculator.is-error {
	border-radius: 12px;
	padding: 12px;
	background: var(--yhz-error-bg);
	border: 1px solid var(--yhz-error-border);
}

.yhz-calculator__header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 10px 12px;
	margin-bottom: 16px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--yhz-border);
}

.yhz-calculator__step {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 999px;
	background: var(--yhz-primary);
	color: #fff;
	font-size: 0.85rem;
	font-weight: 700;
	flex-shrink: 0;
}

.yhz-calculator__heading {
	flex: 1 1 180px;
	min-width: 0;
}

.yhz-calculator__title {
	margin: 0;
	font-size: 1.05rem;
	line-height: 1.3;
	color: var(--yhz-text);
}

.yhz-calculator__desc {
	margin: 4px 0 0;
	font-size: 0.875rem;
	color: var(--yhz-muted);
	line-height: 1.45;
}

.yhz-calculator__body {
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.yhz-calculator__sentence {
	margin: 0;
	color: var(--yhz-text);
	font-size: 1.05rem;
	line-height: 1.85;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.5rem 0.6rem;
}

.yhz-text {
	display: inline;
	padding-bottom: 0.35rem;
}

.yhz-field {
	display: inline-flex;
	flex-direction: column;
	gap: 4px;
	min-width: 6rem;
}

.yhz-field__label {
	font-size: 0.7rem;
	font-weight: 700;
	line-height: 1;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--yhz-muted);
}

.yhz-input {
	appearance: textfield;
	width: 100%;
	min-width: 6rem;
	max-width: 8.5rem;
	padding: 0.62rem 0.75rem;
	border: 1px solid var(--yhz-border);
	border-radius: 10px;
	background: #fff;
	color: var(--yhz-text);
	font: inherit;
	font-size: 1.05rem;
	line-height: 1.4;
	transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.yhz-input::placeholder {
	color: #94a3b8;
	opacity: 1;
}

.yhz-input::-webkit-outer-spin-button,
.yhz-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.yhz-input:focus {
	outline: none;
	border-color: var(--yhz-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--yhz-primary) 18%, transparent);
}

.yhz-input.is-invalid {
	border-color: var(--yhz-error-border);
	background: #fff5f5;
}

/* Result hero */
.yhz-calculator__result-hero {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 16px 18px;
	border-radius: 12px;
	background: linear-gradient(135deg, var(--yhz-surface) 0%, #fff 100%);
	border: 1px solid color-mix(in srgb, var(--yhz-primary) 16%, var(--yhz-border));
}

.yhz-widget--live .yhz-calculator__result-hero.has-value {
	border-color: color-mix(in srgb, var(--yhz-primary) 35%, var(--yhz-border));
}

.yhz-widget--live .yhz-calculator__result-hero.is-updating .yhz-input--result {
	animation: yhzPulse 0.35s ease;
}

@keyframes yhzPulse {
	0% { transform: scale(1); }
	50% { transform: scale(1.02); }
	100% { transform: scale(1); }
}

.yhz-calculator__result-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.yhz-calculator__result-label {
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--yhz-muted);
}

.yhz-calculator__result-tools {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.yhz-btn--tool {
	min-height: 32px;
	padding: 0.3rem 0.65rem;
	font-size: 0.78rem;
	font-weight: 600;
	border-radius: 8px;
	background: #fff;
	color: var(--yhz-primary);
	border: 1px solid color-mix(in srgb, var(--yhz-primary) 22%, var(--yhz-border));
}

.yhz-btn--tool:hover,
.yhz-btn--tool:focus {
	background: color-mix(in srgb, var(--yhz-primary) 10%, #fff);
	border-color: var(--yhz-primary);
	color: var(--yhz-primary-hover);
}

.yhz-btn--tool:disabled,
.yhz-btn--tool[hidden] {
	display: none;
}

.yhz-btn--copy.is-copied {
	background: color-mix(in srgb, var(--yhz-primary) 14%, #fff);
	border-color: var(--yhz-primary);
}

.yhz-calculator__result-wrap {
	display: inline-flex;
	align-items: baseline;
	gap: 0.35rem;
}

.yhz-input--result {
	width: auto;
	min-width: 5rem;
	max-width: 100%;
	padding: 0;
	border: 0;
	background: transparent;
	font-weight: 800;
	font-size: clamp(1.75rem, 5vw, 2.35rem);
	line-height: 1.1;
	color: var(--yhz-primary);
	box-shadow: none;
}

.yhz-input--result:focus {
	box-shadow: none;
}

.yhz-input--result::placeholder {
	color: #cbd5e1;
	font-weight: 600;
}

.yhz-calculator__unit {
	font-weight: 800;
	font-size: clamp(1.25rem, 4vw, 1.75rem);
	color: var(--yhz-primary);
}

.yhz-calculator__live-hint {
	font-size: 0.78rem;
	color: var(--yhz-muted);
}

.yhz-calculator__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.yhz-widget--live .yhz-btn--secondary-action {
	min-height: 38px;
	padding: 0.45rem 1rem;
	font-size: 0.88rem;
	background: #f1f5f9;
	color: var(--yhz-text);
}

.yhz-widget--live .yhz-btn--secondary-action:hover,
.yhz-widget--live .yhz-btn--secondary-action:focus {
	background: #e2e8f0;
}

.yhz-calculator__header .yhz-btn--example {
	display: inline-flex;
}

.yhz-calculator__actions .yhz-btn--example-inline {
	display: none;
}

.yhz-calculator-group--stack .yhz-calculator__header .yhz-btn--example,
.yhz-calculator-group--tabs .yhz-btn--example {
	display: none;
}

.yhz-calculator-group--stack .yhz-calculator__actions .yhz-btn--example-inline,
.yhz-calculator-group--tabs .yhz-calculator__actions .yhz-btn--example-inline,
.yhz-calculator-group--accordion .yhz-calculator__actions .yhz-btn--example-inline {
	display: inline-flex;
}

.yhz-calculator__formula {
	margin: 0;
	padding: 10px 12px;
	font-size: 0.84rem;
	color: var(--yhz-muted);
	background: #f8fafc;
	border-radius: 8px;
	border: 1px dashed var(--yhz-border);
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.yhz-calculator__formula[hidden] {
	display: none;
}

.yhz-calculator__error {
	margin: 12px 0 0;
	font-size: 0.875rem;
	color: var(--yhz-error-text);
}

.yhz-calculator__error[hidden] {
	display: none;
}

.yhz-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0.6rem 1.2rem;
	border: 0;
	border-radius: 10px;
	font: inherit;
	font-weight: 700;
	font-size: 0.95rem;
	line-height: 1.2;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.yhz-btn--primary {
	background: var(--yhz-primary);
	color: #fff;
}

.yhz-btn--primary:hover,
.yhz-btn--primary:focus {
	background: var(--yhz-primary-hover);
}

.yhz-btn--primary:active {
	transform: translateY(1px);
}

.yhz-btn--ghost {
	min-height: 38px;
	padding: 0.45rem 0.85rem;
	background: #fff;
	color: var(--yhz-primary);
	border: 1px solid color-mix(in srgb, var(--yhz-primary) 28%, var(--yhz-border));
	font-size: 0.85rem;
	font-weight: 600;
}

.yhz-btn--ghost:hover,
.yhz-btn--ghost:focus {
	background: color-mix(in srgb, var(--yhz-primary) 10%, #fff);
	border-color: var(--yhz-primary);
	color: var(--yhz-primary-hover);
}

/* Örnek — tema gri hover’ını ez (Neve / WP button reset) */
.yhz-widget .yhz-btn--ghost.yhz-btn--example,
.yhz-widget .yhz-btn--ghost.yhz-btn--example:hover,
.yhz-widget .yhz-btn--ghost.yhz-btn--example:focus {
	background: #fff;
	color: var(--yhz-primary);
	border-color: color-mix(in srgb, var(--yhz-primary) 32%, var(--yhz-border));
}

.yhz-widget .yhz-btn--ghost.yhz-btn--example:hover,
.yhz-widget .yhz-btn--ghost.yhz-btn--example:focus {
	background: color-mix(in srgb, var(--yhz-primary) 12%, #fff);
	border-color: var(--yhz-primary);
	color: var(--yhz-primary-hover);
}

/* Mobile */
@media (max-width: 640px) {
	.yhz-widget--width-default,
	.yhz-widget--width-full {
		max-width: 100%;
		margin-left: 0;
		margin-right: 0;
	}

	.yhz-intro {
		padding: 14px;
	}

	.yhz-tabs {
		position: sticky;
		top: 0;
		z-index: 2;
		padding: 8px 8px 0;
	}

	.yhz-tabs__btn {
		flex: 1 1 0;
		min-width: 0;
		padding: 11px 10px;
		font-size: 0.82rem;
		white-space: normal;
		text-align: center;
		line-height: 1.25;
	}

	.yhz-panel {
		padding: 16px 14px 18px;
	}

	.yhz-calculator__sentence {
		font-size: 1rem;
	}

	.yhz-field {
		flex: 1 1 calc(50% - 0.5rem);
		min-width: calc(50% - 0.5rem);
	}

	.yhz-input {
		max-width: none;
		font-size: 16px;
		min-height: 48px;
	}

	.yhz-calculator__result-hero {
		padding: 14px;
	}

	.yhz-calculator__actions {
		flex-direction: column;
		align-items: stretch;
	}

	.yhz-calculator__actions .yhz-btn {
		width: 100%;
	}

	.yhz-accordion__trigger {
		padding: 14px 16px;
	}

	.yhz-accordion__panel {
		padding: 0 14px 16px;
	}
}

@media (min-width: 900px) {
	.yhz-widget--width-full .yhz-calculator__body {
		display: grid;
		grid-template-columns: 1.2fr 0.8fr;
		grid-template-areas:
			"sentence sentence"
			"result actions";
		gap: 20px;
		align-items: end;
	}

	.yhz-widget--width-full .yhz-calculator__sentence {
		grid-area: sentence;
	}

	.yhz-widget--width-full .yhz-calculator__result-hero {
		grid-area: result;
	}

	.yhz-widget--width-full .yhz-calculator__actions {
		grid-area: actions;
		justify-content: flex-end;
	}

	.yhz-widget--width-full .yhz-calculator__formula {
		grid-column: 1 / -1;
	}
}
