/*
Theme Name: Audio Theme
Theme URI: https://audio-tien-hiep.local
Author: Audio Tien Hiep
Description: Spotify-inspired dark theme for Vietnamese audiobook streaming.
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: license.txt
Text Domain: audio-theme
*/

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
	--bg-base: #121212;
	--bg-surface: #181818;
	--bg-hover: #282828;
	--bg-highlight: #333333;
	--accent: #1DB954;
	--accent-hover: #1ed760;
	--text-primary: #FFFFFF;
	--text-secondary: #B3B3B3;
	--text-subdued: #6A6A6A;
	--sidebar-width: 240px;
	--player-height: 90px;
	--player-height-mobile: 64px;
	--radius-sm: 4px;
	--radius-md: 8px;
	--radius-lg: 12px;
}

/* Light theme override */
[data-theme="light"] {
	--bg-base: #FFFFFF;
	--bg-surface: #F5F5F5;
	--bg-hover: #E8E8E8;
	--bg-highlight: #DDDDDD;
	--accent: #1DB954;
	--accent-hover: #1aa34a;
	--text-primary: #191414;
	--text-secondary: #535353;
	--text-subdued: #999999;
}

[data-theme="light"] .player-bar__play-btn {
	background: var(--text-primary);
	color: #FFFFFF;
}

[data-theme="light"] .progress-bar {
	background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .player-bar__volume-slider {
	background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .player-bar__dropdown {
	box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .sidebar {
	border-right-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .bottom-nav {
	border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .player-bar {
	border-top-color: rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

html {
	font-size: 16px;
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
}

body {
	background: var(--bg-base);
	color: var(--text-primary);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: 0.875rem;
	line-height: 1.5;
	overflow: hidden;
}

a {
	color: inherit;
	text-decoration: none;
}

a:hover {
	color: var(--text-primary);
}

img {
	max-width: 100%;
	height: auto;
	display: block;
}

ul, ol {
	list-style: none;
}

button {
	background: none;
	border: none;
	color: inherit;
	cursor: pointer;
	font: inherit;
	padding: 0;
}

input[type="text"],
input[type="search"],
input[type="url"],
input[type="email"],
textarea {
	background: var(--bg-highlight);
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	color: var(--text-primary);
	font: inherit;
	padding: 8px 12px;
	outline: none;
}

input[type="text"]:focus,
input[type="search"]:focus {
	border-color: var(--text-secondary);
}

[x-cloak] {
	display: none !important;
}

/* ==========================================================================
   App Shell - CSS Grid 3-Zone Layout
   ========================================================================== */

.app-shell {
	display: grid;
	grid-template-columns: var(--sidebar-width) 1fr;
	grid-template-rows: 1fr;
	grid-template-areas:
		"sidebar main";
	height: 100vh;
	width: 100vw;
	overflow: hidden;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
	grid-area: sidebar;
	background: var(--bg-base);
	overflow-y: auto;
	padding: 0;
	border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-nav {
	padding: 16px;
}

.sidebar-nav__logo {
	margin-bottom: 24px;
}

.sidebar-nav__logo a {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--text-primary);
	font-weight: 700;
	font-size: 1.1rem;
}

.sidebar-nav__links {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 16px;
}

.sidebar-nav__link {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 8px 12px;
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	font-weight: 600;
	font-size: 0.875rem;
	transition: color 0.2s, background 0.2s;
}

.sidebar-nav__link:hover {
	color: var(--text-primary);
}

.sidebar-nav__link.is-active {
	color: var(--text-primary);
}

.sidebar-nav__divider {
	border: none;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
	margin: 8px 0 16px;
}

.sidebar-nav__section-title {
	color: var(--text-secondary);
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	margin-bottom: 12px;
	padding: 0 12px;
}

.sidebar-nav__genre-list {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.sidebar-nav__genre-link {
	display: block;
	padding: 6px 12px;
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	font-size: 0.8125rem;
	transition: color 0.2s, background 0.2s;
}

.sidebar-nav__genre-link:hover {
	color: var(--text-primary);
	background: var(--bg-hover);
}

/* ==========================================================================
   Main View
   ========================================================================== */

.main-view {
	grid-area: main;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 24px;
	padding-bottom: calc(var(--player-height) + 24px);
	background: var(--bg-surface);
}

/* ==========================================================================
   Player Bar
   ========================================================================== */

.player-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 100;
	display: grid;
	grid-template-columns: 1fr 2fr auto 1fr;
	align-items: center;
	padding: 8px 16px;
	background: var(--bg-highlight);
	border-top: 1px solid rgba(255, 255, 255, 0.05);
	min-height: var(--player-height);
}

.player-bar__track {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}

.player-bar__cover {
	width: 56px;
	height: 56px;
	border-radius: var(--radius-sm);
	object-fit: cover;
	flex-shrink: 0;
	background: var(--bg-hover);
}

.player-bar__yt-container {
	width: 200px;
	height: 113px;
	border-radius: var(--radius-sm);
	overflow: hidden;
	flex-shrink: 0;
	background: #000;
}

.player-bar__yt-container iframe {
	width: 100%;
	height: 100%;
	border: 0;
}

.player-bar__track-info {
	min-width: 0;
}

.player-bar__title {
	color: var(--text-primary);
	font-size: 0.8125rem;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.player-bar__subtitle {
	color: var(--text-secondary);
	font-size: 0.6875rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.player-bar__center {
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: 600px;
	margin: 0 auto;
	width: 100%;
	gap: 4px;
}

.player-bar__controls {
	display: flex;
	align-items: center;
	gap: 16px;
}

.player-bar__btn {
	color: var(--text-secondary);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.2s, transform 0.1s;
}

.player-bar__btn:hover {
	color: var(--text-primary);
	transform: scale(1.1);
}

.player-bar__play-btn {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--text-primary);
	color: var(--bg-base);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.1s;
}

.player-bar__play-btn:hover {
	transform: scale(1.06);
}

.player-bar__progress {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
}

.player-bar__time {
	color: var(--text-subdued);
	font-size: 0.6875rem;
	min-width: 40px;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.progress-bar {
	flex: 1;
	height: 4px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 2px;
	cursor: pointer;
	position: relative;
	transition: height 0.1s;
}

.progress-bar:hover {
	height: 6px;
}

.progress-bar__fill {
	height: 100%;
	background: var(--accent);
	border-radius: 2px;
	position: relative;
	transition: width 0.1s linear;
}

.progress-bar:hover .progress-bar__fill {
	background: var(--accent-hover);
}

.player-bar__volume {
	display: flex;
	align-items: center;
	gap: 8px;
	justify-content: flex-end;
}

.player-bar__volume-slider {
	-webkit-appearance: none;
	appearance: none;
	width: 100px;
	height: 4px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 2px;
	outline: none;
	cursor: pointer;
}

.player-bar__volume-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--text-primary);
	cursor: pointer;
}

.player-bar__volume-slider::-moz-range-thumb {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--text-primary);
	border: none;
	cursor: pointer;
}

.player-bar__speed-btn {
	color: var(--text-secondary);
	font-size: 0.75rem;
	font-weight: 600;
	padding: 2px 8px;
	border: 1px solid var(--text-subdued);
	border-radius: 12px;
	background: transparent;
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s;
	white-space: nowrap;
}

.player-bar__speed-btn:hover {
	color: var(--text-primary);
	border-color: var(--text-primary);
}

/* Skip forward/backward buttons */
.player-bar__skip-btn {
	position: relative;
}

.player-bar__skip-label {
	position: absolute;
	font-size: 0.5rem;
	font-weight: 700;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	margin-top: 1px;
	pointer-events: none;
}

/* Dropdown menus for speed & sleep timer */
.player-bar__dropdown-wrap {
	position: relative;
}

.player-bar__dropdown {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	background: var(--bg-highlight);
	border-radius: var(--radius-md);
	box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
	padding: 4px 0;
	min-width: 80px;
	margin-bottom: 8px;
	z-index: 110;
}

.player-bar__dropdown-item {
	display: block;
	width: 100%;
	padding: 6px 16px;
	text-align: center;
	color: var(--text-secondary);
	font-size: 0.8125rem;
	font-weight: 500;
	background: none;
	border: none;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s, color 0.15s;
}

.player-bar__dropdown-item:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.player-bar__dropdown-item.is-active {
	color: var(--accent);
	font-weight: 700;
}

.player-bar__dropdown-item--cancel {
	color: #e74c3c;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
	margin-top: 4px;
	padding-top: 8px;
}

.player-bar__dropdown-item--cancel:hover {
	color: #ff6b6b;
}

/* Sleep timer button */
.player-bar__sleep-btn {
	color: var(--text-secondary);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4px;
	border-radius: var(--radius-sm);
	transition: color 0.15s;
	cursor: pointer;
	background: none;
	border: none;
}

.player-bar__sleep-btn:hover {
	color: var(--text-primary);
}

.player-bar__sleep-btn.is-active {
	color: var(--accent);
}

.player-bar__sleep-countdown {
	font-size: 0.6875rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.player-bar__extras {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 12px;
}

/* Chapter list actions row */
.chapter-list__actions {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 24px 0 16px;
	flex-wrap: wrap;
}

.btn-resume {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 20px;
	font-size: 0.875rem;
	font-weight: 600;
	background: transparent;
	color: var(--accent);
	border: 1px solid var(--accent);
	border-radius: 24px;
	cursor: pointer;
	transition: background 0.2s, color 0.2s;
}

.btn-resume:hover {
	background: var(--accent);
	color: var(--bg-base);
}

.btn-resume__detail {
	font-weight: 400;
	font-size: 0.75rem;
	opacity: 0.8;
}

/* ==========================================================================
   Card Grid & Cards
   ========================================================================== */

.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 24px;
}

.card-truyen {
	display: block;
	padding: 12px;
	border-radius: var(--radius-md);
	background: rgba(255, 255, 255, 0.03);
	transition: background 0.2s, transform 0.2s;
}

.card-truyen:hover {
	background: var(--bg-hover);
	transform: translateY(-2px);
}

.card-truyen__cover {
	position: relative;
	width: 100%;
	aspect-ratio: 1;
	border-radius: var(--radius-sm);
	overflow: hidden;
	margin-bottom: 12px;
	background: var(--bg-highlight);
}

.card-truyen__cover img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Placeholder cover images use inline SVGs with #282828 bg. */

.card-truyen__play-btn {
	position: absolute;
	bottom: 8px;
	right: 8px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--accent);
	color: var(--bg-base);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.2s, transform 0.2s;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.card-truyen:hover .card-truyen__play-btn {
	opacity: 1;
	transform: translateY(0);
}

.card-truyen__play-btn:hover {
	background: var(--accent-hover);
	transform: scale(1.06);
}

.card-truyen__title {
	color: var(--text-primary);
	font-size: 0.875rem;
	font-weight: 600;
	margin-bottom: 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.card-truyen__author {
	color: var(--text-secondary);
	font-size: 0.75rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Horizontal scrolling card row */
.card-row {
	display: flex;
	gap: 16px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 8px;
}

.card-row::-webkit-scrollbar {
	height: 0;
}

.card-row .card-truyen {
	min-width: 160px;
	max-width: 180px;
	scroll-snap-align: start;
	flex-shrink: 0;
}

/* ==========================================================================
   Section Headers
   ========================================================================== */

.section-header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 16px;
}

.section-header__title {
	color: var(--text-primary);
	font-size: 1.375rem;
	font-weight: 700;
}

.section-header__link {
	color: var(--text-secondary);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.section-header__link:hover {
	text-decoration: underline;
}

.content-section {
	margin-bottom: 40px;
}

/* ==========================================================================
   Truyen Detail Page
   ========================================================================== */

.truyen-detail {
	display: flex;
	gap: 32px;
	margin-bottom: 32px;
}

.truyen-detail__cover {
	width: 232px;
	height: 232px;
	border-radius: var(--radius-md);
	object-fit: cover;
	flex-shrink: 0;
	box-shadow: 0 4px 60px rgba(0, 0, 0, 0.5);
}

.truyen-detail__info {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
}

.truyen-detail__type {
	color: var(--text-primary);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	margin-bottom: 4px;
}

.truyen-detail__title {
	color: var(--text-primary);
	font-size: 2.5rem;
	font-weight: 900;
	line-height: 1.1;
	margin-bottom: 12px;
}

.truyen-detail__meta {
	color: var(--text-secondary);
	font-size: 0.8125rem;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 16px;
	align-items: center;
}

.truyen-detail__meta strong {
	color: var(--text-primary);
}

/* Status badge */
.status-badge {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 12px;
	font-size: 0.6875rem;
	font-weight: 600;
	text-transform: uppercase;
}

.status-badge--ongoing {
	background: rgba(29, 185, 84, 0.2);
	color: var(--accent);
}

.status-badge--completed {
	background: rgba(30, 144, 255, 0.2);
	color: #1e90ff;
}

.status-badge--hiatus {
	background: rgba(255, 255, 255, 0.1);
	color: var(--text-secondary);
}

/* Play all button */
.btn-play-all {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 32px;
	border-radius: 24px;
	background: var(--accent);
	color: var(--bg-base);
	font-size: 0.875rem;
	font-weight: 700;
	transition: background 0.2s, transform 0.1s;
}

.btn-play-all:hover {
	background: var(--accent-hover);
	transform: scale(1.04);
}

/* Truyen description */
.truyen-description {
	color: var(--text-secondary);
	font-size: 0.875rem;
	line-height: 1.6;
	margin-top: 16px;
	max-width: 700px;
}

/* ==========================================================================
   Chapter List
   ========================================================================== */

.chapter-list {
	width: 100%;
}

.chapter-list__header {
	display: grid;
	grid-template-columns: 40px 1fr 100px 85px;
	gap: 16px;
	padding: 8px 16px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	color: var(--text-subdued);
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.btn-sort-toggle {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 6px 14px;
	font-size: 0.8rem;
	font-weight: 600;
	background: transparent;
	color: var(--text-secondary);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 24px;
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-sort-toggle:hover {
	color: var(--text-primary);
	border-color: var(--text-subdued);
}

.btn-sort-toggle:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.btn-sort-toggle.is-desc {
	color: var(--accent);
	border-color: var(--accent);
}

.btn-sort-toggle__icon {
	transition: transform 0.2s;
}

.btn-sort-toggle.is-desc .btn-sort-toggle__icon {
	transform: rotate(180deg);
}

.chapter-row {
	display: grid;
	grid-template-columns: 40px 1fr 100px 85px;
	gap: 16px;
	padding: 10px 16px;
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: background 0.15s;
	align-items: center;
}

.chapter-row:hover {
	background: var(--bg-hover);
}

.chapter-row__number {
	color: var(--text-secondary);
	font-size: 0.875rem;
	text-align: center;
}

.chapter-row__title {
	color: var(--text-primary);
	font-size: 0.875rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chapter-row__date {
	color: var(--text-subdued);
	font-size: 0.8125rem;
}

.chapter-row__duration {
	color: var(--text-subdued);
	font-size: 0.8125rem;
	text-align: right;
}

.chapter-row.is-playing .chapter-row__title {
	color: var(--accent);
}

.chapter-row.is-completed .chapter-row__number {
	color: var(--accent);
}

.chapter-row__check {
	display: inline-block;
	vertical-align: middle;
	margin-left: 2px;
}

/* Mini progress bar under chapter title */
.chapter-row__progress-mini {
	display: block;
	height: 3px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 2px;
	margin-top: 4px;
	width: 100%;
	max-width: 200px;
	overflow: hidden;
}

.chapter-row__progress-fill {
	display: block;
	height: 100%;
	background: var(--accent);
	border-radius: 2px;
}

/* Infinite scroll loading indicator */
.chapter-scroll-loader {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 16px;
	color: var(--text-subdued);
	font-size: 0.8125rem;
}

.chapter-scroll-loader__spinner {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.1);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: chapter-spin 0.6s linear infinite;
}

@keyframes chapter-spin {
	to { transform: rotate(360deg); }
}

/* Continue Listening cards */
.continue-listening-grid {
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 12px;
}

.card-continue {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 12px;
	border-radius: var(--radius-md);
	background: rgba(255, 255, 255, 0.03);
	transition: background 0.2s;
}

.card-continue:hover {
	background: var(--bg-hover);
}

.card-continue__cover {
	width: 48px;
	height: 48px;
	border-radius: var(--radius-sm);
	object-fit: cover;
	flex-shrink: 0;
}

.card-continue__info {
	flex: 1;
	min-width: 0;
}

.card-continue__title {
	color: var(--text-primary);
	font-size: 0.8125rem;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.card-continue__chapter {
	color: var(--text-secondary);
	font-size: 0.6875rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-bottom: 4px;
}

.card-continue__progress-bar {
	height: 3px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 2px;
	overflow: hidden;
}

.card-continue__progress-fill {
	height: 100%;
	background: var(--accent);
	border-radius: 2px;
}

.card-continue__play-btn {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--accent);
	color: var(--bg-base);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.2s, transform 0.1s;
}

.card-continue__play-btn:hover {
	background: var(--accent-hover);
	transform: scale(1.06);
}

/* Favorite heart button on cards */
.card-truyen__fav-btn {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: var(--text-secondary);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.2s, color 0.2s, transform 0.1s;
	z-index: 2;
}

.card-truyen:hover .card-truyen__fav-btn,
.card-truyen__fav-btn.is-active {
	opacity: 1;
}

.card-truyen__fav-btn.is-active {
	color: #e74c3c;
}

.card-truyen__fav-btn:hover {
	transform: scale(1.15);
}

/* Truyen detail action buttons (favorite + share) */
.truyen-detail__actions {
	display: flex;
	gap: 12px;
	margin-top: 16px;
	flex-basis: 100%;
}

.truyen-action-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border-radius: 20px;
	border: 1px solid var(--text-subdued);
	background: transparent;
	color: var(--text-secondary);
	font-size: 0.8125rem;
	font-weight: 500;
	cursor: pointer;
	transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.truyen-action-btn:hover {
	color: var(--text-primary);
	border-color: var(--text-primary);
}

.truyen-action-btn--fav.is-active {
	color: #e74c3c;
	border-color: #e74c3c;
}

/* Social share brand buttons */
.truyen-action-btn--facebook {
	text-decoration: none;
}
.truyen-action-btn--facebook:hover {
	color: #1877F2;
	border-color: #1877F2;
}
.truyen-action-btn--zalo {
	text-decoration: none;
}
.truyen-action-btn--zalo:hover {
	color: #0068FF;
	border-color: #0068FF;
}

/* ==========================================================================
   Star Rating (single-truyen actions)
   ========================================================================== */

.truyen-rating {
	display: inline-flex;
	align-items: center;
	gap: 2px;
}

.truyen-rating__star {
	background: none;
	border: none;
	padding: 2px;
	cursor: pointer;
	color: var(--text-subdued);
	transition: color 0.15s, transform 0.15s;
	line-height: 1;
}

.truyen-rating__star:hover:not(:disabled) {
	transform: scale(1.2);
}

.truyen-rating__star.is-filled {
	color: #FFD700;
}

.truyen-rating__star:disabled {
	cursor: default;
}

.truyen-rating__text {
	font-size: 0.75rem;
	color: var(--text-secondary);
	margin-left: 6px;
	white-space: nowrap;
}

/* Card compact rating */
.card-truyen__rating {
	color: #FFD700;
	font-size: 0.7rem;
	line-height: 1;
}

/* ==========================================================================
   Comments Section (truyen)
   ========================================================================== */

.truyen-comments {
	background: var(--bg-surface);
	border-radius: var(--radius-lg);
	padding: 24px;
	margin-top: 24px;
}

.truyen-comments__title {
	font-size: 1.25rem;
	color: var(--text-primary);
	margin: 0 0 20px;
}

.truyen-comments__closed {
	color: var(--text-subdued);
	font-style: italic;
}

/* Individual comment */
.truyen-comment {
	margin-bottom: 16px;
}

.truyen-comment .children {
	margin-left: 24px;
	padding-left: 16px;
	border-left: 2px solid var(--bg-hover);
}

.truyen-comment__body {
	display: flex;
	gap: 12px;
}

.truyen-comment__avatar img {
	border-radius: 50%;
}

.truyen-comment__content {
	flex: 1;
	min-width: 0;
	background: var(--bg-hover);
	border-radius: var(--radius-md);
	padding: 12px 16px;
}

.truyen-comment__meta {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 6px;
}

.truyen-comment__author {
	color: var(--text-primary);
	font-size: 0.875rem;
}

.truyen-comment__date {
	color: var(--text-subdued);
	font-size: 0.75rem;
}

.truyen-comment__text {
	color: var(--text-secondary);
	font-size: 0.875rem;
	line-height: 1.5;
}

.truyen-comment__text p {
	margin: 0;
}

.truyen-comment__reply a {
	color: var(--accent);
	font-size: 0.75rem;
	text-decoration: none;
	margin-top: 6px;
	display: inline-block;
}

.truyen-comment__reply a:hover {
	text-decoration: underline;
}

/* Comment form */
.truyen-comments .comment-respond {
	margin-top: 24px;
}

.truyen-comments .comment-reply-title {
	font-size: 1.1rem;
	color: var(--text-primary);
	margin: 0 0 16px;
}

.truyen-comments .comment-reply-title small {
	margin-left: 8px;
}

.truyen-comments .comment-reply-title small a {
	color: var(--accent);
	text-decoration: none;
}

.truyen-comments .comment-form p {
	margin-bottom: 12px;
}

.truyen-comments .comment-form label {
	display: block;
	color: var(--text-secondary);
	font-size: 0.8125rem;
	margin-bottom: 4px;
}

.truyen-comments .comment-form input[type="text"],
.truyen-comments .comment-form input[type="email"],
.truyen-comments .comment-form textarea {
	width: 100%;
	padding: 10px 12px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--text-subdued);
	background: var(--bg-base);
	color: var(--text-primary);
	font-size: 0.875rem;
	font-family: inherit;
	transition: border-color 0.2s;
}

.truyen-comments .comment-form input:focus,
.truyen-comments .comment-form textarea:focus {
	border-color: var(--accent);
	outline: none;
}

.truyen-comments .comment-form .required {
	color: #e74c3c;
}

.truyen-comments .comment-form .form-submit input[type="submit"] {
	padding: 10px 24px;
	border-radius: 20px;
	border: none;
	background: var(--accent);
	color: #fff;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
}

.truyen-comments .comment-form .form-submit input[type="submit"]:hover {
	background: var(--accent-hover);
}

/* Comments navigation */
.comment-navigation {
	display: flex;
	justify-content: space-between;
	margin: 16px 0;
	font-size: 0.8125rem;
}

.comment-navigation a {
	color: var(--accent);
	text-decoration: none;
}

.comment-navigation a:hover {
	text-decoration: underline;
}

/* ==========================================================================
   Genre Pills
   ========================================================================== */

.genre-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.genre-pill {
	display: inline-block;
	padding: 6px 16px;
	border-radius: 20px;
	background: var(--bg-hover);
	color: var(--text-primary);
	font-size: 0.8125rem;
	font-weight: 500;
	transition: background 0.2s;
}

.genre-pill:hover {
	background: var(--bg-highlight);
}

/* ==========================================================================
   Search
   ========================================================================== */

.sidebar-nav__search {
	position: relative;
}

.search-input-wrapper {
	position: relative;
	margin-bottom: 8px;
}

.search-input {
	box-sizing: border-box;
	width: 100%;
	padding: 8px 12px 8px 36px;
	border-radius: 20px;
	background: var(--bg-hover);
	border: 1px solid transparent;
	color: var(--text-primary);
	font-size: 0.8125rem;
	outline: none;
}

.search-input:focus {
	background: var(--bg-highlight);
	border-color: var(--text-secondary);
}

.search-input::placeholder {
	color: var(--text-subdued);
}

.search-dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: var(--bg-highlight);
	border-radius: var(--radius-md);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
	z-index: 100;
	overflow: hidden;
	margin-top: 4px;
}

.search-result-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 12px;
	transition: background 0.15s;
}

.search-result-item:hover {
	background: var(--bg-hover);
}

.search-result-item__cover {
	width: 40px;
	height: 40px;
	border-radius: var(--radius-sm);
	object-fit: cover;
	flex-shrink: 0;
}

.search-result-item__title {
	color: var(--text-primary);
	font-size: 0.8125rem;
}

/* ==========================================================================
   Hero / Featured Section
   ========================================================================== */

.hero-featured {
	position: relative;
	border-radius: var(--radius-lg);
	overflow: hidden;
	margin-bottom: 32px;
	min-height: 300px;
	display: flex;
	align-items: flex-end;
	padding: 32px;
	background: linear-gradient(135deg, var(--bg-hover), var(--bg-base));
}

.hero-featured__bg {
	position: absolute;
	inset: 0;
	object-fit: cover;
	width: 100%;
	height: 100%;
	opacity: 0.3;
}

.hero-featured__content {
	position: relative;
	z-index: 1;
}

.hero-featured__title {
	color: var(--text-primary);
	font-size: 3rem;
	font-weight: 900;
	line-height: 1.1;
	margin-bottom: 8px;
}

.hero-featured__author {
	color: var(--text-secondary);
	font-size: 0.875rem;
	margin-bottom: 16px;
}

/* ==========================================================================
   MC Profile (Narrator Archive)
   ========================================================================== */

.mc-profile {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 24px;
}

.mc-profile__avatar {
	width: 80px;
	height: 80px;
	border-radius: 50%;
	object-fit: cover;
}

.mc-profile__bio {
	color: var(--text-secondary);
	margin: 0;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin-top: 32px;
}

.pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 32px;
	height: 32px;
	padding: 0 8px;
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	font-size: 0.8125rem;
	transition: background 0.2s, color 0.2s;
}

.pagination .page-numbers:hover {
	background: var(--bg-hover);
	color: var(--text-primary);
}

.pagination .page-numbers.current {
	background: var(--text-primary);
	color: var(--bg-base);
}

/* ==========================================================================
   404 & Empty States
   ========================================================================== */

.empty-state {
	text-align: center;
	padding: 80px 24px;
}

.empty-state__title {
	color: var(--text-primary);
	font-size: 2rem;
	font-weight: 700;
	margin-bottom: 12px;
}

.empty-state__text {
	color: var(--text-secondary);
	font-size: 0.875rem;
	margin-bottom: 24px;
}

.empty-state__link {
	display: inline-block;
	padding: 12px 32px;
	border-radius: 24px;
	background: var(--text-primary);
	color: var(--bg-base);
	font-weight: 700;
	font-size: 0.875rem;
	transition: transform 0.1s;
}

.empty-state__link:hover {
	transform: scale(1.04);
	color: var(--bg-base);
}

/* ==========================================================================
   Bottom Nav (Mobile)
   ========================================================================== */

.bottom-nav {
	display: none;
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 99;
	justify-content: space-around;
	align-items: center;
	background: var(--bg-surface);
	border-top: 1px solid rgba(255, 255, 255, 0.05);
	padding: 4px 0;
	height: 56px;
}

.bottom-nav__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	color: var(--text-secondary);
	font-size: 0.625rem;
	padding: 4px 16px;
	transition: color 0.2s;
}

.bottom-nav__item:hover,
.bottom-nav__item.is-active {
	color: var(--text-primary);
}

/* Hamburger (hidden desktop) */
.hamburger-btn {
	display: none;
	position: fixed;
	top: 12px;
	left: 12px;
	z-index: 201;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--bg-highlight);
	align-items: center;
	justify-content: center;
	color: var(--text-primary);
}

/* Sidebar overlay */
.sidebar-overlay {
	display: none;
}

/* ==========================================================================
   AJAX Loading Bar
   ========================================================================== */

body::before {
	content: '';
	position: fixed;
	top: 0;
	left: 0;
	height: 3px;
	width: 0;
	background: var(--accent);
	z-index: 9999;
	transition: width 0.3s ease;
	pointer-events: none;
}

body.is-loading::before {
	width: 70%;
	transition: width 2s ease;
}

/* ==========================================================================
   Custom Scrollbar
   ========================================================================== */

.main-view::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
	width: 8px;
}

.main-view::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
	background: transparent;
}

.main-view::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.1);
	border-radius: 4px;
}

.main-view::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.2);
}

/* Firefox */
.main-view,
.sidebar {
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ==========================================================================
   Listening History Page
   ========================================================================== */

.history-group {
	margin-bottom: 24px;
}

.history-group__label {
	color: var(--text-secondary);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin-bottom: 8px;
	padding: 0 8px;
}

.history-list {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.history-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px;
	border-radius: var(--radius-sm);
	transition: background 0.15s;
}

.history-item:hover {
	background: var(--bg-hover);
}

.history-item__cover {
	width: 40px;
	height: 40px;
	border-radius: var(--radius-sm);
	object-fit: cover;
	flex-shrink: 0;
}

.history-item__info {
	flex: 1;
	min-width: 0;
}

.history-item__title {
	color: var(--text-primary);
	font-size: 0.8125rem;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.history-item__subtitle {
	color: var(--text-secondary);
	font-size: 0.6875rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.history-item__play-btn {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--accent);
	color: var(--bg-base);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	opacity: 0;
	transition: opacity 0.2s, transform 0.1s;
}

.history-item:hover .history-item__play-btn {
	opacity: 1;
}

.history-item__play-btn:hover {
	transform: scale(1.1);
}

/* ==========================================================================
   Theme Toggle
   ========================================================================== */

.sidebar-nav__theme-toggle {
	cursor: pointer;
	width: 100%;
	text-align: left;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ==========================================================================
   Transitions (hover-only devices)
   ========================================================================== */

@media (hover: hover) {
	a, button, .card-truyen, .chapter-row, .sidebar-nav__link, .sidebar-nav__genre-link {
		transition: background 0.2s, color 0.2s, transform 0.2s;
	}
}

/* ==========================================================================
   Mobile Responsive (< 768px)
   ========================================================================== */

@media (max-width: 768px) {
	.app-shell {
		grid-template-columns: 1fr;
		grid-template-rows: 1fr;
		grid-template-areas:
			"main";
	}

	.sidebar {
		position: fixed;
		left: -240px;
		top: 0;
		bottom: 0;
		width: 240px;
		z-index: 200;
		background: var(--bg-base);
		transition: left 0.3s ease;
	}

	.sidebar.is-open {
		left: 0;
	}

	.sidebar-overlay {
		display: none;
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.5);
		z-index: 199;
	}

	.sidebar.is-open ~ .sidebar-overlay {
		display: block;
	}

	.hamburger-btn {
		display: flex;
	}

	.main-view {
		padding: 16px;
		padding-top: 56px;
		padding-bottom: calc(var(--player-height-mobile) + 56px + 16px);
	}

	.player-bar {
		min-height: var(--player-height-mobile);
		grid-template-columns: 1fr auto auto;
		bottom: 56px;
	}

	.player-bar__yt-container {
		width: 106px;
		height: 60px;
	}

	.player-bar__volume {
		display: none;
	}

	.player-bar__extras {
		gap: 8px;
	}

	.player-bar__progress {
		display: none;
	}

	.player-bar__center {
		width: auto;
		margin: 0;
	}

	.player-bar__track {
		min-width: 0;
	}

	.bottom-nav {
		display: flex;
	}

	/* Truyen detail responsive */
	.truyen-detail {
		flex-direction: column;
		align-items: center;
		text-align: center;
	}

	.truyen-detail__cover {
		width: 200px;
		height: 200px;
	}

	.truyen-detail__title {
		font-size: 1.5rem;
	}

	.truyen-detail__meta {
		justify-content: center;
	}

	/* Chapter list mobile */
	.chapter-list__header {
		grid-template-columns: 40px 1fr 60px;
	}

	.chapter-row {
		grid-template-columns: 40px 1fr 60px;
	}

	.chapter-row__date {
		display: none;
	}

	/* Card grid mobile */
	.card-grid {
		grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
		gap: 12px;
	}

	/* Hero mobile */
	.hero-featured {
		min-height: 200px;
		padding: 20px;
	}

	.hero-featured__title {
		font-size: 1.75rem;
	}

	/* Action buttons mobile - wrap */
	.truyen-detail__actions {
		flex-wrap: wrap;
		justify-content: center;
	}

	/* Rating mobile */
	.truyen-rating {
		flex-basis: 100%;
		justify-content: center;
	}

	/* Comments mobile */
	.truyen-comments {
		padding: 16px;
	}

	.truyen-comment .children {
		margin-left: 12px;
		padding-left: 10px;
	}

	.truyen-comments .comment-form input[type="text"],
	.truyen-comments .comment-form input[type="email"],
	.truyen-comments .comment-form textarea {
		font-size: 16px; /* prevents iOS zoom on focus */
	}
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
	:root {
		--sidebar-width: 200px;
	}

	.truyen-detail__cover {
		width: 192px;
		height: 192px;
	}
}
