/* Toast notifications */
.toast-container {
	position: fixed;
	top: 20px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 9999;
	display: flex;
	flex-direction: column;
	gap: 10px;
	pointer-events: none;
}
.toast {
	pointer-events: auto;
	min-width: 220px;
	max-width: 420px;
	padding: 10px 14px;
	border-radius: 10px;
	color: #fff;
	font-weight: 600;
	box-shadow: 0 8px 24px rgba(2,8,20,0.6);
	transform: translateY(8px) scale(0.98);
	opacity: 0;
	transition: transform 220ms ease, opacity 220ms ease;
}
.toast--visible { transform: translateY(0) scale(1); opacity: 1; }
.toast--success { background: linear-gradient(90deg,#65ca53,#1fa03d); }
.toast--error { background: linear-gradient(90deg,#ff6b6b,#d64545); }
.toast--info { background: linear-gradient(90deg,#4f81ff,#3c6bff); }
/* Dialog popups */
#dialog-root { position: fixed; inset: 0; z-index: 2147483000; pointer-events: none; }
.dialog-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(2,8,20,0.6); opacity: 0; transition: opacity 200ms ease; pointer-events: auto; z-index: 2147483001; }
.dialog-overlay.show { opacity: 1; }
.dialog-panel { pointer-events: auto; background: var(--panel-bg); border-radius: 12px; padding: 18px; width: 420px; max-width: calc(100% - 32px); box-shadow: var(--shadow-strong); color: var(--text-primary); transform: translateY(6px) scale(0.98); opacity: 0; transition: transform 200ms ease, opacity 200ms ease; }
.dialog-panel.show { transform: translateY(0) scale(1); opacity: 1; }
.dialog-message { font-size: 15px; line-height: 1.4; color: var(--text-primary); }
.dialog-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.dialog-btn { padding: 8px 12px; border-radius: 8px; border: none; cursor: pointer; font-weight: 700; color: #fff; background: rgba(15,23,42,0.5); }
.dialog-btn.cancel { background: #6b7280; }
.dialog-btn.confirm { background: var(--accent); }

/* main styles */

:root {
	--app-bg: #050c1f;
	--panel-bg: rgba(12, 21, 45, 0.92);
	--panel-border: rgba(62, 93, 166, 0.32);
	--sidebar-bg: rgba(7, 16, 35, 0.92);
	--sidebar-border: rgba(45, 72, 133, 0.35);
	--text-primary: #f3f6ff;
	--text-secondary: rgba(208, 220, 255, 0.72);
	--muted: rgba(146, 162, 207, 0.55);
	--accent: #4f81ff;
	--accent-soft: rgba(79, 129, 255, 0.16);
	--accent-strong: rgba(79, 129, 255, 0.38);
	--today-ring: rgba(95, 159, 255, 0.6);
	--header-height: 96px;
	--shadow-strong: 0 25px 65px rgba(7, 17, 43, 0.7);
	--shadow-soft: 0 12px 30px rgba(12, 25, 54, 0.35);
	font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: radial-gradient(circle at top right, rgba(30, 66, 131, 0.25), transparent 45%), var(--app-bg);
	color: var(--text-primary);
	min-height: 100vh;
	display: flex;
}

.app-shell {
	display: flex;
	flex-direction: column;
	width: 100%;
	min-height: 100vh;
}

.app-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 24px 40px;
	border-bottom: 1px solid var(--panel-border);
	background: rgba(9, 18, 39, 0.88);
	backdrop-filter: blur(18px);
	box-shadow: var(--shadow-soft);
	position: sticky;
	top: 0;
	z-index: 100;
	min-height: var(--header-height);
}

.brand__subtitle {
	margin: 0 0 6px;
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: 0.16em;
	color: var(--text-secondary);
}

.brand__title {
	margin: 0;
	font-size: 22px;
	letter-spacing: 0.02em;
	font-weight: 700;
}

.user-panel {
	display: flex;
	align-items: center;
	gap: 18px;
}

.user-panel__info {
	display: flex;
	flex-direction: column;
	text-align: right;
	gap: 4px;
}

.user-panel__name {
	font-weight: 600;
	font-size: 15px;
}

.user-panel__role {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--text-secondary);
}

.app-body {
	flex: 1;
	display: flex;
	gap: 28px;
	padding: 32px 40px 48px;
	align-items: flex-start;
}

.sidebar {
	width: 260px;
	background: var(--sidebar-bg);
	border-radius: 24px;
	border: 1px solid var(--sidebar-border);
	padding: 28px 24px;
	display: flex;
	flex-direction: column;
	gap: 24px;
	box-shadow: var(--shadow-soft);
	position: sticky;
	top: calc(var(--header-height) + 24px);
	align-self: flex-start;
	max-height: calc(100vh - var(--header-height) - 40px);
	overflow-y: auto;
	scrollbar-width: thin;
}

.sidebar__title {
	margin: 0;
	text-transform: uppercase;
	font-size: 13px;
	letter-spacing: 0.18em;
	color: var(--text-secondary);
}

.sidebar__nav {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.sidebar__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	border-radius: 16px;
	border: 1px solid transparent;
	background: rgba(20, 32, 66, 0.7);
	color: var(--text-secondary);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.015em;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.sidebar__item:hover {
	transform: translateY(-2px);
	background: rgba(40, 63, 113, 0.8);
	color: var(--text-primary);
}

.sidebar__item.is-active {
	background: var(--accent-soft);
	border-color: var(--accent-strong);
	color: #ffffff;
	box-shadow: 0 18px 40px rgba(58, 104, 255, 0.25);
}

.workspace {
	flex: 1;
	min-width: 0;
}

.calendar-card {
	background: var(--panel-bg);
	border-radius: 32px;
	border: 1px solid var(--panel-border);
	padding: 32px;
	display: flex;
	flex-direction: column;
	gap: 28px;
	height: 100%;
	box-shadow: var(--shadow-strong);
}

.calendar-card__header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 24px;
}

.calendar-card__title {
	margin: 0 0 8px;
	font-size: 24px;
	text-transform: uppercase;
	letter-spacing: 0.16em;
}

.calendar-card__subtitle {
	margin: 0;
	font-size: 18px;
	letter-spacing: 0.12em;
	color: var(--text-secondary);
}

.calendar-card__current {
	margin: 0;
	font-size: 14px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

.calendar-toolbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 20px;
}

.calendar-toolbar__buttons {
	display: flex;
	gap: 12px;
}

.calendar-grid {
	display: flex;
	flex-direction: column;
	gap: 18px;
	width: 100%;
}

.calendar-grid__head,
.calendar-week__cells {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 16px;
}

.calendar-weeks {
	display: flex;
	flex-direction: column;
	gap: 28px;
}

.calendar-week {
	display: flex;
	flex-direction: column;
	gap: 12px;
	position: relative;
	padding-bottom: 0;
}

.calendar-week__cells {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	grid-auto-rows: unset;
	grid-auto-flow: unset;
	align-items: stretch;
	position: relative;
}

.calendar-week__timeline {
	display: grid;
    /* split each calendar cell into two halves (first/second) */
    grid-template-columns: repeat(14, minmax(0, 1fr));
	grid-auto-rows: 26px;
	grid-auto-flow: row dense;
	gap: 8px 16px;
	align-items: center;
	min-height: 0;
	position: absolute;
	left: 0;
	right: 0;
	top: 44px;
	pointer-events: none;
}

.calendar-week__timeline .timeline-bar {
	pointer-events: auto;
}

.timeline-bar {
	appearance: none;
	-webkit-appearance: none;
	min-height: 24px;
	border-radius: 999px;
	border: 1px solid rgba(15, 23, 42, 0.12);
	background: rgba(255, 255, 255, 0.85);
	color: #0f172a;
	font-size: 12px;
	font-weight: 600;
	padding: 0 14px;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	box-shadow: 0 8px 18px rgba(10, 16, 32, 0.35);
	cursor: pointer;
}

/* Timeline status colours (lo2 = stronger/darker, lo1 = lighter/pastel) */
/* Kế hoạch (blue) */
.timeline-bar.timeline-bar--status-kehoach-lo2 {
	background: #1E40AF ; /* blue - lo2 */
	border-color: #ffffff ;
	color: #ffffff ;
}
.timeline-bar.timeline-bar--status-kehoach-lo1 {
	background: #DBEAFE ; /* pale blue - lo1 */
	border-color: #ffffff ;
	color: #062244 ;
}

/* Đã đăng ký (purple) */
.timeline-bar.timeline-bar--status-dadangky-lo2 {
	background: #aa46fc ; /* purple - lo2 */
	border-color: #ffffff ;
	color: #ffffff ;
}
.timeline-bar.timeline-bar--status-dadangky-lo1 {
	background: #af7ffd ; /* pale purple - lo1 */
	/* background: #F3E8FF ;  */
	border-color: #ffffff ;
	color: #ffffff ;
}

/* Đang thực hiện (yellow) */
.timeline-bar.timeline-bar--status-dangthuchien-lo2 {
	background: #F59E0B ; /* amber/yellow - lo2 */
	border-color: #ffffff ;
	color: #ffffff ;
}
.timeline-bar.timeline-bar--status-dangthuchien-lo1 {
	background: #FEF3C7 ; /* pale yellow - lo1 */
	border-color: #ffffff ;
	color: #5a3f00 ;
}

/* Kết thúc (green) */
.timeline-bar.timeline-bar--status-ketthuc-lo2 {
	background: #059669 ; /* green - lo2 */
	border-color: #ffffff ;
	color: #ffffff ;
}
.timeline-bar.timeline-bar--status-ketthuc-lo1 {
	background: #D1FAE5 ; /* pale green - lo1 */
	border-color: #ffffff ;
	color: #08361e ;
}

/* Delay (red) */
.timeline-bar.timeline-bar--status-delay-lo2 {
	background: #fd7f7f ; /* red - lo2 */
	border-color: #ffffff ;
	color: #a50000 ;
}
.timeline-bar.timeline-bar--status-delay-lo1 {
	background: #FEE2E2 ; /* pale red - lo1 */
	border-color: #ffffff ;
	color: #a50000 ;
}

.timeline-bar--placeholder {
	/* dashed border and transparent background regardless of status */
	border-style: dashed !important;
	border-width: 1px !important;
	border-color: rgba(100, 116, 139, 0.25) !important;
	background: transparent !important; /* make background transparent */
	color: #717171 !important; /* keep text color from status or global styles */
	box-shadow: none !important; /* remove colored shadow from status variants */
}

.calendar-weekday {
	text-transform: uppercase;
	letter-spacing: 0.18em;
	font-size: 12px;
	color: var(--text-secondary);
	text-align: center;
	padding-bottom: 6px;
}

.calendar-cell {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 150px;
	height: 150px;
	padding: 16px;
	border-radius: 18px;
	border: 1px solid rgba(65, 104, 200, 0.18);
	background: linear-gradient(160deg, rgba(14, 26, 55, 0.75), rgba(9, 18, 39, 0.88));
	box-shadow: inset 0 0 0 1px rgba(40, 71, 142, 0.16);
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Visual split: show a subtle divider to indicate first-half / second-half of the day */
.calendar-cell::after {
    content: "";
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 50%;
    width: 1px;
    transform: translateX(-0.5px);
    background: linear-gradient(to bottom, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
    pointer-events: none;
    border-radius: 1px;
}

/* Make the halves slightly hover-highlightable (subtle) without changing layout */
.calendar-cell:hover::after {
    background: linear-gradient(to bottom, rgba(255,255,255,0.05), rgba(255,255,255,0.03));
}

.calendar-cell:hover {
	transform: translateY(-3px);
	border-color: rgba(103, 145, 255, 0.4);
	box-shadow: 0 18px 40px rgba(20, 40, 95, 0.45);
}

.calendar-cell__action {
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0;
	border-radius: 14px;
	border: none;
	background: rgba(79, 129, 255, 0.16);
	color: #dfe7ff;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	cursor: pointer;
	opacity: 0;
	transform: translateY(-4px);
	transition: opacity 0.18s ease, transform 0.18s ease, background-color 0.2s ease;
	pointer-events: none;
}

.calendar-cell__action:hover {
	background: rgba(79, 129, 255, 0.28);
}

.calendar-cell__action-icon {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: rgba(79, 129, 255, 0.35);
	border: 1px solid rgba(79, 129, 255, 0.45);
	display: grid;
	place-items: center;
	font-size: 14px;
}

.calendar-cell:hover .calendar-cell__action,
.calendar-cell:focus-within .calendar-cell__action {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.calendar-cell__date {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 16px;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.calendar-cell__date span {
	color: var(--muted);
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.calendar-cell__events {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 40px;
}

.calendar-cell--muted {
	opacity: 0.45;
}

.calendar-cell--today {
	border-color: rgb(255, 170, 0);
	box-shadow: 0 0 0 2px rgba(244, 255, 126, 0.3);
}

.calendar-cell--has-event {
	border-color: rgba(97, 151, 255, 0.35);
}

.calendar-empty {
	min-height: 0;
	height: 1px;
	visibility: hidden;
}

.calendar-empty-message {
	grid-column: 1 / -1;
	text-align: center;
	padding: 48px 16px;
	border-radius: 18px;
	border: 1px dashed rgba(100, 132, 210, 0.4);
	color: var(--text-secondary);
	background: rgba(19, 30, 60, 0.6);
}

.event-pill__meta {
	font-size: 11px;
	color: rgba(205, 221, 255, 0.7);
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.serial-grid__unit {
	font-size: 14px;
	color: rgba(208, 220, 255, 0.8);
	white-space: nowrap;
}

@media (max-width: 1280px) {
	.app-body {
		padding: 10px 24px 0 24px;
		gap: 20px;
	}

	.sidebar {
		top: calc(var(--header-height) + 16px);
		max-height: calc(100vh - var(--header-height) - 32px);
	}

	.calendar-card {
		border-radius: 24px;
	}

	.calendar-grid {
		gap: 12px;
	}

	.calendar-cell {
		min-height: 110px;
	}
}

@media (max-width: 900px) {
	.calendar-toolbar {
		flex-direction: column;
		align-items: flex-start;
	}

	.calendar-toolbar__buttons {
		width: 100%;
		justify-content: flex-start;
		flex-wrap: wrap;
	}

	.usage-chip {
		width: 100%;
		justify-content: space-between;
	}

	.calendar-grid {
		grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	}
}
