/**
 * IIFIN — Цели /personal-finance/goals/
 * Мигрировано из Elementor inline-стилей и frontend_personal-finance_goals.md
 */

/* Зона #f1ede7 как на assets/obligations */
#goals-form-wrapper {
	--card-bg: #faf8f5;
	--text: #2a2f45;
	--muted: #6b7280;
	--accent: #24A8A6;
	--danger: #ef4444;
	--dangerHover: #dc2626;
	background: #f1ede7;
	padding: 30px;
	border-radius: 16px;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
	margin-bottom: 40px;
	box-sizing: border-box;
}

#goals-list {
	display: flex;
	flex-direction: column;
	gap: 20px;
	max-width: 980px;
	margin: 0 auto;
}

#goals-list .goal-item {
	background: #faf8f5 !important;
	border-radius: 16px;
	padding: 20px 22px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
	color: var(--text);
	position: relative;
	isolation: isolate;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	--goal-calc: 0;
	--goal-actual: 0;
	min-width: 0;
}

#goals-list .goal-item:hover {
	transform: translateY(-1px);
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08), 0 3px 10px rgba(0, 0, 0, 0.05);
}

#goals-list .goal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	cursor: pointer;
	user-select: none;
	padding: 2px;
	border-radius: 14px;
	transition: background 0.15s ease;
}

#goals-list .goal-header:hover {
	background: rgba(255, 255, 255, 0.28);
}

#goals-list .goal-header:focus {
	outline: none;
}

#goals-list .goal-header:focus-visible {
	box-shadow: 0 0 0 2px rgba(36, 168, 166, 0.25);
}

/* Полоса действий между шапкой и сворачиваемым телом — видна в свёрнутой карточке */
#goals-list .goal-header + .goal-status-actions {
	margin-top: 6px;
}

#goals-list .goal-main {
	display: flex;
	align-items: center;
	gap: 14px;
}

#goals-list .goal-icon-wrap {
	width: 46px;
	height: 46px;
	min-width: 46px;
	min-height: 46px;
	border-radius: 14px;
	background: conic-gradient(rgba(255, 145, 77, 0.95) calc(var(--goal-actual) * 1turn), rgba(0, 0, 0, 0.08) 0);
	padding: 3px;
	position: relative;
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
}

#goals-list .goal-icon-wrap::before {
	content: "";
	position: absolute;
	inset: 3px;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.45);
}

#goals-list .goal-icon {
	font-size: 26px;
	line-height: 1;
	position: relative;
	z-index: 1;
}

#goals-list .goal-header-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

#goals-list .goal-title {
	font-weight: 600;
	font-size: clamp(18px, 1.7vw, 20px);
}

#goals-list .goal-summary-line {
	font-size: 13px;
	color: var(--muted);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

#goals-list .goal-compact {
	margin-top: 10px;
	display: grid;
	gap: 10px;
}

#goals-list .goal-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

#goals-list .goal-chip {
	display: inline-flex;
	align-items: center;
	padding: 6px 10px;
	border-radius: 999px;
	font-size: 12.5px;
	line-height: 1;
	background: rgba(255, 255, 255, 0.75);
	border: 1px solid rgba(0, 0, 0, 0.06);
	color: var(--text);
}

#goals-list .goal-chip--plan {
	border-color: rgba(36, 168, 166, 0.25);
	color: #0b7e95;
}

#goals-list .goal-chip--deadline {
	color: #334155;
}

#goals-list .goal-item.is-overdue .goal-chip--status {
	background: rgba(239, 68, 68, 0.10);
	border-color: rgba(239, 68, 68, 0.25);
	color: #b91c1c;
}

#goals-list .goal-item.is-done .goal-chip--status {
	background: rgba(22, 163, 74, 0.10);
	border-color: rgba(22, 163, 74, 0.25);
	color: #166534;
}

#goals-list .goal-mini-progress {
	display: grid;
	gap: 8px;
}

#goals-list .goal-mini-bar {
	height: 10px;
	background: rgba(0, 0, 0, 0.06);
	border-radius: 999px;
	overflow: hidden;
	position: relative;
}

#goals-list .goal-mini-fill {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 0%;
	transition: width 0.35s ease;
}

#goals-list .goal-mini-fill.calc {
	width: calc(var(--goal-calc) * 100%);
	background: rgba(36, 168, 166, 0.9);
}

#goals-list .goal-mini-fill.actual {
	width: calc(var(--goal-actual) * 100%);
	background: rgba(255, 145, 77, 0.95);
}

#goals-list .goal-mini-legend {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

#goals-list .goal-mini-pill {
	display: inline-flex;
	align-items: center;
	padding: 5px 9px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	background: rgba(255, 255, 255, 0.65);
	border: 1px solid rgba(0, 0, 0, 0.06);
	color: var(--muted);
}

#goals-list .goal-mini-pill.calc {
	border-color: rgba(36, 168, 166, 0.22);
	color: #0b7e95;
}

#goals-list .goal-mini-pill.actual {
	border-color: rgba(255, 145, 77, 0.25);
	color: #b45309;
}

#goals-list .goal-disclosure {
	width: 40px;
	height: 40px;
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.9);
	border: 1px solid rgba(36, 168, 166, 0.25);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
	color: var(--accent);
	flex: 0 0 auto;
	align-self: center;
}

#goals-list .goal-chevron {
	width: 22px;
	height: 22px;
	transition: transform 0.18s ease;
}

#goals-list .goal-item.is-open .goal-chevron {
	transform: rotate(180deg);
}

#goals-list .goal-body {
	margin-top: 0;
	overflow: hidden;
	max-height: 0;
	opacity: 0;
	transform: translateY(-6px);
	transition: max-height 0.32s ease, opacity 0.22s ease, transform 0.22s ease, margin-top 0.22s ease;
	min-width: 0;
}

#goals-list .goal-item.is-open .goal-body {
	margin-top: 22px;
	max-height: 2200px;
	opacity: 1;
	transform: translateY(0);
}

/* Достигнутая цель: спокойный «архивный» вид, поля только для просмотра (!important — поверх токенов темы) */
#goals-list .goal-item.goal-item--achieved-readonly {
	background: #f8fafc !important;
	border-color: rgba(15, 23, 42, 0.09) !important;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

#goals-list .goal-item.goal-item--achieved-readonly:hover {
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

#goals-list .goal-item.goal-item--achieved-readonly .goal-summary-line,
#goals-list .goal-item.goal-item--achieved-readonly .goal-chip {
	color: #475569;
}

#goals-list .goal-item.goal-item--achieved-readonly .goal-body input.goal-field--readonly,
#goals-list .goal-item.goal-item--achieved-readonly .goal-body select.goal-field--readonly,
#goals-list .goal-item.goal-item--achieved-readonly .goal-body textarea.goal-field--readonly {
	background: #f1f5f9;
	border-color: rgba(100, 116, 139, 0.22);
	color: #334155;
	cursor: default;
	opacity: 1;
}

#goals-list .goal-item.goal-item--achieved-readonly .goal-body label {
	color: #64748b;
}

#goals-list .goal-item.goal-item--achieved-readonly .goal-progress-title,
#goals-list .goal-item.goal-item--achieved-readonly .goal-forecast,
#goals-list .goal-item.goal-item--achieved-readonly .goal-delta-hint,
#goals-list .goal-item.goal-item--achieved-readonly .goal-actual-hint {
	color: #64748b;
}

#goals-list label {
	display: block;
	font-size: 14px;
	margin: 6px 0 4px;
	color: var(--text);
}

#goals-form-wrapper .goal-input {
	width: 100%;
	max-width: 100%;
	min-width: 0;
	padding: 9px 10px;
	border-radius: 10px;
	border: 1px solid rgba(0, 0, 0, 0.12);
	background: #fff;
	box-sizing: border-box;
	font-size: 14px;
}

#goals-form-wrapper .goal-input[type="date"] {
	-webkit-appearance: none;
	appearance: none;
}

#goals-list .goal-input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 1px rgba(36, 168, 166, 0.2);
}

.goal-delta-hint,
.goal-actual-hint {
	display: block;
	margin-bottom: 10px;
	color: #6b7280;
	font-size: 13px;
}

.goal-actual-hint {
	color: #777;
}

.goal-progress-block {
	margin-top: 10px;
}

.goal-progress-block:last-of-type {
	margin-top: 16px;
}

.goal-progress-title {
	font-weight: 500;
	margin-bottom: 4px;
}

#goals-list .goal-progress-bar {
	height: 12px;
	background: #e5e9f0;
	border-radius: 999px;
	overflow: hidden;
}

#goals-list .goal-progress-fill {
	height: 100%;
	width: 0%;
	background: var(--accent);
	transition: width 0.4s ease;
}

#goals-list .goal-progress-fill.actual {
	background: #FF914D;
}

#goals-list .goal-progress-label {
	font-size: 13px;
	margin-top: 3px;
	color: var(--muted);
}

.goal-forecast {
	margin-top: 10px;
	font-size: 14px;
	color: #555;
}

#goals-list .goal-danger {
	margin-top: 18px;
	padding: 14px;
	border-radius: 14px;
	background: rgba(239, 68, 68, 0.06);
	border: 1px solid rgba(239, 68, 68, 0.18);
}

#goals-list .goal-danger__title {
	font-weight: 700;
	font-size: 14px;
	color: #991b1b;
	margin-bottom: 6px;
}

#goals-list .goal-danger__text {
	font-size: 13px;
	color: rgba(153, 27, 27, 0.85);
	margin-bottom: 10px;
}

#goals-list .goal-delete {
	appearance: none;
	border: none;
	cursor: pointer;
	padding: 10px 12px;
	border-radius: 12px;
	font-weight: 600;
	font-size: 14px;
	background: #ef4444;
	color: #fff;
	box-shadow: 0 10px 24px rgba(239, 68, 68, 0.20), 0 2px 6px rgba(0, 0, 0, 0.08);
	transition: transform 0.15s ease, background 0.15s ease;
}

#goals-list .goal-delete:hover {
	background: #dc2626;
	transform: translateY(-1px);
}

/* Подсказка по дельте — над карточками */
#goals-warning.goals-warning-above {
	margin-bottom: 16px;
	text-align: center;
	max-width: 980px;
	margin-left: auto;
	margin-right: auto;
}

.goal-buttons {
	margin-top: 24px;
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 16px;
	max-width: 980px;
	margin-left: auto;
	margin-right: auto;
}

.goal-buttons .iifin-button {
	background: var(--accent);
	color: #fff;
	padding: 12px 24px;
	border-radius: 12px;
	border: none;
	box-shadow: 0 8px 22px rgba(36, 168, 166, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
	cursor: pointer;
	font-size: 15px;
	font-weight: 500;
	transition: background 0.15s ease, transform 0.15s ease;
}

.goal-buttons .iifin-button:hover {
	background: #0B7E95;
	transform: translateY(-1px);
}

#goals-message {
	display: none;
	margin-top: 10px;
	font-weight: 600;
	flex-basis: 100%;
}

#goals-warning {
	display: none;
	margin-top: 0;
	font-weight: 600;
	font-size: 14px;
	line-height: 1.5;
}

@media (max-width: 768px) {
	#goals-form-wrapper {
		padding: 16px;
	}
	.goal-buttons {
		flex-direction: column;
		align-items: center;
	}
	.goal-buttons .iifin-button,
	#goals-form-wrapper .goal-buttons .iifin-button.iifin-button--with-icon {
		width: 100%;
		max-width: 280px;
		display: flex !important;
		align-items: center !important;
		justify-content: center !important;
		text-align: center !important;
	}
}

@media (max-width: 640px) {
	#goals-list .goal-item {
		padding: 16px 14px;
	}
	#goals-list .goal-header {
		flex-direction: column;
		align-items: flex-start;
	}
	/* Иконка + название в одном ряду, остальное по всей ширине снизу */
	#goals-list .goal-main {
		display: grid;
		grid-template-columns: auto 1fr;
		grid-template-areas: "icon title" "full full";
		gap: 0 12px;
		align-items: start;
	}
	#goals-list .goal-icon-wrap {
		grid-area: icon;
		align-self: start;
	}
	#goals-list .goal-header-text {
		display: contents;
	}
	#goals-list .goal-title-row {
		grid-area: title;
		align-self: start;
		margin: 0;
	}
	#goals-list .goal-summary-line {
		grid-column: 1 / -1;
		margin: 8px 0 0;
	}
	#goals-list .goal-compact {
		grid-column: 1 / -1;
		gap: 8px;
		width: 100%;
		margin-top: 4px;
	}
	#goals-list .goal-chips {
		width: 100%;
	}
	#goals-list .goal-disclosure {
		width: 42px;
		height: 42px;
		align-self: center;
	}
	#goals-list .goal-chip {
		font-size: 12px;
	}
	#goals-list .goal-mini-pill {
		font-size: 11.5px;
	}
}

/* Статусы и подтверждения целей */
#goals-list .goal-title-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	min-width: 0;
}

#goals-list .goal-status-badge {
	font-size: 12px;
	font-weight: 600;
	line-height: 1.2;
	padding: 4px 10px;
	border-radius: 999px;
	background: rgba(36, 168, 166, 0.12);
	color: #0f766e;
	border: 1px solid rgba(36, 168, 166, 0.35);
	white-space: nowrap;
}

#goals-list .goal-status-badge[data-status="behind"] {
	background: rgba(249, 115, 22, 0.12);
	color: #c2410c;
	border-color: rgba(249, 115, 22, 0.4);
}

#goals-list .goal-status-badge[data-status="almost"] {
	background: rgba(234, 179, 8, 0.15);
	color: #a16207;
	border-color: rgba(234, 179, 8, 0.45);
}

#goals-list .goal-status-badge[data-status="achieved"] {
	background: rgba(34, 197, 94, 0.12);
	color: #15803d;
	border-color: rgba(34, 197, 94, 0.4);
}

#goals-list .goal-status-badge[data-status="paused"],
#goals-list .goal-status-badge[data-status="cancelled"] {
	background: rgba(107, 114, 128, 0.12);
	color: #4b5563;
	border-color: rgba(107, 114, 128, 0.35);
}

#goals-list .goal-confirm-banner {
	margin-bottom: 14px;
	padding: 12px 14px;
	border-radius: 12px;
	border: 1px solid rgba(36, 168, 166, 0.35);
	background: rgba(255, 255, 255, 0.85);
	font-size: 14px;
	line-height: 1.45;
}

#goals-list .goal-confirm-banner--deadline {
	border-color: rgba(249, 115, 22, 0.45);
	background: rgba(255, 247, 237, 0.95);
}

#goals-list .goal-confirm-banner--target {
	border-color: rgba(34, 197, 94, 0.4);
	background: rgba(240, 253, 244, 0.95);
}

#goals-list .goal-confirm-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}

/* Полоса действий: чуть больше воздуха и мягче отделение от формы ниже */
#goals-list .goal-status-actions {
	position: relative;
	z-index: 4;
	margin-bottom: 8px;
	padding-bottom: 16px;
	border-bottom: 1px solid rgba(42, 47, 69, 0.07);
}

#goals-list .goal-status-actions__bar {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 8px;
}

#goals-list .goal-btn-assistant {
	flex: 1 1 auto;
	min-width: min(100%, 12rem);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font-weight: 500;
}

#goals-list .goal-btn-assistant .material-symbols-outlined {
	font-size: 18px;
	line-height: 1;
}

#goals-list .goal-btn-assistant__label {
	white-space: nowrap;
}

#goals-list .goal-action-primary {
	flex: 1 1 auto;
	min-width: 0;
	font-weight: 600;
}

/* «Действия» — вторично к основным кнопкам: лёгкий outline / ghost */
#goals-list .goal-action-menu-trigger {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	white-space: nowrap;
	background: transparent !important;
	border: 1px solid rgba(42, 47, 69, 0.14) !important;
	color: var(--muted, #64748b) !important;
	box-shadow: none !important;
	font-weight: 500;
}

#goals-list .goal-action-menu-trigger:hover {
	background: rgba(42, 47, 69, 0.05) !important;
	border-color: rgba(42, 47, 69, 0.2) !important;
	color: var(--text, #3d4459) !important;
}

#goals-list .goal-action-menu-trigger:focus-visible {
	outline: none;
	background: rgba(36, 168, 166, 0.08) !important;
	border-color: rgba(36, 168, 166, 0.35) !important;
	color: var(--text, #2a2f45) !important;
	box-shadow: 0 0 0 2px rgba(36, 168, 166, 0.2) !important;
}

#goals-list .goal-status-actions--open .goal-action-menu-trigger {
	background: rgba(42, 47, 69, 0.06) !important;
	border-color: rgba(42, 47, 69, 0.22) !important;
	color: var(--text, #2a2f45) !important;
}

#goals-list .goal-action-menu-trigger__icon {
	font-size: 20px;
	line-height: 1;
	width: 1em;
	height: 1em;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	opacity: 0.88;
}

#goals-list .goal-action-menu-trigger__label {
	font-size: 13px;
	font-weight: 500;
	color: inherit;
}

#goals-list .iifin-button--compact {
	min-height: 40px;
	padding: 8px 14px;
	font-size: 14px;
	border-radius: 10px;
}

/* [hidden] должен побеждать display:flex — иначе меню всегда развернуто */
#goals-list .goal-actions-panel[hidden] {
	display: none !important;
}

#goals-list .goal-actions-panel {
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 6px);
	z-index: 5;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 8px;
	margin: 0;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 12px;
	box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.06);
	max-height: min(70vh, 320px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

#goals-list .goal-status-actions--open .goal-actions-panel {
	animation: goal-actions-panel-in 0.18s ease-out;
}

@keyframes goal-actions-panel-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

#goals-list .goal-menu-action {
	display: block;
	width: 100%;
	text-align: left;
	padding: 12px 14px;
	margin: 0;
	font-size: 14px;
	line-height: 1.35;
	font-family: inherit;
	font-weight: 500;
	color: var(--text, #1f2937);
	background: transparent;
	border: none;
	border-radius: 10px;
	cursor: pointer;
	transition: background 0.15s ease;
}

#goals-list .goal-menu-action:hover,
#goals-list .goal-menu-action:focus-visible {
	background: rgba(36, 168, 166, 0.08);
	outline: none;
}

#goals-list .goal-menu-action--danger {
	color: #b91c1c;
	font-weight: 600;
}

#goals-list .goal-menu-action--danger:hover,
#goals-list .goal-menu-action--danger:focus-visible {
	background: rgba(185, 28, 28, 0.08);
}

@media (max-width: 600px) {
	#goals-list .goal-status-actions {
		padding-bottom: 18px;
		margin-bottom: 6px;
	}

	#goals-list .goal-item.is-open .goal-body {
		margin-top: 20px;
	}
}

@media (max-width: 380px) {
	#goals-list .goal-action-menu-trigger__label {
		position: absolute;
		width: 1px;
		height: 1px;
		padding: 0;
		margin: -1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border: 0;
	}

	#goals-list .goal-action-menu-trigger {
		min-width: 44px;
		min-height: 44px;
		padding-left: 10px;
		padding-right: 10px;
	}
}
