:root {
	--primary-color: #1a365d;
	--secondary-color: #2d3748;
	--accent-color: #3182ce;
	--light-color: #f7fafc;
	--dark-color: #2d3748;
	--font-size: 16px;
	--line-height: 1.6;
	--header-height: 70px;
	--sidebar-width: 250px;
	--max-width: 1200px;
	--border-radius: 8px;
	--box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
	--transition: all 0.3s ease;
	
	/* Light theme (default) */
	--bg-color: #f7fafc;
	--text-color: #2d3748;
	--card-bg: #ffffff;
	--border-color: #e2e8f0;
	--header-bg: #1a365d;
	--footer-bg: #2d3748;
}

.theme-dark {
	--bg-color: #1a202c;
	--text-color: #e2e8f0;
	--card-bg: #2d3748;
	--border-color: #4a5568;
	--header-bg: #2d3748;
	--footer-bg: #1a202c;
	--box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

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

body {
	font-family: 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
	font-size: var(--font-size);
	line-height: var(--line-height);
	color: var(--text-color);
	background-color: var(--bg-color);
	transition: var(--transition);
}

/* Header Styles */
header {
	background-color: var(--header-bg);
	color: white;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: var(--header-height);
	z-index: 1000;
	box-shadow: var(--box-shadow);
}

.header-container {
	max-width: var(--max-width);
	margin: 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: center;
	height: 100%;
	padding: 0 20px;
}

.logo {
	font-size: 1.1rem;
	font-weight: bold;
    position: relative; /* Add this */
    z-index: 1002; /* Higher than mobile menu button */
}	


.logo a {
    color: white;
    text-decoration: none;
    display: block; /* Ensure full clickable area */
    padding: 5px 0; /* Add some padding for better touch target */
	z-index: 1003; /* Higher than mobile menu button */
}

/* Navigation - Default (Desktop) */
.nav-desktop {
	display: flex;
	gap: 20px;
}

.nav-desktop a {
	color: white;
	text-decoration: none;
	padding: 8px 12px;
	border-radius: var(--border-radius);
	transition: var(--transition);
}

.nav-desktop a:hover,
.nav-desktop a.active {
	background-color: rgba(255, 255, 255, 0.1);
}

.mobile-menu-btn {
	display: none;
	background: none;
	border: none;
	color: white;
	font-size: 1.5rem;
	cursor: pointer;
	z-index: 1001;
}

/* Mobile Menu - Hidden by default */
.mobile-menu {
	position: fixed;
	top: var(--header-height);
	left: 0;
	right: 0;
	background-color: var(--header-bg);
	padding: 20px;
	transform: translateY(-100%);
	opacity: 0;
	transition: var(--transition);
	z-index: 999;
	box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
	overflow-y: auto;
	max-height: calc(100vh - var(--header-height));
	visibility: hidden; /* Use visibility instead of display */
}

.mobile-menu.active {
	transform: translateY(0);
	opacity: 1;
	visibility: visible; /* Show when active */
}

.mobile-menu a {
	display: block;
	color: white;
	text-decoration: none;
	padding: 12px 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	transition: var(--transition);
}

.mobile-menu a:hover,
.mobile-menu a.active {
	background-color: rgba(255, 255, 255, 0.1);
	padding-left: 10px;
}

/* Main Content */
main {
	margin-top: var(--header-height);
	min-height: calc(100vh - var(--header-height));
	padding: 20px;
}

.container {
	max-width: var(--max-width);
	margin: 0 auto;
}

/* Display Controls */
.display-controls {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
	gap: 15px;
	flex-wrap: wrap;
}

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

.image-toggle-form,
.theme-toggle-form {
	margin: 0;
}

/* Font Size Controls */
.font-controls {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

.font-control-form {
	display: flex;
	gap: 10px;
}

.font-btn {
	background-color: var(--secondary-color);
	color: white;
	border: none;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: var(--transition);
    font-weight: bold;	
}

.font-btn:hover {
	background-color: var(--accent-color);
}

/* Font size variations for the A buttons */
.font-btn[value="small"] {
	font-size: 14px;
}

.font-btn[value="medium"] {
	font-size: 18px;
}

.font-btn[value="large"] {
	font-size: 22px;
}

.font-btn[value="xlarge"] {
	font-size: 26px;
}

/* Preference buttons */
.preference-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 15px;
	background-color: var(--secondary-color);
	color: white;
	border: none;
	border-radius: var(--border-radius);
	cursor: pointer;
	transition: var(--transition);
	font-size: 0.9rem;
	font-weight: 500;
}

.preference-btn:hover {
	background-color: var(--accent-color);
	transform: translateY(-2px);
}

/* Image toggle button states */
.image-toggle-btn.images-on {
	background-color: #38a169;
}

.image-toggle-btn.images-on:hover {
	background-color: #2f855a;
}

.image-toggle-btn.images-off {
	background-color: #e53e3e;
}

.image-toggle-btn.images-off:hover {
	background-color: #c53030;
}

/* Theme toggle button states */
.theme-toggle-btn.theme-light {
	background-color: #d69e2e;
}

.theme-toggle-btn.theme-light:hover {
	background-color: #b7791f;
}

.theme-toggle-btn.theme-dark {
	background-color: #4a5568;
}

.theme-toggle-btn.theme-dark:hover {
	background-color: #2d3748;
}

/* Category Grid */
.category-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 20px;
	margin-bottom: 40px;
}

.category-card {
	background-color: var(--card-bg);
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow);
	overflow: hidden;
	transition: var(--transition);
	border: 1px solid var(--border-color);
}

.category-card:hover {
	transform: translateY(-5px);
	box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.category-link {
	text-decoration: none;
	color: inherit;
	display: block;
}

.category-image {
	height: 180px;
	background-color: var(--accent-color);
	display: flex;
	align-items: center;
	justify-content: center;
	color: white;
	font-size: 2rem;
}

.category-content {
	padding: 20px;
	color: var(--text-color);
}

.category-title {
	font-size: 1.25rem;
	margin-bottom: 10px;
	color: var(--text-color);
}

.category-desc {
	color: var(--text-color);
	opacity: 0.8;
	font-size: 0.9rem;
}

/* News List */
.news-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 20px;
}

.news-card {
	background-color: var(--card-bg);
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow);
	overflow: hidden;
	transition: var(--transition);
	border: 1px solid var(--border-color);
}

.news-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.news-link {
	text-decoration: none;
	color: inherit;
	display: block;
}

.news-image {
	height: 180px;
	background-color: #e2e8f0;
	overflow: hidden;
}

.news-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: var(--transition);
}

.news-card:hover .news-image img {
	transform: scale(1.05);
}

.news-content {
	padding: 15px;
	color: var(--text-color);
}

.news-title {
	font-size: 1.1rem;
	margin-bottom: 10px;
	line-height: 1.4;
	color: var(--text-color);
}

.news-meta {
	display: flex;
	justify-content: space-between;
	font-size: 0.8rem;
	color: var(--text-color);
	opacity: 0.8;
}

/* News list without images */
.news-list.images-hidden .news-card {
	min-height: auto;
}

.news-list.images-hidden .news-content.full-width {
	padding: 20px;
	width: 100%;
}

.news-list.images-hidden .news-title {
	font-size: 1.1rem;
	margin-bottom: 8px;
}

/* Adjust layout when images are hidden */
.news-content.full-width {
	width: 100%;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

/* Only wrap on very small screens if needed */
@media (max-width: 480px) {
    .page-header {
        flex-wrap: nowrap;
    }
}

/* News Detail */
.news-detail {
	background-color: var(--card-bg);
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow);
	padding: 30px;
	margin-bottom: 30px;
	border: 1px solid var(--border-color);
	color: var(--text-color);
}

.news-header {
	margin-bottom: 20px;
	border-bottom: 1px solid var(--border-color);
	padding-bottom: 20px;
}

.news-detail-title {
	font-size: 1.8rem;
	margin-bottom: 10px;
	color: var(--text-color);
	line-height: 1.3;
}

.news-detail-subtitle {
	font-size: 1.2rem;
	color: var(--text-color);
	opacity: 0.8;
	margin-bottom: 15px;
	line-height: 1.4;
}

.news-detail-meta {
	display: flex;
	gap: 15px;
	font-size: 0.9rem;
	color: var(--text-color);
	opacity: 0.8;
	flex-wrap: wrap;
}

.news-body {
	margin-bottom: 30px;
}

.news-image-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 15px;
	margin: 20px 0;
}

.gallery-item {
	cursor: pointer;
	border-radius: var(--border-radius);
	overflow: hidden;
	box-shadow: var(--box-shadow);
	transition: var(--transition);
}

.gallery-item:hover {
	transform: translateY(-3px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
	width: 100%;
	height: 180px;
	object-fit: cover;
	transition: var(--transition);
}

.gallery-item:hover img {
	transform: scale(1.05);
}

.image-caption {
	padding: 10px;
	font-size: 0.85rem;
	color: var(--text-color);
	background-color: var(--bg-color);
}

.news-content p {
	margin-bottom: 15px;
	line-height: 1.7;
}

/* Social Sharing */
.social-sharing {
	display: flex;
	gap: 15px;
	margin: 30px 0;
	padding: 20px 0;
	border-top: 1px solid var(--border-color);
	border-bottom: 1px solid var(--border-color);
	justify-content: center;
}

.share-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 15px;
	border-radius: var(--border-radius);
	color: white;
	text-decoration: none;
	font-size: 0.9rem;
	transition: var(--transition);
}

.share-whatsapp {
	background-color: #25D366;
}

.share-wechat {
	background-color: #07C160;
}

.share-btn:hover {
	opacity: 0.9;
	transform: translateY(-2px);
}

/* Navigation Controls */
.nav-controls {
	display: flex;
	justify-content: space-between;
	margin-top: 30px;
}

.nav-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 20px;
	background-color: var(--primary-color);
	color: white;
	border: none;
	border-radius: var(--border-radius);
	cursor: pointer;
	transition: var(--transition);
	text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;    
}

.nav-btn:hover {
	background-color: var(--accent-color);
}

.nav-btn.disabled {
	background-color: #a0aec0;
	cursor: not-allowed;
}

.nav-btn.disabled:hover {
	background-color: #a0aec0;
}

/* Image Modal */
.modal {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.9);
	z-index: 1100;
	justify-content: center;
	align-items: center;
	padding: 20px;
}

.theme-dark .modal {
	background-color: rgba(0, 0, 0, 0.95);
}

.modal.active {
	display: flex;
}

.modal-content {
	max-width: 90%;
	max-height: 90%;
	position: relative;
}

.modal-content img {
	max-width: 100%;
	max-height: 100%;
	border-radius: var(--border-radius);
}

.modal-close {
	position: absolute;
	top: -40px;
	right: 0;
	color: white;
	font-size: 2rem;
	cursor: pointer;
}

.modal-caption {
	color: white;
	text-align: center;
	margin-top: 15px;
}

/* Footer */
footer {
	background-color: var(--footer-bg);
	color: white;
	padding: 30px 20px;
	margin-top: 50px;
}

.footer-container {
	max-width: var(--max-width);
	margin: 0 auto;
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 30px;
}

.footer-section {
	flex: 1;
	min-width: 200px;
}

.footer-section h3 {
	margin-bottom: 15px;
	font-size: 1.2rem;
}

.footer-section a {
	color: #cbd5e0;
	text-decoration: none;
	display: block;
	margin-bottom: 8px;
	transition: var(--transition);
}

.footer-section a:hover {
	color: white;
}

.copyright {
	text-align: center;
	margin-top: 30px;
	padding-top: 20px;
	border-top: 1px solid #4a5568;
	color: #cbd5e0;
	font-size: 0.9rem;
}

/* Loading Spinner */
.loading {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	padding: 40px;
	text-align: center;
}

.spinner {
	width: 40px;
	height: 40px;
	border: 4px solid rgba(0, 0, 0, 0.1);
	border-left-color: var(--accent-color);
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin-bottom: 15px;
}

.theme-dark .spinner {
	border: 4px solid rgba(255, 255, 255, 0.1);
	border-left-color: var(--accent-color);
}

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

/* Font Size Classes */
.font-small {
	--font-size: 14px;
}

.font-medium {
	--font-size: 16px;
}

.font-large {
	--font-size: 18px;
}

.font-xlarge {
	--font-size: 20px;
}

/* Desktop Styles - Hide mobile elements */
@media (min-width: 769px) {
	.mobile-menu-btn {
		display: none;
	}
	
	.mobile-menu {
		display: none;
	}
	
	.nav-desktop {
		display: flex;
		position: relative;
		z-index: 1002;
	}
}

/* Mobile Styles */
@media (max-width: 768px) {
	.nav-desktop {
		display: none;
	}

	.mobile-menu-btn {
		display: block;
	}

	.mobile-menu {
		display: block; /* Ensure it's display block on mobile */
		visibility: visible; /* Make it visible for transitions */
	}

	.category-grid {
		grid-template-columns: 1fr;
	}

	.news-list {
		grid-template-columns: 1fr;
	}

	.news-detail {
		padding: 20px;
	}

	.news-detail-title {
		font-size: 1.5rem;
	}

	.nav-controls {
		flex-direction: column;
		gap: 10px;
	}

	.nav-btn {
		justify-content: center;
	}

	/* === UPDATED: Same row layout for controls === */
	.display-controls {
		flex-direction: row; /* CHANGED: from column to row */
		align-items: center; /* ADDED */
		justify-content: space-between; /* ADDED */
		gap: 10px; /* CHANGED: from 15px to 10px */
		flex-wrap: nowrap; /* ADDED */
	}
	
	.font-controls {
		justify-content: flex-start; /* CHANGED: from center to flex-start */
		flex: 0 0 auto; /* ADDED */
	}
	
	.preference-controls {
		display: flex; /* ADDED */
		justify-content: flex-end; /* CHANGED: from center to flex-end */
		width: auto; /* CHANGED: from 100% to auto */
		gap: 5px; /* CHANGED: from 10px to 5px */
		flex: 0 0 auto; /* ADDED */
	}
	
	.preference-btn {
		flex: none; /* CHANGED: from 1 to none */
		min-width: 100px; /* ADDED */
		justify-content: center; /* KEPT */
		padding: 8px 10px; /* ADDED: reduced padding */
		font-size: 0.8rem; /* ADDED: smaller font */
	}

	/* === UPDATED: Font controls compact === */
	.font-control-form {
		gap: 5px; /* ADDED: reduced gap */
	}
	
	.font-btn {
		width: 35px; /* ADDED: smaller buttons */
		height: 35px; /* ADDED: smaller buttons */
		font-size: 0.8rem; /* ADDED: smaller font */
	}
	/* === END UPDATED === */

    .page-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        gap: 10px;
        width: 100%;
        min-width: 0; /* Important for flex children */
    }
}

/* Additional Mobile Optimizations */
@media (max-width: 480px) {
	.header-container {
		padding: 0 15px;
	}

	main {
		padding: 15px;
	}

	.news-image-gallery {
		grid-template-columns: 1fr;
	}

	.social-sharing {
		flex-direction: column;
		align-items: center;
	}

	.share-btn {
		width: 100%;
		justify-content: center;
	}

	.footer-container {
		flex-direction: column;
	}

	/* === UPDATED: Small mobile adjustments === */
	.display-controls {
		gap: 5px; /* CHANGED: from 10px to 5px */
	}
	
	.preference-btn {
		min-width: 80px; /* CHANGED: from 100px to 80px */
		padding: 6px 8px; /* CHANGED: reduced padding */
	}
	
	.preference-btn span {
		display: none; /* ADDED: hide text on very small screens */
	}
	
	.font-btn {
		width: 32px; /* CHANGED: from 35px to 32px */
		height: 32px; /* CHANGED: from 35px to 32px */
	}
	/* === END UPDATED === */
}

/* Ensure text remains readable in dark mode */
.theme-dark .category-desc,
.theme-dark .news-meta,
.theme-dark .news-detail-subtitle {
	color: #cbd5e0;
}

.theme-dark .image-caption {
	background-color: #4a5568;
	color: #e2e8f0;
}

.theme-dark .news-header,
.theme-dark .social-sharing {
	border-color: #4a5568;
}

/* Dark mode specific adjustments */
.theme-dark .category-image {
	background-color: #4a5568;
}

.theme-dark .news-image {
	background-color: #4a5568;
}

.theme-dark .font-btn {
	background-color: #4a5568;
}

.theme-dark .font-btn:hover {
	background-color: var(--accent-color);
}