/**
 * Ameliya — стили виджета записи на фронтенде.
 * Mobile-first: базовые стили для смартфонов, затем медиа-запросы для планшетов и десктопа.
 */

/* ───────── Контейнер ───────── */
.ameliya-booking {
	--am-primary: #2563eb;
	--am-primary-hover: #1d4ed8;
	--am-accent: #7c3aed;
	--am-bg: #ffffff;
	--am-bg-soft: #f8fafc;
	--am-border: #e2e8f0;
	--am-text: #0f172a;
	--am-text-muted: #64748b;
	--am-success: #16a34a;
	--am-danger: #dc2626;
	--am-warning: #d97706;
	--am-radius: 12px;
	--am-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--am-text);
	background: var(--am-bg);
	border-radius: var(--am-radius);
	box-shadow: var(--am-shadow);
	overflow: hidden;
	max-width: 720px;
	margin: 0 auto;
	line-height: 1.5;
	font-size: 15px;
}

.ameliya-booking * {
	box-sizing: border-box;
}

.ameliya-empty {
	padding: 24px;
	text-align: center;
	background: #fef2f2;
	color: #991b1b;
	border-radius: var(--am-radius);
	margin: 16px 0;
}

/* ───────── Заголовок ───────── */
.ameliya-header {
	background: linear-gradient(135deg, var(--am-primary), var(--am-accent));
	color: #fff;
	padding: 20px 16px;
	text-align: center;
}

.ameliya-header h3 {
	margin: 0 0 4px;
	font-size: 18px;
	font-weight: 700;
}

.ameliya-header .ameliya-price {
	display: inline-block;
	background: rgba(255, 255, 255, 0.18);
	padding: 4px 12px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	margin-top: 6px;
}

/* ───────── Селектор специалиста ───────── */
.ameliya-specialist-selector {
	padding: 12px 16px;
	background: var(--am-bg-soft);
	border-bottom: 1px solid var(--am-border);
}

.ameliya-specialist-selector label {
	display: block;
	font-size: 13px;
	color: var(--am-text-muted);
	margin-bottom: 4px;
	font-weight: 500;
}

.ameliya-specialist-selector select {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--am-border);
	border-radius: 8px;
	background: #fff;
	font-size: 15px;
	color: var(--am-text);
	cursor: pointer;
	appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 36px;
}

/* ───────── Тело виджета ───────── */
.ameliya-body {
	padding: 16px;
}

/* ───────── Календарь ───────── */
.ameliya-calendar {
	margin-bottom: 16px;
}

.ameliya-cal-nav {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 12px;
}

.ameliya-cal-nav button {
	background: var(--am-bg-soft);
	border: 1px solid var(--am-border);
	border-radius: 8px;
	padding: 8px 12px;
	cursor: pointer;
	font-size: 16px;
	color: var(--am-text);
	font-weight: 600;
	transition: background 0.15s ease;
	min-width: 40px;
}

.ameliya-cal-nav button:hover:not(:disabled) {
	background: var(--am-border);
}

.ameliya-cal-nav button:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.ameliya-cal-title {
	font-weight: 600;
	font-size: 16px;
	text-align: center;
	flex: 1;
}

.ameliya-cal-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 4px;
}

.ameliya-cal-weekday {
	text-align: center;
	font-size: 11px;
	color: var(--am-text-muted);
	font-weight: 600;
	padding: 6px 0;
	text-transform: uppercase;
}

.ameliya-cal-day {
	aspect-ratio: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--am-border);
	background: #fff;
	border-radius: 8px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	transition: all 0.15s ease;
	min-height: 36px;
}

.ameliya-cal-day:hover:not(.is-disabled):not(.is-selected) {
	border-color: var(--am-primary);
	background: var(--am-bg-soft);
}

.ameliya-cal-day.is-disabled {
	color: #cbd5e1;
	background: var(--am-bg-soft);
	cursor: not-allowed;
}

.ameliya-cal-day.is-empty {
	border: none;
	background: transparent;
	cursor: default;
}

.ameliya-cal-day.is-other-month {
	color: #cbd5e1;
	background: transparent;
}

.ameliya-cal-day.is-today {
	border-color: var(--am-accent);
	font-weight: 700;
}

.ameliya-cal-day.is-selected {
	background: var(--am-primary);
	color: #fff;
	border-color: var(--am-primary);
	font-weight: 700;
}

.ameliya-cal-day .ameliya-cal-availability {
	display: none;
}

/* ───────── Список слотов ───────── */
.ameliya-slots {
	margin-top: 16px;
}

.ameliya-slots-title {
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 8px;
	color: var(--am-text-muted);
}

.ameliya-slots-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 8px;
	max-height: 280px;
	overflow-y: auto;
	padding: 4px;
	border: 1px solid var(--am-border);
	border-radius: 8px;
	background: var(--am-bg-soft);
}

.ameliya-slot {
	background: #fff;
	border: 1px solid var(--am-border);
	border-radius: 8px;
	padding: 10px 6px;
	text-align: center;
	cursor: pointer;
	transition: all 0.15s ease;
	font-size: 14px;
	font-weight: 600;
}

.ameliya-slot:hover:not(.is-disabled):not(.is-selected) {
	border-color: var(--am-primary);
	background: #eff6ff;
	transform: translateY(-1px);
}

.ameliya-slot.is-selected {
	background: var(--am-primary);
	color: #fff;
	border-color: var(--am-primary);
}

.ameliya-slot.is-disabled {
	color: #cbd5e1;
	background: #f8fafc;
	cursor: not-allowed;
	opacity: 0.6;
}

.ameliya-slot .ameliya-slot-time {
	display: block;
	font-size: 15px;
}

.ameliya-slot .ameliya-slot-free {
	display: block;
	font-size: 11px;
	font-weight: 500;
	color: var(--am-text-muted);
	margin-top: 2px;
}

.ameliya-slot.is-selected .ameliya-slot-free {
	color: rgba(255, 255, 255, 0.85);
}

.ameliya-slots-empty {
	text-align: center;
	padding: 24px 16px;
	color: var(--am-text-muted);
	font-size: 14px;
	background: var(--am-bg-soft);
	border-radius: 8px;
}

/* ───────── Форма ───────── */
.ameliya-form {
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--am-border);
}

.ameliya-form-row {
	margin-bottom: 12px;
}

.ameliya-form-row label {
	display: block;
	font-size: 13px;
	color: var(--am-text-muted);
	margin-bottom: 4px;
	font-weight: 500;
}

.ameliya-form-row input,
.ameliya-form-row textarea {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--am-border);
	border-radius: 8px;
	font-size: 16px; /* ≥16px чтобы iOS не зумил */
	color: var(--am-text);
	background: #fff;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	font-family: inherit;
}

.ameliya-form-row input:focus,
.ameliya-form-row textarea:focus {
	outline: none;
	border-color: var(--am-primary);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ameliya-form-row textarea {
	resize: vertical;
	min-height: 80px;
}

.ameliya-form-row.has-error input,
.ameliya-form-row.has-error textarea {
	border-color: var(--am-danger);
}

.ameliya-form-error {
	color: var(--am-danger);
	font-size: 12px;
	margin-top: 4px;
}

.ameliya-summary {
	background: var(--am-bg-soft);
	border: 1px solid var(--am-border);
	border-radius: 8px;
	padding: 12px 14px;
	margin-bottom: 12px;
	font-size: 14px;
}

.ameliya-summary-row {
	display: flex;
	justify-content: space-between;
	margin-bottom: 4px;
}

.ameliya-summary-row:last-child {
	margin-bottom: 0;
	font-weight: 700;
	font-size: 16px;
}

.ameliya-summary-label {
	color: var(--am-text-muted);
}

/* ───────── Кнопка ───────── */
.ameliya-submit {
	width: 100%;
	padding: 14px 20px;
	background: linear-gradient(135deg, var(--am-primary), var(--am-accent));
	color: #fff;
	border: none;
	border-radius: 10px;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
	transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.ameliya-submit:hover:not(:disabled) {
	transform: translateY(-1px);
	box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.ameliya-submit:active:not(:disabled) {
	transform: translateY(0);
}

.ameliya-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	box-shadow: none;
}

.ameliya-submit.is-loading {
	background: var(--am-text-muted);
}

.ameliya-submit-spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ameliya-spin 0.7s linear infinite;
	margin-right: 8px;
	vertical-align: -2px;
}

@keyframes ameliya-spin {
	to { transform: rotate(360deg); }
}

/* ───────── Сообщения / ошибки ───────── */
.ameliya-alert {
	padding: 12px 14px;
	border-radius: 8px;
	font-size: 14px;
	margin: 12px 0;
	display: flex;
	align-items: flex-start;
	gap: 8px;
}

.ameliya-alert-error {
	background: #fef2f2;
	color: #991b1b;
	border: 1px solid #fecaca;
}

.ameliya-alert-success {
	background: #f0fdf4;
	color: #166534;
	border: 1px solid #bbf7d0;
}

.ameliya-alert-info {
	background: #eff6ff;
	color: #1e40af;
	border: 1px solid #bfdbfe;
}

/* ───────── Страница "Спасибо" ───────── */
.ameliya-thanks {
	max-width: 560px;
	margin: 40px auto;
	padding: 32px 24px;
	background: #fff;
	border-radius: var(--am-radius);
	box-shadow: var(--am-shadow);
	text-align: center;
}

.ameliya-thanks-icon {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: #dcfce7;
	color: #16a34a;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 16px;
	font-size: 32px;
	font-weight: 700;
}

.ameliya-thanks-icon.is-fail {
	background: #fee2e2;
	color: #dc2626;
}

.ameliya-thanks h2 {
	margin: 0 0 8px;
	font-size: 22px;
}

.ameliya-thanks-details {
	text-align: left;
	background: var(--am-bg-soft);
	padding: 16px;
	border-radius: 8px;
	margin: 20px 0;
	font-size: 15px;
}

.ameliya-thanks-details dt {
	color: var(--am-text-muted);
	font-size: 13px;
	margin-top: 8px;
}
.ameliya-thanks-details dt:first-child {
	margin-top: 0;
}
.ameliya-thanks-details dd {
	margin: 2px 0 0;
	font-weight: 600;
}

.ameliya-thanks-video {
	display: inline-block;
	margin-top: 16px;
	padding: 12px 24px;
	background: var(--am-primary);
	color: #fff;
	text-decoration: none;
	border-radius: 8px;
	font-weight: 700;
}

.ameliya-thanks-video:hover {
	background: var(--am-primary-hover);
}

/* ───────── Планшеты и десктоп ───────── */
@media (min-width: 640px) {
	.ameliya-booking {
		font-size: 16px;
	}
	.ameliya-header {
		padding: 28px 24px;
	}
	.ameliya-header h3 {
		font-size: 22px;
	}
	.ameliya-body {
		padding: 24px;
	}
	.ameliya-form-row input,
	.ameliya-form-row textarea {
		font-size: 16px;
	}
	.ameliya-slots-list {
		grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	}
	.ameliya-cal-day {
		font-size: 15px;
		min-height: 44px;
	}
}

@media (min-width: 768px) {
	.ameliya-booking {
		max-width: 800px;
	}
	.ameliya-header h3 {
		font-size: 24px;
	}
}

/* ───────── Анимации ───────── */
.ameliya-fade-in {
	animation: ameliya-fade-in 0.25s ease-out;
}

@keyframes ameliya-fade-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ───────── Скроллбар ───────── */
.ameliya-slots-list::-webkit-scrollbar {
	width: 6px;
}
.ameliya-slots-list::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 3px;
}
.ameliya-slots-list::-webkit-scrollbar-track {
	background: transparent;
}
