// 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 {
	--item-radius: 14px;
	--spring: cubic-bezier(0.34, 1.56, 0.64, 1);
	--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

// ============================================================
// TOOLBAR / SEARCHBAR
// ============================================================

.search-toolbar {
	--background: var(--ion-toolbar-background);
	padding: 0 8px 6px;
}

.custom-searchbar {
	--background: var(--ion-color-light, #f4f5f8);
	--border-radius: 12px;
	--box-shadow: none;
	--placeholder-color: var(--ion-color-medium);
	--color: var(--ion-color-dark);
	--icon-color: var(--ion-color-medium);
	font-size: 14px;
	padding: 0;
}

// ============================================================
// POPOVER
// ============================================================

.popover-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	padding: 8px 16px 16px;
}

// ============================================================
// TIMELINE LIST
// ============================================================

.apt-list {
	padding: 12px 16px 88px;
	display: flex;
	flex-direction: column;
	gap: 0;
}

// ============================================================
// DATE GROUP HEADER
// ============================================================

.date-group-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 20px 0 10px;

	&:first-child {
		padding-top: 4px;
	}

	&.is-today .dgr-label {
		color: var(--ion-color-primary);
		font-weight: 800;
	}
}

.dgr-label {
	font-size: 12px;
	font-weight: 700;
	color: var(--ion-color-medium);
	text-transform: uppercase;
	letter-spacing: 0.6px;
	white-space: nowrap;
	flex-shrink: 0;
}

.dgr-line {
	flex: 1;
	height: 1px;
	background: linear-gradient(to right, var(--ion-color-light-shade, #d8d9de), transparent);
}

// ============================================================
// APPOINTMENT CARD
// ============================================================

.apt-item {
	display: flex;
	align-items: stretch;
	background: var(--ion-card-background, #fff);
	border-radius: var(--item-radius);
	overflow: hidden;
	margin-bottom: 8px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.05);
	cursor: pointer;
	transition: transform 0.12s var(--spring), box-shadow 0.12s ease;
	animation: aptFadeIn 0.3s var(--ease-out) both;

	&:active {
		transform: scale(0.985);
		box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
	}
}

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

.apt-accent {
	width: 4px;
	flex-shrink: 0;
	align-self: stretch;
}

.apt-body {
	flex: 1;
	padding: 13px 10px 13px 14px;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

// Title row
.apt-title-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.apt-title {
	font-size: 15px;
	font-weight: 700;
	color: var(--ion-color-dark, #1c1c1e);
	letter-spacing: -0.2px;
	flex: 1;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.apt-badge {
	flex-shrink: 0;
	color: #fff;
	font-size: 10px;
	font-weight: 800;
	padding: 3px 8px;
	border-radius: 7px;
	letter-spacing: 0.2px;
	text-transform: uppercase;
}

// Subtitle
.apt-subtitle {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	color: var(--ion-color-medium-shade);
	font-weight: 500;

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

// Meta chips
.apt-meta-row {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 2px;
}

.apt-meta-chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	color: var(--ion-color-medium);
	font-weight: 500;

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

// End column
.apt-end {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 12px;
	flex-shrink: 0;
}

.apt-unread {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	background: var(--ion-color-danger);
	color: #fff;
	font-size: 10px;
	font-weight: 800;
	padding: 2px 6px;
	border-radius: 10px;

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

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

// ============================================================
// SKELETON LOADING
// ============================================================

.skeleton-group-header {
	width: 80px;
	height: 12px;
	background: var(--ion-color-light, #f4f5f8);
	border-radius: 6px;
	margin: 4px 0 14px;
	animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-card {
	display: flex;
	align-items: stretch;
	background: var(--ion-card-background, #fff);
	border-radius: var(--item-radius);
	overflow: hidden;
	margin-bottom: 8px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sk-accent {
	width: 4px;
	background: var(--ion-color-light, #f4f5f8);
	animation: shimmer 1.4s ease-in-out infinite;
}

.sk-body {
	flex: 1;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.sk-line {
	border-radius: 6px;
	background: var(--ion-color-light, #f4f5f8);
	animation: shimmer 1.4s ease-in-out infinite;

	&.sk-title {
		height: 15px;
		width: 65%;
	}

	&.sk-sub {
		height: 12px;
		width: 45%;
	}

	&.sk-meta {
		height: 11px;
		width: 50%;
	}
}

@keyframes shimmer {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.45; }
}

// ============================================================
// EMPTY STATE
// ============================================================

.empty-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 64px 32px 40px;
	text-align: center;
}

.empty-icon-box {
	width: 80px;
	height: 80px;
	border-radius: 24px;
	background: var(--ion-color-light, #f4f5f8);
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 20px;

	ion-icon {
		font-size: 38px;
		color: var(--ion-color-medium);
	}
}

.empty-title {
	font-size: 18px;
	font-weight: 700;
	color: var(--ion-color-dark);
	margin: 0 0 8px;
	letter-spacing: -0.3px;
}

.empty-sub {
	font-size: 14px;
	color: var(--ion-color-medium);
	margin: 0 0 24px;
	line-height: 1.5;
}

// ============================================================
// FAB
// ============================================================

.custom-fab {
	--background: var(--ion-color-primary);
	--box-shadow: 0 4px 20px rgba(var(--ion-color-primary-rgb), 0.4);
}
