/* Global Styles */
html,
body {
	height: 100%;
	margin: 0;
	padding: 0;
	font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
	color: #333;
	background-color: #fff;
}

a {
	color: #4183c4;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

/* Book Layout */
.book {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.book-summary {
	font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	z-index: 1;
	width: 300px;
	/* Default width, will be changed by JS */
	color: #364149;
	background: #fafafa;
	border-right: 1px solid rgba(0, 0, 0, 0.07);
	transform: translateX(-100%);
	transition: transform 250ms ease;
	font-size: 14px;
}

.book.with-summary .book-summary {
	transform: translateX(0);
}

.book-body {
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	bottom: 0;
	background: #fff;
	transition: transform 250ms ease, left 250ms ease;
}

.book.with-summary .book-body {
	left: 300px;
}

.summary-resizer {
	position: absolute;
	top: 0;
	left: 300px;
	/* Initial position */
	bottom: 0;
	width: 8px;
	cursor: col-resize;
	z-index: 10;
	opacity: 0;
	transition: opacity 0.2s;
}

.summary-resizer:hover,
body.is-resizing .summary-resizer {
	opacity: 1;
	background: rgba(140, 140, 140, 0.2);
}

.body-inner {
	height: 100%;
	display: flex;
	flex-direction: column;
}

/* Header */
.book-header {
	height: 50px;
	padding: 0 15px;
	z-index: 2;
	font-size: 0.85em;
	color: #7e888b;
	background: #fff;
	border-bottom: 1px solid rgba(0, 0, 0, 0.07);
	display: -ms-flexbox;
	display: flex;
	-ms-flex-align: center;
	align-items: center;
}

.book-header .btn {
	color: #ccc;
	line-height: 50px;
	padding-right: 15px;
	font-size: 16px;
}

.book-header .btn:hover {
	color: #444;
	text-decoration: none;
}

.book-header h1 {
	margin: 0;
	font-size: 20px;
	font-weight: 300;
	text-align: center;
	line-height: 50px;
	-ms-flex-positive: 1;
	flex-grow: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.book-header h1 a {
	color: inherit;
}

#a_tit {
	transition: color 0.3s ease, text-shadow 0.3s ease;
}

#a_tit:hover {
	color: #3C3C43;
	text-shadow: 2px 2px 8px rgba(227, 229, 231, 1);
	text-decoration: none;
}

/* Summary / Sidebar */
.book-summary .book-search {
	position: relative;
	display: none;
	padding: 8px;
	background: #fafafa;
	border-bottom: 1px solid rgba(0, 0, 0, 0.07);
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.5s ease, visibility 0.5s ease;
	z-index: 10;
	/* Ensure it's on top */
}

.book.with-search .book-summary .book-search {
	visibility: visible;
	opacity: 1;
}

.book-summary .book-search input {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid #ddd;
	border-radius: 3px;
	padding: 8px;
	outline: none;
}

.book-summary ul.summary {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	overflow-y: auto;
	list-style: none;
	margin: 0;
	padding: 0;
	padding-top: 7px;
	transition: top 0.5s ease;
}

.book.with-search .book-summary ul.summary {
	top: 50px;
	/* Pushed down by search bar */
}

.book-summary ul.summary li.divider {
	height: 1px;
	margin: 7px 0;
	background: rgba(0, 0, 0, 0.07);
}

.book-summary ul.summary li a {
	display: block;
	padding: 10px 15px;
	color: #364149;
	text-overflow: ellipsis;
	overflow: hidden;
	white-space: nowrap;
	position: relative;
}

.book-summary ul li.active>a,
.book-summary ul li a:hover {
	color: #008cff;
	text-decoration: none;
}

.book-summary ul.summary li .fa-check {
	display: none;
}


.book-summary ul.summary li ul {
	padding-left: 20px;
	list-style: none;
}

.book-summary ul.summary li.has-children>a {
	padding-left: 30px;
	/* Make space for icon */
}


/* Removed empty .myfa ruleset */

.book-summary ul.summary li .toggle-chapter {
	position: absolute;
	left: 12px;
	top: 13px;
	transition: transform 0.2s ease;
	font-size: 10px;
}

.book-summary ul.summary li.collapsed .articles {
	display: none;
}

.book-summary ul.summary li.collapsed .toggle-chapter {
	top: 14px;
	transform: rotate(-90deg);
}

/* Page Content */
.page-wrapper {
	position: relative;
	outline: 0;
	flex-grow: 1;
	display: flex;
}

.page-inner {
	position: relative;
	flex-grow: 1;
	overflow: hidden;
	/* This is crucial for the padding effect */
}

.page-inner>iframe {
	position: absolute;
	border: none;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	visibility: hidden;
	/* Hide by default */
	opacity: 0;
	transition: opacity 0.3s ease;
	/* Padding is now injected into iframe content via CSS injection */
}

.page-inner>iframe.loaded {
	visibility: visible;
	opacity: 1;
}

.page-inner section.normal h1 {
	padding-bottom: 0.3em;
	font-size: 2.25em;
	line-height: 1.2;
	border-bottom: 1px solid #eee;
	margin-top: 0;
}

.page-inner section.normal h2 {
	padding-bottom: 0.3em;
	font-size: 1.75em;
	line-height: 1.225;
	border-bottom: 1px solid #eee;
}

.page-inner section.normal p {
	margin: 0 0 16px;
}

.page-inner section.normal blockquote {
	padding: 0 15px;
	color: #777;
	border-left: 4px solid #ddd;
	margin: 0 0 16px;
}

/* Responsive */
@media (max-width: 600px) {
	.book-summary {
		width: calc(100% - 60px);
		transform: translateX(-100%);
		transition: transform 0.25s ease;
	}

	.book.with-summary .book-summary {
		transform: translateX(0);
	}

	.book-body {
		left: 0 !important;
		/* Override desktop style */
		transition: transform 0.25s ease;
	}

	.book.with-summary .book-body {
		transform: translateX(calc(100% - 60px));
	}

	.body-overlay {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);
		z-index: 5;
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.25s ease, visibility 0.25s ease;
	}

	.book.with-summary .body-overlay {
		opacity: 1;
		visibility: visible;
	}

	.summary-resizer {
		display: none !important;
	}

	#progress-bar-container {
		left: 0 !important;
	}
}

/* Helper class to prevent text selection during resize */
body.is-resizing {
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

/* Font settings dropdown */
.font-settings-dropdown {
	position: absolute;
	top: 50px;
	left: 90px;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.07);
	border-radius: 3px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	padding: 10px;
	z-index: 100;
	display: flex;
	gap: 10px;
}

.font-size-option {
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border: 1px solid #ddd;
	border-radius: 3px;
	transition: all 0.2s ease;
	background: #fff;
}

.font-size-option:hover {
	background: #f5f5f5;
	border-color: #4183c4;
}

.font-size-option.active {
	background: #4183c4;
	border-color: #4183c4;
	color: #fff;
}

.font-size-option.active span {
	color: #fff;
}

.font-size-option span {
	font-weight: bold;
	color: #333;
}


.search-clear {
	position: absolute;
	top: 50%;
	right: 20px;
	transform: translateY(-50%);
	cursor: pointer;
	color: #999;
}

.search-container {
	display: none;
	/* Initially hidden */
}

.search-header {
	padding: 10px 15px;
	border-bottom: 1px solid #eee;
	text-align: center;
	color: #777;
}

.search-header .fa-spinner {
	margin-right: 8px;
}

.search-results {
	list-style: none;
	padding: 0;
	margin: 0;
	max-height: calc(100vh - 90px);
	/* Example height, adjust as needed */
	overflow-y: auto;
}

.search-results li a {
	display: block;
	padding: 10px 15px;
	text-decoration: none;
	color: #364149;
	border-bottom: 1px solid #f0f0f0;
}

.search-results li a:hover {
	background-color: #f5f5f5;
}

.iframe-shield {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 9999;
	display: none;
}

/* Progress Bar Styles */
#progress-bar-container {
	position: fixed;
	top: 50px;
	/* Height of the book-header */
	left: 300px;
	/* Same as .book-body left */
	right: 0;
	height: 2px;
	z-index: 1001;
	/* Higher than other elements */
	display: none;
	/* Initially hidden */
	transition: left 250ms ease;
	/* Match .book-body transition */
}

.book:not(.with-summary) #progress-bar-container {
	left: 0;
}


#progress-bar {
	width: 0;
	height: 100%;
	background-color: #ccc;
	transition: width 0.3s ease;
}