/* Core theme variables */
:root {
	/* --- General Colors --- */
	--bg-color: #f5f7fa;
	--text-color: #333;
	--text-muted: #777;
	--card-bg: #fff;
	--sidebar-bg: #e0e6ed;
	--border-color: #ddd;

	/* --- Accent Colors --- */
	--primary-accent: #1e88e5;
	--primary-accent-dark: #1565c0;
	--secondary-accent: #ffc107; /* Used for live status/current class */
	--warning-accent: #ff5722; /* Used for special events */
	--blue-day-color: #1e88e5;
	--gold-day-color: #ffc107;

	/* --- Schedule Block Colors --- */
	--block-bg: #f9f9f9;
	--block-border-color: #e0e0e0;
	--live-block-bg: #e0f7fa;

	/* --- Shadows and Borders --- */
	--shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
	--modal-bg: rgba(0, 0, 0, 0.5);

	/* --- Typography --- */
	--font-family: 'Nunito', sans-serif;

	/* --- Hover states --- */
	--hover-background: #f0f0f0;
}

body.dark-mode {
	--bg-color: #121212;
	--text-color: #e0e0e0;
	--text-muted: #aaa;
	--card-bg: #1e1e1e;
	--sidebar-bg: #2c2c2c;
	--border-color: #444;

	--primary-accent: #64b5f6;
	--primary-accent-dark: #42a5f5;
	--secondary-accent: #ffeb3b;
	--warning-accent: #ff8a65;
	--blue-day-color: #42a5f5;
	--gold-day-color: #ffeb3b;

	/* --- Schedule Block Colors (Dark Mode) --- */
	--block-bg: #2a2a2a;
	--block-border-color: #383838;
	--live-block-bg: #004d40;

	--shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
	--modal-bg: rgba(255, 255, 255, 0.2);

	--hover-background: #2a2a2a;
}

/* Base Styles */
* {
	box-sizing: border-box;
}

body {
	font-family: var(--font-family);
	margin: 0;
	padding: 0;
	background-color: var(--bg-color);
	color: var(--text-color);
	transition: background-color 0.3s, color 0.3s;
	display: flex;
	min-height: 100vh;
}

/* Loading Overlay */
.loading-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: var(--bg-color);
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	z-index: 1000;
	transition: opacity 0.5s ease-in-out;
}

.loading-overlay.hidden {
	opacity: 0;
	pointer-events: none;
}

.loading-spinner {
	border: 8px solid var(--text-color);
	border-top: 8px solid var(--primary-accent);
	border-radius: 50%;
	width: 60px;
	height: 60px;
	animation: spin 1s linear infinite;
	margin-bottom: 20px;
}

@keyframes spin {
	0% {
		transform: rotate(0deg);
	}

	100% {
		transform: rotate(360deg);
	}
}

/* --- Sidebar Styles --- */
#sidebar {
	background-color: var(--sidebar-bg);
	color: var(--text-color);
	padding: 20px;
	box-shadow: var(--shadow);
	transition: transform 0.3s ease, width 0.3s ease;
	z-index: 1000;
	position: fixed;
	top: 0;
	left: 0;
	height: 100%;
	width: 250px;
	transform: translateX(-100%);
	overflow-y: auto;
}

#sidebar.open {
	transform: translateX(0);
}

#sidebar .logo {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--primary-accent);
	padding-bottom: 10px;
	border-bottom: 1px solid var(--border-color);
}

#sidebar .nav-list {
	list-style: none;
	padding: 0;
	margin: 20px 0;
}

#sidebar .nav-item {
	margin-bottom: 5px;
}

#sidebar .nav-link {
	display: flex;
	align-items: center;
	gap: 15px;
	padding: 12px 15px;
	text-decoration: none;
	color: var(--text-color);
	font-weight: 700;
	border-radius: 8px;
	transition: background-color 0.2s, color 0.2s;
}

#sidebar .nav-link i {
	width: 20px;
	text-align: center;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
	background-color: var(--primary-accent);
	color: white;
}

#sidebar hr {
	border-color: var(--border-color);
	margin: 15px 0;
}

/* User Profile Dropdown and Modals */
.user-profile-container {
	/* Base styles, applies to both containers */
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	z-index: 500;
}

.profile-trigger {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
}

.profile-pic {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	transition: transform 0.2s ease;
	border: 2px solid var(--primary-accent);
}

.profile-trigger:hover .profile-pic {
	transform: scale(1.1);
}

.dropdown-chevron {
	color: var(--text-color);
	font-size: 1rem;
	transition: transform 0.3s ease;
}

.dropdown-chevron.rotated {
	transform: rotate(180deg);
}

/* --- DROPDOWN MENU STYLES --- */
.logout-menu {
	position: absolute;
	top: 50px;
	right: 0;
	background-color: var(--card-bg);
	border: 1px solid var(--border-color);
	border-radius: 8px;
	box-shadow: var(--shadow);
	min-width: 200px;
	padding: 10px;
	z-index: 10;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-10px);
	transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.logout-menu.visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.user-info-header {
	text-align: center;
	padding: 5px 10px 10px;
}

.user-info-header hr {
	border: 0;
	height: 1px;
	background: var(--border-color);
	margin-top: 10px;
	margin-bottom: 0;
}

#user-full-name {
	font-weight: bold;
	font-size: 1.1rem;
	display: block;
}

/* NEW RULE: Style for the grade text in the dropdown */
#user-full-name + span {
	font-size: 0.9rem;
	color: var(--text-muted);
}

.dropdown-options {
	list-style: none;
	padding: 0;
	margin: 0;
}

.dropdown-options li {
	margin-bottom: 5px;
}

.dropdown-link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px;
	text-decoration: none;
	color: var(--text-color);
	border-radius: 6px;
	transition: background-color 0.2s;
}

.dropdown-link:hover {
	background-color: var(--hover-background);
}

body.dark-mode .dropdown-link:hover {
	background-color: #333;
}

.dropdown-link i {
	width: 20px;
	text-align: center;
}

/* --- Modal Core Styles --- */
/*
 * This is the full-screen overlay for the modal.
 * It uses flexbox to center its child element.
*/
/* --- Modal Core Styles --- */
.modal {
    display: none; /* Keep the modal hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
    display: block; /* Use block to enable the following centering method */
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: fixed; /* Position the content fixed within the viewport */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9); /* Center and apply initial scale */
    transition: transform 0.3s ease-out;
    z-index: 1003;
}

.modal.show .modal-content {
    transform: translate(-50%, -50%) scale(1); /* Scale up to 1 when shown */
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid var(--border-color);
	padding-bottom: 10px;
	margin-bottom: 20px;
}

.modal-header h3 {
	margin: 0;
	color: var(--text-color);
}

.close-button {
	color: #aaa;
	font-size: 28px;
	font-weight: bold;
	cursor: pointer;
	transition: color 0.2s;
	position: absolute;
	top: 10px;
	right: 15px;
}

.close-button:hover,
.close-button:focus {
	color: var(--text-color);
	text-decoration: none;
	cursor: pointer;
}

.modal-body {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 20px;
}

/* Settings and Profile Specifics */
.settings-section {
	background-color: var(--hover-background);
	padding: 20px;
	border-radius: 8px;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.dark-mode .settings-section {
	background-color: #2a2a2a;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.settings-section h4 {
	margin: 0 0 15px 0;
	font-size: 1.1rem;
	color: var(--text-color);
	display: flex;
	align-items: center;
	gap: 10px;
	border-bottom: 1px solid var(--border-color);
	padding-bottom: 10px;
}

.setting-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 0;
}

.action-button {
	padding: 8px 16px;
	font-size: 0.9rem;
	font-weight: bold;
	cursor: pointer;
	border: 1px solid var(--border-color);
	border-radius: 6px;
	transition: background-color 0.2s, color 0.2s;
	background-color: var(--card-bg);
	color: var(--text-color);
}

.action-button.active {
	background-color: var(--primary-accent);
	color: white;
	border-color: var(--primary-accent);
}

.action-button:not(.active):hover {
	background-color: var(--primary-accent);
	color: white;
	border-color: var(--primary-accent);
}

.action-button.disabled {
	background-color: #e0e0e0;
	color: #a0a0a0;
	border-color: #e0e0e0;
	cursor: not-allowed;
	pointer-events: none;
}

body.dark-mode .action-button {
	background-color: #333;
}

body.dark-mode .action-button:not(.active):hover {
	background-color: var(--primary-accent);
	color: white;
}

body.dark-mode .action-button.active {
	background-color: var(--primary-accent);
	color: white;
}

.button-group {
	display: flex;
}

.button-group .action-button {
	padding: 8px 12px;
	border-radius: 0;
}

.button-group .action-button:first-child {
	border-top-left-radius: 6px;
	border-bottom-left-radius: 6px;
}

.button-group .action-button:last-child {
	border-top-right-radius: 6px;
	border-bottom-right-radius: 6px;
}

.profile-info-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	margin-bottom: 20px;
}

.profile-pic-modal {
	width: 100px;
	height: 100px;
	border-radius: 50%;
	border: 4px solid var(--primary-accent);
	margin-bottom: 10px;
}

#profile-modal-name {
	font-size: 1.5rem;
	margin: 0;
}

#profile-modal-grade {
	font-size: 1rem;
	color: var(--text-muted);
	margin: 5px 0 0 0;
}

/* Glass Theme styles */
body.glass-on .time-card,
body.glass-on .day-schedule-card-container,
body.glass-on form,
body.glass-on .logout-menu,
body.glass-on .modal-content,
body.glass-on .settings-btn,
body.glass-on .action-button {
	position: relative;
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(20px) saturate(180%);
	border: 1px solid rgba(255, 255, 255, 0.8);
	box-shadow: 0 8px 32px rgba(31, 38, 135, 0.2), inset 0 4px 20px rgba(255, 255, 255, 0.3);
	transition: all 0.3s ease;
}

body.glass-on.dark-mode .time-card,
body.glass-on.dark-mode .day-schedule-card-container,
body.glass-on.dark-mode form,
body.glass-on.dark-mode .logout-menu,
body.glass-on.dark-mode .modal-content,
body.glass-on.dark-mode .settings-btn,
body.glass-on.dark-mode .action-button {
	background: rgba(30, 30, 30, 0.15);
	border-color: rgba(60, 60, 60, 0.8);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 4px 20px rgba(255, 255, 255, 0.1);
}

body.glass-on .time-card::after,
body.glass-on .day-schedule-card-container::after,
body.glass-on form::after,
body.glass-on .logout-menu::after,
body.glass-on .modal-content::after,
body.glass-on .settings-btn::after,
body.glass-on .action-button::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(255, 255, 255, 0.1);
	border-radius: inherit;
	backdrop-filter: blur(1px);
	box-shadow: inset -10px -8px 0px -11px rgba(255, 255, 255, 1), inset 0px -9px 0px -8px rgba(255, 255, 255, 1);
	opacity: 0.6;
	z-index: -1;
	filter: blur(1px) drop-shadow(10px 4px 6px black) brightness(115%);
}

body.glass-on.dark-mode .time-card::after,
body.glass-on.dark-mode .day-schedule-card-container::after,
body.glass-on.dark-mode form::after,
body.glass-on.dark-mode .logout-menu::after,
body.glass-on.dark-mode .modal-content::after,
body.glass-on.dark-mode .settings-btn::after,
body.glass-on.dark-mode .action-button::after {
	background: rgba(255, 255, 255, 0.05);
	box-shadow: inset -10px -8px 0px -11px rgba(255, 255, 255, 0.5), inset 0px -9px 0px -8px rgba(255, 255, 255, 0.5);
	filter: blur(1px) drop-shadow(10px 4px 6px #000) brightness(115%);
}

/* --- Mobile Header and Layout --- */
#mobile-header {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	padding: 10px 15px;
	background-color: var(--card-bg);
	box-shadow: var(--shadow);
	z-index: 999;
	align-items: center;
	gap: 15px;
}

#mobile-header #page-title {
	flex-grow: 1;
	text-align: center;
	margin: 0;
	font-size: 1.2rem;
	color: var(--primary-accent);
}

.menu-toggle {
	background: none;
	border: none;
	font-size: 1.5rem;
	color: var(--text-color);
	cursor: pointer;
	padding: 0;
}

/* --- Main Content Layout --- */
#main-content {
	flex-grow: 1;
	padding: 20px;
	width: 100%;
	max-width: 800px;
	margin: 0 auto;
}

.content-wrapper {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.content-section {
	display: none;
	animation: fadeIn 0.5s ease-in-out;
}

.content-section.active {
	display: block;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

h2 {
	color: var(--primary-accent);
	border-bottom: 2px solid var(--primary-accent);
	padding-bottom: 5px;
	margin-top: 0;
}

/* --- Schedule View --- */
#status-message {
	display: flex;
	justify-content: space-between;
	gap: 15px;
	margin-bottom: 20px;
	flex-wrap: wrap;
}

.time-card {
	background-color: var(--card-bg);
	border-radius: 12px;
	padding: 15px 20px;
	box-shadow: var(--shadow);
	flex-grow: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-width: 250px;
}

#live-clock {
	font-size: 1.8rem;
	font-weight: 700;
	white-space: nowrap;
	color: var(--primary-accent);
	text-align: center;
}

#class-status-card {
	align-items: center;
}

#status-text {
	font-size: 1.2rem;
	font-weight: 700;
	text-align: center;
}

#time-left-bar-container {
	width: 100%;
	height: 10px;
	background-color: var(--border-color);
	border-radius: 5px;
	overflow: hidden;
	margin-top: 8px;
}

#time-left-bar {
	height: 100%;
	background-color: var(--secondary-accent);
	width: 0;
	transition: width 1s linear;
}

#schedule-today {
	margin-bottom: 20px;
}

#schedule-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 16px;
	padding: 0;
	list-style: none;
}

.day-schedule-card-container {
	flex-shrink: 0;
	background-color: var(--card-bg);
	border: 1px solid var(--border-color);
	border-radius: 12px;
	padding: 20px;
	box-shadow: var(--shadow);
	transition: transform 0.2s ease-in-out;
	position: relative; /* Add position relative for pseudo-element */
}

/* New CSS for the bar colors */
.day-schedule-card-container::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 6px;
	height: 100%;
	border-top-left-radius: 12px;
	border-bottom-left-radius: 12px;
	transition: background-color 0.3s ease;
}

.day-schedule-card-container.today::before {
	background-color: var(--secondary-accent);
}

.day-schedule-card-container.blue-day::before {
	background-color: var(--blue-day-color);
}

.day-schedule-card-container.gold-day::before {
	background-color: var(--gold-day-color);
}

.day-schedule-card-container.today {
	box-shadow: 0 0 15px rgba(255, 193, 7, 0.4);
}

body.dark-mode .day-schedule-card-container.today {
	box-shadow: 0 0 15px rgba(255, 235, 59, 0.4);
}

.day-schedule-card-container:hover {
	transform: translateY(-2px);
}

.day-schedule-card-container h3 {
	margin-top: 0;
	color: var(--primary-accent);
	font-size: 1.2rem;
}

.day-schedule-card-container.today h3 {
	color: var(--secondary-accent);
}

.schedule-block {
	background-color: var(--block-bg);
	border: 1px solid var(--block-border-color);
	border-left: 5px solid var(--primary-accent);
	border-radius: 8px;
	padding: 15px;
	margin-bottom: 12px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.schedule-block.current {
	background-color: var(--live-block-bg);
	border-left: 5px solid var(--secondary-accent);
	animation: pulse 1s infinite alternate;
}

body.dark-mode .schedule-block.current {
	animation: pulse-dark 1s infinite alternate;
}

@keyframes pulse {
	from {
		box-shadow: 0 0 0 0 rgba(0, 172, 193, 0.4);
	}

	to {
		box-shadow: 0 0 0 10px rgba(0, 172, 193, 0);
	}
}

@keyframes pulse-dark {
	from {
		box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.4);
	}

	to {
		box-shadow: 0 0 0 10px rgba(0, 229, 255, 0);
	}
}

.schedule-block h4 {
	margin: 0 0 5px 0;
	color: var(--text-color);
}

.schedule-block p {
	margin: 0;
	font-size: 0.9em;
	color: var(--text-muted);
}

.special-event-card {
	background-color: var(--block-bg);
	border: 1px solid var(--block-border-color);
	border-left: 5px solid var(--warning-accent);
	border-radius: 8px;
	padding: 15px;
	font-weight: bold;
	color: var(--text-color);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.special-event-card h4 {
	color: var(--warning-accent);
}

.navigation-buttons,
.settings-buttons {
	display: flex;
	justify-content: space-between;
	margin-top: 20px;
}

.navigation-buttons button,
.settings-btn {
	padding: 10px 20px;
	font-size: 1rem;
	cursor: pointer;
	background-color: var(--primary-accent);
	color: white;
	border: none;
	border-radius: 8px;
	transition: background-color 0.2s, transform 0.2s;
}

.navigation-buttons button:hover,
.settings-btn:hover {
	background-color: var(--primary-accent-dark);
	transform: translateY(-2px);
}

.clear-btn {
	background-color: #e53935;
}

.clear-btn:hover {
	background-color: #c62828;
}

#prev-btn {
	background-color: #607d8b;
}

#prev-btn:hover {
	background-color: #455a64;
}

/* --- Modal Close Buttons --- */
.close-button {
	color: #aaa;
	font-size: 28px;
	font-weight: bold;
	cursor: pointer;
	transition: color 0.2s;
	position: absolute;
	top: 10px;
	right: 15px;
}

.close-button:hover,
.close-button:focus {
	color: var(--text-color);
	text-decoration: none;
	cursor: pointer;
}

hr {
	border: 0;
	border-top: 1px solid var(--border-color);
	margin: 20px 0;
}

#modal-settings-container hr {
	border-color: var(--primary-accent);
}

#ics-import-section textarea {
	min-height: 150px;
}

/* --- Mobile Specific Styles --- */
.user-profile-container.mobile-header-profile {
	position: relative;
}

.mobile-header-profile .logout-menu {
	/* Override default dropdown position for mobile header */
	top: 60px;
	right: 15px;
	min-width: 150px;
}

/* --- Media Queries --- */
@media (max-width: 768px) {
	body {
		padding-top: 67px;
		flex-direction: column;
	}

	#mobile-header {
		display: flex;
	}

	#sidebar {
		width: 100%;
		top: 67px;
		left: 0;
		height: calc(100% - 67px);
		box-shadow: none;
		border-top: 1px solid var(--border-color);
		transform: translateX(-100%);
	}

	#sidebar.open {
		transform: translateX(0);
	}

	#main-content {
		padding: 15px;
	}

	/* Show the sidebar profile on mobile */
	.user-profile-container.sidebar-profile {
		display: block;
		position: static;
		margin: 0;
	}

	/* Hide the desktop profile on mobile */
	.user-profile-container.desktop-header-profile {
		display: none;
	}
}

@media (min-width: 769px) {
	body {
		flex-direction: row;
		padding-top: 0;
	}

	#sidebar {
		transform: translateX(0);
		position: sticky;
		height: 100vh;
		top: 0;
	}

	#main-content {
		margin-left: 250px;
		width: calc(100% - 250px);
		padding: 20px;
		margin: 20px auto;
	}

	.content-wrapper {
		max-width: 800px;
		margin: 0 auto;
	}

	#mobile-header {
		display: none;
	}

	/* Hide the sidebar profile on desktop */
	.user-profile-container.sidebar-profile {
		display: none;
	}

	/* Show and position the desktop profile */
	.user-profile-container.desktop-header-profile {
		display: flex;
		position: fixed;
		top: 20px;
		right: 20px;
	}
}

/* Add this rule to your stylesheet to give the home link a consistent look */
.nav-link.home-link {
	display: flex;
	align-items: center;
	gap: 15px;
	padding: 12px 15px;
	text-decoration: none;
	color: var(--text-color);
	font-weight: 700;
	border-radius: 8px;
	transition: background-color 0.2s, color 0.2s;
	margin-bottom: 5px; /* Add some spacing below it */
}

/* Ensure hover state works */
.nav-link.home-link:hover {
	background-color: var(--hover-background);
	color: var(--text-color); /* Maintain text color unless it's a special active state */
}

body.dark-mode .nav-link.home-link:hover {
	background-color: #333;
	color: #e0e0e0;
}