:root {
/* CSS HEX */
--midnight-violet: #2e0014ff;
--espresso: #442220ff;
--palm-leaf: #809848ff;
--muted-olive: #b0ca87ff;
--celadon: #b5deadff;
--glamour-white: #fffbed;
--off-white: #f2f3f4;
}

* {
  box-sizing: border-box;
}

h1 {
  font-size: 2em;
  margin: 0 0 0.67em 0;
}

body {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	font-family: Arial, Helvetica, sans-serif;
	color:var(--midnight-violet);
	line-height:1.6;
	margin: 0;
}

.button {
	border: 2px solid var(--midnight-violet);
	background-color: var(--palm-leaf);
	color: var(--glamour-white);
	padding: 0.5em 1em;
	margin: 0.5em 0;
	text-align: center;
	text-decoration: none;
	display: inline-block;
	font-size: 16px;
	cursor: pointer;
	border-radius: 10px;
}
.button:hover{
	background-color: var(--muted-olive);
}

.container{
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	flex-grow: 1;
}
/* Make this selector more specific to only target the direct child div */
.container > div{
	width: 100%;
	align-self: center;
	background-color: var(--off-white);
	margin: 10px;
	padding: 20px;
	border-radius: 10px;
	text-align: center;
}

.header-with-button {
	display: grid;
	grid-template-columns: 1fr auto 1fr; /* Left spacer, h1, right spacer for button */
	align-items: center;
	margin: 1em;
}

.header-with-button h1 {
	grid-column: 2 / 3; /* Place h1 in the middle column */
	text-align: center;
	padding-right: 5px;
	margin: 0;
	white-space: nowrap; /* Prevent text wrapping */
	overflow: hidden; /* Hide overflowing text */
	text-overflow: ellipsis; /* Add ellipsis for overflowing text */
}

.header-with-button .button {
	margin: 0;
	grid-column: 3 / 4; /* Place button in the third column */
	justify-self: end; /* Align button to the end of its grid cell */
}

.auth-buttons {
	display: flex;
	justify-content: center;
	gap: 10px;
	margin-top: 1em;
}

/* Style for the divs inside the form */
.container form div {
	display: flex;
	align-items: center;
	text-align: left;
	gap: 10px; /* Adds space between label and input */
}

/* Give labels a fixed width to align input boxes */
.container form label {
	width: 80px;
	flex-shrink: 0; /* Prevents the label from shrinking */
}

.inputBox{
	border: 2px solid var(--midnight-violet);
	padding: 0.5em 1em;
	color: var(--midnight-violet);
	margin: 0.5em 0;
	background-color: var(--muted-olive);
	border-radius: 10px;
	font-size: 16px;
	flex-grow: 1; /* Allow input to fill remaining space */
}

.inputBox:focus {
	outline: 2px solid var(--palm-leaf);
	background-color: var(--glamour-white);
}

#new-todo-form .add-todo-controls {
	display: flex;
	gap: 10px;
	align-items: center;
}

#new-todo-form .inputBox {
	margin: 0;
}

#new-todo-form .button {
	margin: 0;
	flex-shrink: 0;
}

#todo-list {
	list-style-type: none;
	padding: 0;
}

#todo-list li {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background-color: var(--celadon);
	padding: 10px;
	border-radius: 5px;
	margin-bottom: 5px;
}

.display-controls{
	margin-top: 1em;
	display: flex;
	align-items: stretch;
	gap: 1em;
	flex-wrap: wrap;
	height: auto;
}

.todo-controls {
	padding: 5px;       
	border: 1px solid var(--midnight-violet);  
	border-radius: 5px;   
	background-color: var(--off-white);  
	width: auto;
	display: flex;
	align-items: center;
	gap: 0.5em;
}

#hide-completed-toggle {
	appearance: none;
	-webkit-appearance: none;
	width: 20px;
	height: 20px;
	border: 2px solid var(--midnight-violet);
	border-radius: 5px;
	background-color: var(--glamour-white);
	cursor: pointer;
	position: relative;
	vertical-align: middle;
	margin-right: 5px;
}

#hide-completed-toggle:checked {
	background-color: var(--palm-leaf);
}

#hide-completed-toggle:checked::after {
	content: '\2713'; 
	font-size: 14px;
	color: var(--glamour-white);
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

.todo-controls .inputBox {
	margin: 0;
}

#sort-todos-select {
	font-size: 14px;
}
.todo-text {
	flex-grow: 1;
	text-align: left;
	margin-right: 10px;
	cursor: pointer;
}

.todo-buttons {
	display: flex;
	gap: 5px;
	flex-shrink: 0;
}

.todo-delete-button {
	background-color: var(--espresso);
}

/* --- Calendar Styles --- */

#calendar {
	width: 100%;
}

.calendar-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1em;
}

.calendar-header h2 {
	margin: 0;
}

.calendar-header .button {
	margin: 0;
}

.calendar-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 2px;
	background-color: var(--midnight-violet);
	border: 2px solid var(--midnight-violet);
	border-radius: 5px;
	overflow: hidden; /* Ensures inner border radius is clipped */
}

.calendar-day-header {
	font-weight: bold;
	text-align: center;
	padding: 0.5em;
	background-color: var(--palm-leaf);
	color: var(--glamour-white);
}

.calendar-day {
	background-color: var(--glamour-white);
	min-height: 100px;
	padding: 4px;
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0; /* Prevents long unbreakable words from stretching the grid cell */
}

.day-number {
	font-size: 0.8em;
	font-weight: bold;
	color: var(--espresso);
	align-self: center;
}

.calendar-todo {
	font-size: 0.75em;
	padding: 2px 4px;
	background-color: var(--muted-olive);
	color: var(--midnight-violet);
	border-radius: 3px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.calendar-todo.completed {
	text-decoration: line-through;
	background-color: var(--celadon);
}

/* --- Journal / Modal Styles --- */

.modal-backdrop {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.6);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 1000;
}

.modal-content {
	background-color: var(--glamour-white);
	padding: 20px;
	border-radius: 10px;
	width: 90%;
	max-width: 600px;
	display: flex;
	flex-direction: column;
}

.modal-title {
	margin-top: 0;
}

.modal-content #journal-text {
	width: 100%;
	min-height: 200px;
	margin-bottom: 1em;
	resize: vertical;
}

.modal-buttons {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

.modal-buttons .button {
	margin: 0;
}

.calendar-day.has-journal .day-number {
	font-weight: bold;
	color: var(--glamour-white);
	background-color: var(--palm-leaf);
	border-radius: 50%;
	width: 1.5em;
	height: 1.5em;
	display: flex;
	justify-content: center;
	align-items: center;
}

.calendar-day:hover {
	cursor: pointer;
	background-color: var(--celadon);
}

.edit-todo-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 1em;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
	body {
		font-size: 14px; /* Adjust base font size for better readability */
	}

	.container {
		padding: 0 5px;
	}

	.container > div {
		padding: 15px;
		margin: 10px 0;
	}

	h1 {
		font-size: 1.6em;
	}

	/* --- Login/Register Form --- */
	.container form div:not(.add-todo-controls):not(.auth-buttons) {
		flex-direction: column;
		align-items: stretch;
		gap: 2px;
	}

	.container form label {
		width: auto;
		text-align: left;
	}

	/* --- Dashboard: Add To-Do Form --- */
	#new-todo-form .add-todo-controls {
		flex-direction: column;
		align-items: stretch;
	}

	/* --- Dashboard: To-Do List --- */
	#todo-list li {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.todo-text {
		margin-right: 0;
	}

	.todo-buttons {
		align-self: flex-end;
	}


	/* --- Dashboard: Calendar --- */
	.calendar-day {
		min-height: 80px; /* Make calendar cells shorter */
	}

	/* --- Modals --- */
	.modal-content {
		width: 95%;
		padding: 15px;
	}

	.modal-title {
		font-size: 1.4em;
	}

	.edit-todo-form {
		gap: 8px;
	}
}

@media (max-width: 480px) {
	/* Further adjustments for very small screens */
	.modal-content {
		padding: 10px;
	}

	.modal-title {
		font-size: 1.2em;
		margin-bottom: 0.5em;
	}

	.modal-content #journal-text {
		min-height: 150px; /* Reduce textarea height */
	}
}

/* --- Toast Notifications --- */
#toast-container {
	position: fixed;
	top: 20px;
	left: 20px;
	z-index: 2000;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: 300px;
}

.toast {
	padding: 15px 20px;
	border-radius: 5px;
	color: var(--glamour-white);
	font-size: 1em;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
	opacity: 0;
	transform: translateX(-120%);
	transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.toast.show {
	opacity: 1;
	transform: translateX(0);
}

.toast.error { background-color: var(--espresso); }
.toast.success { background-color: var(--palm-leaf); }
.toast.info { background-color: var(--midnight-violet); }