/**
 * IIFIN — Обязательства /personal-finance/obligations/
 * Мигрировано из Elementor inline-стилей и frontend_personal-finance_obligations.md
 */

/* === Form wrapper — зона #f1ede7 как на assets === */
#obligations-form-wrapper {
	--card-bg: #f1ede7;
	--text: #2a2f45;
	--muted: #6b7280;
	--accent: #24A8A6;
	--accent-hover: #0B7E95;
	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;
}

#obligations-form-wrapper,
#obligations-form-wrapper * {
	box-sizing: border-box;
}

/* === Summary === */
#obligations-summary {
	margin-bottom: 20px;
	text-align: center;
}

#obligations-summary span {
	white-space: nowrap;
}

#obligations-summary p {
	font-size: 18px;
	margin-bottom: 5px;
}

/* Сумма и ₽ не разрывать — защита от переноса */
#obligations-summary #total-obligations,
#obligations-summary #monthly-obligations {
	white-space: nowrap;
}

#obligations-summary p:last-child {
	margin-bottom: 0;
}

/* Сводка контроля: активные / скоро / просрочено */
.obligations-control-summary {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: center;
	margin-top: 12px;
}

.obligation-badge {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 500;
}

.obligation-badge--active {
	background: rgba(36, 168, 166, 0.12);
	color: #0B7E95;
}

.obligation-badge--soon {
	background: rgba(245, 158, 11, 0.18);
	color: #b45309;
}

.obligation-badge--overdue {
	background: rgba(185, 28, 28, 0.12);
	color: #b91c1c;
}

/* Визуальное выделение карточек по статусу */
#obligations-list .obligation-item.obligation-status--soon {
	border-left: 4px solid #f59e0b;
}

#obligations-list .obligation-item.obligation-status--overdue {
	border-left: 4px solid #b91c1c;
}

#obligations-list .obligation-item.obligation-status--repaid {
	border-left: 4px solid #059669;
	opacity: 0.85;
}

/* Бейдж статуса в заголовке карточки */
.obligation-title-row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.obligation-status-badge {
	font-size: 11px;
	font-weight: 600;
	padding: 2px 6px;
	border-radius: 6px;
}

.obligation-status-badge--active {
	background: rgba(36, 168, 166, 0.15);
	color: #0B7E95;
}

.obligation-status-badge--soon_payment {
	background: rgba(245, 158, 11, 0.2);
	color: #b45309;
}

.obligation-status-badge--overdue {
	background: rgba(185, 28, 28, 0.15);
	color: #b91c1c;
}

.obligation-status-badge--repaid {
	background: rgba(5, 150, 105, 0.15);
	color: #059669;
}

.obligation-confirm-row {
	margin-bottom: 12px;
}

.obligation-confirm-payment {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.obligations-subtitle {
	margin: 0 0 18px;
	font-size: 14px;
	color: var(--muted);
	text-align: center;
}

/* === List === */
#obligations-list {
	display: flex;
	flex-direction: column;
	gap: 20px;
	max-width: 980px;
	margin: 0 auto;
	min-width: 0;
}

/* Карточка — #faf8f5 (перебиваем iifin-layered-surfaces и iifin-global) */
#obligations-form-wrapper #obligations-list .obligation-item {
	background: #faf8f5 !important;
}
#obligations-list .obligation-item {
	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);
	overflow: hidden;
	min-width: 0;
}

#obligations-list .obligation-item.is-collapsed .obligation-body {
	display: none;
}

/* Шапка */
#obligations-list .obligation-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	cursor: pointer;
	user-select: none;
	outline: none;
	max-width: 100%;
	min-width: 0;
}

#obligations-list .obligation-main {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

#obligations-list .obligation-icon-wrap {
	width: 46px;
	height: 46px;
	border-radius: 14px;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.4);
	flex: 0 0 auto;
}

#obligations-list .obligation-icon {
	font-size: 24px;
	line-height: 1;
}

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

#obligations-list .obligation-title {
	font-weight: 600;
	font-size: clamp(18px, 1.7vw, 20px);
	max-width: 100%;
	min-width: 0;
	white-space: normal;
	overflow-wrap: anywhere;
	word-break: break-word;
	hyphens: auto;
	line-height: 1.25;
}

#obligations-list .obligation-summary-line {
	font-size: 13px;
	color: var(--muted);
	max-width: 100%;
	min-width: 0;
	white-space: normal;
	overflow-wrap: anywhere;
	word-break: break-word;
}

/* Disclosure / Chevron */
#obligations-list .obligation-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;
}

#obligations-list .obligation-chevron {
	width: 18px;
	height: 18px;
	display: block;
	transition: transform 0.18s ease;
	transform: rotate(0deg);
}

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

/* Тело карточки */
#obligations-list .obligation-body {
	margin-top: 16px;
}

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

#obligations-form-wrapper .obligation-input,
#obligations-list .obligation-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;
}

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

/* Удалить */
#obligations-list .obligation-danger-row {
	margin-top: 14px;
	display: flex;
	justify-content: flex-end;
}

#obligations-list .obligation-delete {
	border: none;
	background: rgba(185, 28, 28, 0.10);
	color: #b91c1c;
	padding: 10px 12px;
	border-radius: 12px;
	cursor: pointer;
	font-weight: 600;
	transition: transform 0.12s ease, background 0.12s ease;
}

#obligations-list .obligation-delete:hover {
	background: rgba(185, 28, 28, 0.14);
	transform: translateY(-1px);
}

/* Кнопки под списком — десктоп: справа, мобильная: по центру друг над другом */
.obligation-buttons {
	margin-top: 24px;
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	justify-content: flex-end;
	max-width: 980px;
	margin-left: auto;
	margin-right: auto;
}

.obligation-buttons .iifin-button {
	background: #24A8A6;
	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;
}

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

#obligations-message {
	display: none;
	color: green;
	margin-top: 15px;
	font-weight: bold;
	flex-basis: 100%;
}

/* === Graph wrapper === */
#obligation-graph-wrapper {
	margin-top: 40px;
	background: #faf8f5;
	padding: 25px;
	border-radius: 10px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#obligation-graph-wrapper h2 {
	margin-bottom: 20px;
	font-size: 24px;
}

#timeline-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 20px;
	font-size: 14px;
	align-items: center;
}

#timeline-legend strong {
	flex-basis: 100%;
}

#timeline-legend div {
	display: flex;
	align-items: center;
}

.legend-swatch {
	display: inline-block;
	width: 16px;
	height: 16px;
	border-radius: 3px;
	margin-right: 5px;
}

.graph-controls {
	margin-bottom: 12px;
}

/* Timeline container — минимальная высота, JS подстраивает под кол-во групп */
#obligation-timeline {
	min-height: 180px;
	height: 300px;
	border: 1px solid #ddd;
	border-radius: 8px;
}

/* Кнопки управления графиком */
.graph-control-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px 14px;
	font-size: 14px;
	font-weight: 600;
	border-radius: 10px;
	border: 1px solid rgba(36, 168, 166, 0.4);
	background: rgba(36, 168, 166, 0.08);
	color: #0B7E95;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}
.graph-control-btn:hover {
	background: rgba(36, 168, 166, 0.14);
	border-color: #24A8A6;
}

.graph-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

/* Desktop controls */
.desktop-only {
	display: inline-flex;
}

.mobile-only {
	display: none;
}

@media (max-width: 768px) {
	.desktop-only {
		display: none;
	}
	.mobile-only {
		display: inline-flex;
	}
	/* Компактные кнопки на мобильной — текст умещается */
	.graph-control-btn--mobile {
		padding: 6px 12px !important;
		font-size: 12px !important;
		min-width: auto !important;
		width: auto !important;
		height: auto !important;
		border-radius: 10px !important;
		line-height: 1.2 !important;
	}
}

@media (max-width: 640px) {
	#obligations-list .obligation-item {
		padding: 16px 14px;
	}
}

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