// Questo file fa parte di MyTown.
// MyTown è software libero: puoi ridistribuirlo e/o modificarlo secondo
// i termini della GNU Affero General Public License come pubblicata dalla
// Free Software Foundation, versione 3.
// Distribuito senza ALCUNA GARANZIA; vedi la GNU AGPL v3 per i dettagli.
// Copyright (C) Kondor Consulting & Services S.r.l.
// SPDX-License-Identifier: AGPL-3.0-or-later

// ============================================================
// TOKENS
// ============================================================

:host {
	--section-radius: 16px;
	--spring: cubic-bezier(0.34, 1.56, 0.64, 1);
	--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

// ============================================================
// HERO
// ============================================================

.detail-hero {
	position: relative;
	overflow: hidden;
	min-height: 140px;
	display: flex;
	align-items: flex-end;
}

.hero-wash {
	position: absolute;
	inset: 0;
	opacity: 0.1;
}

.hero-body {
	position: relative;
	z-index: 1;
	padding: 24px 20px 20px;
	width: 100%;
	animation: fadeUp 0.35s var(--ease-out) both;
}

@keyframes fadeUp {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.hero-service-row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
}

.hero-service-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex-shrink: 0;
}

.hero-service-name {
	font-size: 22px;
	font-weight: 800;
	letter-spacing: -0.5px;
	color: var(--ion-color-dark, #1c1c1e);
	margin: 0;
	line-height: 1.15;
}

.hero-status-badge {
	display: inline-flex;
	align-items: center;
	color: #fff;
	font-size: 11px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	padding: 5px 12px;
	border-radius: 10px;
	margin-bottom: 8px;
}

.hero-apt-id {
	font-size: 12px;
	color: var(--ion-color-medium);
	font-weight: 500;
	margin-top: 4px;
}

// ============================================================
// BODY WRAPPER
// ============================================================

.detail-body {
	padding: 12px 16px 0;
	background: var(--ion-background-color, #f8f8f8);
}

// ============================================================
// SECTIONS
// ============================================================

.detail-section {
	background: var(--ion-card-background, #fff);
	border-radius: var(--section-radius);
	overflow: hidden;
	margin-bottom: 12px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.04);
	animation: fadeUp 0.35s var(--ease-out) both;
}

.section-title {
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.6px;
	color: var(--ion-color-medium);
	margin: 0;
	padding: 14px 16px 6px;
}

.section-header-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px 6px;
}

.section-add-btn {
	background: none;
	border: none;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--ion-color-primary);
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 8px;
	transition: background 0.15s ease;

	ion-icon {
		font-size: 15px;
	}

	&:active {
		background: rgba(var(--ion-color-primary-rgb), 0.08);
	}
}

// ============================================================
// INFO ROWS
// ============================================================

.info-row {
	display: flex;
	align-items: flex-start;
	gap: 0;
	padding: 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.04);
	position: relative;

	&:last-child {
		border-bottom: none;
	}

	&.accent-confirmed {
		.ir-icon-wrap {
			color: var(--ion-color-success);
			background: rgba(var(--ion-color-success-rgb), 0.08);
		}
	}

	&.accent-proposed {
		.ir-icon-wrap {
			color: var(--ion-color-warning);
			background: rgba(var(--ion-color-warning-rgb), 0.08);
		}
	}
}

.ir-icon-wrap {
	width: 52px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 14px 0;
	flex-shrink: 0;
	color: var(--ion-color-medium);
	background: transparent;
	transition: background 0.15s ease;

	ion-icon {
		font-size: 18px;
	}
}

.ir-content {
	flex: 1;
	padding: 13px 16px 13px 4px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.ir-label {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	color: var(--ion-color-medium);
}

.ir-value {
	font-size: 15px;
	font-weight: 600;
	color: var(--ion-color-dark, #1c1c1e);
	letter-spacing: -0.1px;
}

.ir-sub {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	color: var(--ion-color-medium-shade);
	font-weight: 500;
	margin-top: 2px;

	ion-icon {
		font-size: 12px;
		flex-shrink: 0;
	}
}

// ============================================================
// NOTE BLOCKS
// ============================================================

.note-block {
	margin: 0 16px 12px;
	background: var(--ion-color-light, #f4f5f8);
	border-radius: 10px;
	padding: 12px 14px;

	&:first-of-type {
		margin-top: 4px;
	}

	&.is-danger {
		background: rgba(var(--ion-color-danger-rgb), 0.06);
	}
}

.note-tag {
	display: inline-block;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	color: var(--ion-color-medium);
	margin-bottom: 6px;

	.is-danger & {
		color: var(--ion-color-danger);
	}
}

.note-text {
	font-size: 14px;
	color: var(--ion-color-dark-shade);
	line-height: 1.55;
	margin: 0;
	font-style: italic;
}

// ============================================================
// MESSAGES CARD
// ============================================================

.messages-card {
	display: flex;
	align-items: center;
	gap: 0;
	background: var(--ion-card-background, #fff);
	border-radius: var(--section-radius);
	margin-bottom: 12px;
	padding: 16px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.04);
	cursor: pointer;
	transition: transform 0.12s var(--spring);
	animation: fadeUp 0.35s 0.05s var(--ease-out) both;

	&:active {
		transform: scale(0.985);
	}
}

.mc-icon {
	width: 44px;
	height: 44px;
	border-radius: 14px;
	background: rgba(var(--ion-color-primary-rgb), 0.08);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	margin-right: 14px;

	ion-icon {
		font-size: 22px;
		color: var(--ion-color-primary);
	}
}

.mc-body {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.mc-title {
	font-size: 15px;
	font-weight: 700;
	color: var(--ion-color-dark);
	letter-spacing: -0.2px;
}

.mc-sub {
	font-size: 12px;
	color: var(--ion-color-medium);
	font-weight: 500;

	&.mc-unread {
		color: var(--ion-color-danger);
		font-weight: 600;
	}
}

.mc-end {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.mc-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	border-radius: 11px;
	background: var(--ion-color-danger);
	color: #fff;
	font-size: 11px;
	font-weight: 800;
	padding: 0 6px;
}

.mc-arrow {
	font-size: 14px;
	color: var(--ion-color-medium-shade);
}

// ============================================================
// ATTACHMENTS
// ============================================================

.att-empty {
	padding: 16px;
	font-size: 13px;
	color: var(--ion-color-medium);
	text-align: center;
}

.att-list {
	border-radius: 0;
}

.att-item {
	--padding-start: 16px;
	--inner-padding-end: 16px;
}

.att-icon {
	width: 36px;
	height: 36px;
	border-radius: 10px;
	background: rgba(var(--ion-color-primary-rgb), 0.08);
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: 12px;

	ion-icon {
		font-size: 18px;
		color: var(--ion-color-primary);
	}
}

// ============================================================
// TIMELINE (status history)
// ============================================================

.timeline {
	padding: 4px 16px 16px;
}

.tl-item {
	display: flex;
	gap: 14px;
}

.tl-left {
	display: flex;
	flex-direction: column;
	align-items: center;
	flex-shrink: 0;
	padding-top: 4px;
}

.tl-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex-shrink: 0;
	box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.tl-line {
	width: 2px;
	flex: 1;
	background: var(--ion-color-light-shade, #e0e1e5);
	margin: 4px 0;
	min-height: 16px;
}

.tl-content {
	flex: 1;
	padding-bottom: 16px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tl-status {
	font-size: 14px;
	font-weight: 700;
	color: var(--ion-color-dark);
	letter-spacing: -0.1px;
}

.tl-meta {
	font-size: 12px;
	color: var(--ion-color-medium);
	font-weight: 500;
}

.tl-dot-sep {
	margin: 0 4px;
}

.tl-notes {
	font-size: 12px;
	color: var(--ion-color-medium-shade);
	font-style: italic;
	margin-top: 2px;
}

// ============================================================
// ACTION BAR (sticky bottom)
// ============================================================

.action-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 100;
	padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
	background: rgba(255, 255, 255, 0.94);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	border-top: 1px solid rgba(0, 0, 0, 0.07);
	animation: slideUpBar 0.3s var(--spring) both;
}

@keyframes slideUpBar {
	from {
		opacity: 0;
		transform: translateY(100%);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.action-bar-inner {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.action-primary {
	display: flex;
	flex-direction: column;
	gap: 0;
}

.action-btn {
	--border-radius: 14px;
	font-weight: 700;
	font-size: 15px;
	height: 48px;
}

.action-secondary {
	display: flex;
	gap: 8px;

	ion-button {
		flex: 1;
	}
}

.action-btn-sm {
	--border-radius: 12px;
	font-size: 13px;
	font-weight: 600;
}

// ============================================================
// SLOT PICKER (modal Proponi Data) - allineato al wizard richiesta
// ============================================================

.day-chips-scroll {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding-bottom: 4px;
	-webkit-overflow-scrolling: touch;

	&::-webkit-scrollbar {
		display: none;
	}
}

.day-chip {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: 70px;
	padding: 10px 12px;
	border-radius: 12px;
	background: var(--ion-color-light);
	cursor: pointer;
	transition: all 0.2s;
	flex-shrink: 0;

	&.selected {
		background: var(--ion-color-primary);
		color: white;

		.day-chip-label,
		.day-chip-date {
			color: white;
		}
	}
}

.day-chip-label {
	font-size: 12px;
	font-weight: 600;
	color: var(--ion-text-color);
}

.day-chip-date {
	font-size: 11px;
	color: var(--ion-color-medium);
	margin-top: 2px;
}

.period-toggle-row {
	display: flex;
	justify-content: center;
	gap: 0;
	background: var(--ion-color-light);
	border-radius: 20px;
	padding: 2px;
	margin-bottom: 12px;
}

.period-btn {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 6px 12px;
	border-radius: 18px;
	font-size: 12px;
	font-weight: 500;
	color: var(--ion-color-medium);
	cursor: pointer;
	transition: all 0.2s;

	ion-icon {
		font-size: 14px;
	}

	&.active {
		background: var(--ion-color-primary);
		color: white;
	}
}

.time-chips-scroll {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding-bottom: 4px;
	-webkit-overflow-scrolling: touch;

	&::-webkit-scrollbar {
		display: none;
	}
}

.time-chip {
	padding: 10px 18px;
	border-radius: 20px;
	background: var(--ion-color-light);
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
	flex-shrink: 0;
	white-space: nowrap;

	&.selected {
		background: var(--ion-color-primary);
		color: white;
	}
}

.time-separator {
	width: 2px;
	background: var(--ion-color-light-shade);
	flex-shrink: 0;
	margin: 4px 4px;
	border-radius: 1px;
}
