/* ======================================== */
/* 1. Font Definitions                      */
/* ======================================== */
@font-face {
	font-family: "Imprima";
	src: url("../assets/fonts/Imprima-Regular.ttf") format("truetype");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Klee One";
	src: url("../assets/fonts/KleeOne-Regular.ttf") format("truetype");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Klee One";
	src: url("../assets/fonts/KleeOne-SemiBold.ttf") format("truetype");
	font-weight: 600;
	font-style: normal;
	font-display: swap;
}

/* ======================================== */
/* 2. Variables (Unified)                   */
/* ======================================== */
:root {
	--bg: #f0f2f5;
	--card: #ffffff;
	--text: #1c1e21;
	--primary: #0078d4;
	--border: #ddd;
	--accent: #e7f3ff;
	--sidebar-bg: #f8f9fa;
	--danger: #dc3545;
	--success: #28a745;
	--theme-transition: all 0.2s ease;
	--popover-bg: #333333;
}

.dark-mode {
	--bg: #121212;
	--card: #1e1e1e;
	--text: #e0e0e0;
	--border: #444;
	--accent: #2c3e50;
	--sidebar-bg: #181818;
	--popover-bg: #000000;
}

/* ======================================== */
/* 3. Full Screen App Shell Layout         */
/* ======================================== */
body,
html {
	height: 100%;
	min-height: 800px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	font-family: "Imprima", sans-serif;
	background: var(--bg);
	color: var(--text);
	transition: var(--theme-transition);
}

.app-shell {
	display: flex;
	flex-direction: row;
	height: 100vh;
	overflow: hidden;
}

.content-container {
	flex: 1;
	padding: 2rem;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 25px;
}

/* ======================================== */
/* 4. Sidebar & History                     */
/* ======================================== */
.sidebar {
	width: 320px;
	background: var(--sidebar-bg);
	border-left: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	padding: 1.5rem;
	overflow-y: auto;
	position: relative;
}

.score-badge {
	font-size: 0.75rem;
	font-weight: bold;
	padding: 2px 8px;
	border-radius: 12px;
	color: white;
	margin-left: 10px;
	min-width: 40px;
	text-align: center;
}

.sidebar-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1rem;
	gap: 10px;
}

.history-list {
	flex: 1;
	overflow-y: auto;
	padding-bottom: 60px; /* Room for floating image */
}

.history-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px;
	border-bottom: 1px solid var(--border);
	cursor: pointer;
	border-radius: 8px;
	margin-bottom: 6px;
	background: var(--card);
	transition:
		transform 0.2s ease,
		background 0.2s ease;
}

.history-item:hover {
	background: var(--accent);
	transform: translateX(-3px);
}

/* ======================================== */
/* 5. Inputs & Components                   */
/* ======================================== */
.header-flex {
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.brand {
	display: flex;
	align-items: center;
	gap: 15px;
}
.app-logo {
	width: 50px;
	height: 50px;
	border-radius: 12px;
	object-fit: cover;
}

.top-controls {
	display: flex;
	gap: 10px;
	align-items: center;
}

select,
#theme-toggle {
	background: var(--card);
	color: var(--text);
	border: 1px solid var(--border);
	padding: 8px 12px;
	border-radius: 8px;
	font-family: "Imprima", sans-serif;
	cursor: pointer;
}

textarea,
#textToPractice {
	display: block;
	font-family: "Klee One", sans-serif;
	width: 90%;
	min-height: 160px;
	padding: 1.2rem;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: var(--card);
	color: var(--text);
	font-size: 1.2rem;
	resize: none;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
	margin: 0 1rem;
	outline: none;
}

/* ======================================== */
/* 6. Translation Popover (NEW)             */
/* ======================================== */
#globalPopover {
	position: absolute;
	background: var(--popover-bg);
	color: white;
	padding: 6px 12px;
	border-radius: 8px;
	font-size: 0.9rem;
	pointer-events: none; /* Prevents flickering */
	z-index: 10000;
	transition: opacity 0.2s ease;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
	display: none;
	/* white-space: nowrap; */
	max-width: 200px;
	white-space: normal; /* Allow text to wrap if the translation is long */
	text-align: center;
	line-height: 1.4;
}

/* Small arrow for popover */
#globalPopover::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -5px;
	border-width: 5px;
	border-style: solid;
	border-color: var(--popover-bg) transparent transparent transparent;
}

/* Practice Mode Word Styling */
.word,
.word-span {
	cursor: help;
	padding: 0 2px;
	transition: all 0.2s;
	border-radius: 3px;
	display: inline-block;
}

.word:hover,
.word-span:hover {
	background-color: rgba(0, 120, 212, 0.1);
	color: var(--primary);
	text-decoration: underline;
}

/* ======================================== */
/* 7. Feedback & Colors                     */
/* ======================================== */
.word-correct {
	color: var(--success) !important;
	font-weight: bold;
}
.word-missed {
	color: var(--danger) !important;
	text-decoration: line-through;
	cursor: pointer;
}

.word-span.highlight {
	background-color: #ffeb3b !important;
	color: #000 !important;
}

/* ======================================== */
/* 8. Floating Image                        */
/* ======================================== */
#floating-image {
	position: absolute;
	bottom: 10px;
	right: 10px;
	width: auto;
	height: 150px;
	transform: scaleX(-1);
	opacity: 0.6;
	transition:
		opacity 0.3s ease,
		transform 0.3s ease;
	z-index: 5;
}

#floating-image:hover {
	opacity: 1;
	transform: scaleX(-1.05) scaleY(1.05);
}

/* ======================================== */
/* 9. Action Bar & Buttons                  */
/* ======================================== */
.action-bar,
.controls-row {
	display: flex;
	width: 90%;
	gap: 20px;
	margin: 1rem;
}

button {
	font-family: "Imprima", sans-serif;
	padding: 12px 20px;
	border-radius: 10px;
	border: none;
	font-weight: 600;
	cursor: pointer;
	transition: var(--theme-transition);
	background: var(--border);
	color: var(--text);
}

.btn-primary {
	background: var(--primary);
	color: white;
}
.btn-danger {
	background: var(--danger);
	color: white;
}
.btn-clear {
	background: transparent;
	border: 1px solid var(--border);
	padding: 5px 10px;
	font-size: 0.8rem;
}

button:hover {
	filter: brightness(90%);
}

/* ======================================== */
/* 10. Animations & Loading                 */
/* ======================================== */

#waveformCanvas {
	width: 90%;
	height: 80px;
	border-radius: 12px;
	margin: 0 1rem;
	color: var(--bg);
}

#loadingScanner {
	text-align: center;
	margin: 20px 0;
	padding: 20px;
	background: rgba(76, 175, 80, 0.1);
	border-radius: 8px;
	border: 1px solid var(--border);
}

.scanner-line {
	height: 4px;
	width: 100%;
	background: #4caf50;
	position: relative;
	overflow: hidden;
	border-radius: 10px;
}

.scanner-line::after {
	content: "";
	display: block;
	height: 100%;
	width: 30%;
	background: white;
	box-shadow: 0 0 15px 5px #4caf50;
	position: absolute;
	animation: scan 1.5s infinite linear;
}

@keyframes scan {
	0% {
		left: -30%;
	}
	100% {
		left: 100%;
	}
}

/* ======================================== */
/* 11. Mobile Responsiveness                */
/* ======================================== */
@media (max-width: 900px) {
	body,
	html {
		overflow: auto;
		height: auto;
	}
	.app-shell {
		flex-direction: column;
		height: auto;
	}
	.sidebar {
		width: 100%;
		border-left: none;
		border-top: 1px solid var(--border);
	}
	.content-container {
		padding: 1rem;
	}
	.action-bar,
	.controls-row {
		flex-wrap: wrap;
		width: 100%;
		margin: 1rem 0;
	}
}
