/* ===========================================
   CSS VARIABLES 
   =========================================== */

:root {
	/* Core colors - easy to change for theming */
	--color-primary: #007bff;
	--color-primary-hover: #0056b3;
	--color-success: #28a745;
	--color-success-hover: #218838;
	--color-error: #dc3545;

	/* Text colors */
	--color-text: #333;
	--color-text-light: #666;

	/* UI colors */
	--color-border: #ddd;
	--color-bg: #f5f5f5;
	--color-bg-light: #f8f9fa;
	--color-bg-dark: #ffffff;

	/* Success/Error states */
	--color-success-bg: #d4edda;
	--color-success-text: #155724;
	--color-success-border: #c3e6cb;
	--color-error-bg: #f8d7da;
	--color-error-text: #721c24;
	--color-error-border: #f5c6cb;

	/* Common spacing */
	--spacing: 10px;
	--spacing-lg: 20px;
}

/* ===========================================
   BASE STYLES
   =========================================== */

body {
	font-family: Arial, sans-serif;
	margin: 0;
	padding: 0;
	background-color: var(--color-bg);
	color: var(--color-text);
}

/* ===========================================
   COMPONENTS
   =========================================== */

/* Buttons */
.btn {
	padding: 10px 20px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 16px;
}

.btn-primary {
	background-color: var(--color-primary);
	color: white;
}

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

.btn-success {
	background-color: var(--color-success);
	color: white;
}

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

.btn:disabled {
	background-color: #6c757d;
	cursor: not-allowed;
}

.btn-small {
	padding: 6px 12px;
	font-size: 12px;
	border: 1px solid var(--color-border);
	background: white;
	color: var(--color-text);
}

.btn-small:hover {
	background-color: var(--color-bg-light);
}

/* Input Fields */
.input {
	padding: 10px;
	border: 1px solid var(--color-border);
	border-radius: 4px;
	font-size: 16px;
}

.input:focus {
	outline: none;
	border-color: var(--color-primary);
}

.input-lg {
	border-width: 2px;
}

/* ===========================================
   LAYOUT & UTILITY
   =========================================== */

.container {
	background: white;
	padding: 0 var(--spacing-lg) 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.input-group {
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
}

.input-group .input {
	flex: 1;
}

.hidden {
	display: none;
}

.loading {
	text-align: center;
	padding: 20px;
	color: var(--color-text-light);
}

/* ===========================================
   CHAT PAGE
   =========================================== */

.chat-box {
	border: 1px solid var(--color-border);
	height: 300px;
	overflow-y: auto;
	padding: 10px;
	margin: 10px 0;
	background-color: #fafafa;
	border-radius: 4px;
}

.message {
	margin: 5px 0;
	padding: 8px 12px;
	border-radius: 18px;
	max-width: 70%;
}

.user-message {
	background-color: var(--color-primary);
	color: white;
	margin-left: auto;
	text-align: right;
}

.cat-message {
	background-color: #e9ecef;
	color: var(--color-text);
}

.status {
	margin: 10px 0;
	padding: 10px;
	border-radius: 4px;
}

.status.success {
	background-color: var(--color-success-bg);
	color: var(--color-success-text);
	border: 1px solid var(--color-success-border);
}

.status.error {
	background-color: var(--color-error-bg);
	color: var(--color-error-text);
	border: 1px solid var(--color-error-border);
}

.settings-header {
	display: flex;
	align-items: center;
	cursor: pointer;
	padding: 10px;
	background-color: var(--color-bg-light);
	border: 1px solid #e9ecef;
	border-radius: 4px;
	margin-bottom: 15px;
	user-select: none;
}

.settings-header:hover {
	background-color: #e9ecef;
}

.settings-icon {
	margin-right: 8px;
	transition: transform 0.2s;
}

.settings-icon.expanded {
	transform: rotate(90deg);
}

.settings-content {
	padding: 15px;
	background-color: var(--color-bg-light);
	border: 1px solid #e9ecef;
	border-top: none;
	border-radius: 0 0 4px 4px;
	margin-top: -15px;
	margin-bottom: 15px;
}

/* ===========================================
   POKEMON PAGE
   =========================================== */

.page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: var(--color-bg);
	margin: 0 calc(-1 * var(--spacing-lg));
	padding: var(--spacing-lg);
}

.page-header h1 {
	margin: 0;
	font-size: 1.5rem;
}

.search-inline {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: var(--spacing-sm);
	align-items: center;
}

.pokemon-input {
	width: 200px;
}

.settings-link {
	text-decoration: none;
	font-size: 1.5rem;
}

/* Results Layout with Sidebar */
#pokemonResults {
	flex-direction: column;
}

.results-layout {
	display: flex;
	gap: var(--spacing);
	align-items: flex-start;
}

.info-sidebar {
	flex: 0 0 350px;
	width: 350px;
	align-self: flex-start;
	position: sticky;
	top: 0;
}

.cards-main {
	flex: 1;
	min-width: 0;
	max-height: calc(100vh-90px);
	overflow-y: auto;
}

.cards-section {
	margin-top: 20px;
}

.cards-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 200px));
	gap: 5px;
	justify-content: center;
}

.card-item {
	background: white;
	border: 1px solid var(--color-border);
	border-radius: 6px;
	padding: 12px;
	transition: transform 0.2s ease;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.card-item.owned {
	border-color: var(--color-success);
	background: #f8fff9;
}

.card-item.not-owned {
	border-color: var(--color-error);
	background: #fff8f8;
}

.card-item:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.card-status {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
}

.card-status input[type='checkbox'] {
	margin: 0;
}

.card-image {
	width: 100%;
	height: auto;
	border-radius: 4px;
}

.owned-badge {
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: bold;
}

.owned-badge.owned {
	background: var(--color-success-bg);
	color: var(--color-success-text);
}

.owned-badge.not-owned {
	background: var(--color-error-bg);
	color: var(--color-error-text);
}

.quantity {
	font-weight: bold;
	color: var(--color-primary);
}

.error-message {
	background: var(--color-error-bg);
	color: var(--color-error-text);
	padding: 15px;
	border-radius: 6px;
	margin: var(--spacing-lg) 0;
	border: 1px solid var(--color-error-border);
}

.success-message {
	background: #d1fae5;
	color: #065f46;
	padding: 15px;
	border-radius: 6px;
	margin: var(--spacing-lg) 0;
	border: 1px solid #10b981;
}

/* Pokedex Card Section */
.pokedex-card-section {
	background: white;
	border-radius: 8px;
	padding: var(--spacing-lg);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
	text-align: center;
}

.pokedex-card-header {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 15px;
	margin: var(--spacing) 0;
}

.pokedex-card-section h3 {
	margin: 0;
	color: var(--color-primary);
}

.pokemon-nav-arrow {
	text-decoration: none;
	font-size: 20px;
	color: var(--color-primary);
	padding: 5px 10px;
	border-radius: 4px;
	transition: background-color 0.2s ease;
}

.pokemon-nav-arrow:hover {
	background-color: var(--color-bg-light);
}

.pokemon-nav-arrow.hidden {
	visibility: hidden !important;
	display: inline-block !important;
}

.pokedex-card-display {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: var(--spacing);
}

.pokedex-card-display img {
	width: 300px;
	height: auto;
	border-radius: 12px;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
	display: block;
}

/* ===========================================
   POKEDEX GRID VIEW
   =========================================== */

.pokedex-controls {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
	padding: 15px;
	background: var(--color-bg-light);
	position: relative;

	background: lightgreen;
	margin: 0 calc(-1 * var(--spacing-lg));
	padding: 5px var(--spacing-lg);
}

.pokedex-controls .pagination-group {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 20px;
	flex: 1;
}

.pokedex-controls #pageInfo {
	font-weight: bold;
	min-width: 120px;
	text-align: center;
}

.pokedex-controls #showUnowned {
	margin-left: auto;
}

.pokedex-grid {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	max-width: 100vw;
	box-sizing: border-box;
	gap: 0;
	background: black;
	padding: 15px;
	border-radius: 6px;
	border: 4px solid;
	border-image: linear-gradient(135deg, #2ecc71, #27ae60, #16a085, #27ae60, #2ecc71) 1;
	width: fit-content;
	margin: 0 auto;
}

.pokedex-cell {
	width: 100%;
	max-width: 250px;
	aspect-ratio: 5 / 7;
	border-right: 2px dashed #666;
	border-bottom: 2px dashed #666;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 5px;
	background: black;
	cursor: pointer;
	text-decoration: none;
	box-sizing: border-box;
	position: relative;
}

.pokedex-cell:nth-child(-n + 5) {
	border-top: 2px dashed #666;
}

.pokedex-cell:nth-child(5n + 1) {
	border-left: 2px dashed #666;
}

.pokedex-cell:hover {
	z-index: 10;
}

.pokedex-cell img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	transition: transform 0.2s ease;
}

.pokedex-cell:hover img {
	transform: scale(1.1);
}

/* ===========================================
   HOME PAGE NAVIGATION
   =========================================== */

.nav-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	background: white;
	border: 2px solid var(--color-border);
	border-radius: 8px;
	text-decoration: none;
	color: var(--color-text);
	transition: all 0.2s ease;
	cursor: pointer;
}

.nav-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
	border-color: var(--color-primary);
}

.nav-emoji {
	font-size: 64px;
	margin-bottom: 15px;
}

.nav-title {
	font-size: 20px;
	font-weight: bold;
}

/* ===========================================
   UNOWNED PANEL
   =========================================== */

.unowned-panel {
	position: fixed;
	top: 0;
	right: 0;
	width: 80%;
	max-width: 300px;
	height: 100vh;
	background: var(--color-bg-dark);
	border-left: 2px solid var(--color-border);
	box-shadow: -4px 0 8px rgba(0, 0, 0, 0.2);
	z-index: 1000;
	display: flex;
	flex-direction: column;
	transition: transform 0.3s ease;
}

.unowned-panel.hidden {
	transform: translateX(100%);
}

.unowned-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20px;
	border-bottom: 1px solid var(--color-border);
	background: var(--color-bg-light);
}

.unowned-header h3 {
	margin: 0;
	font-size: 1.2rem;
}

.unowned-list {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
}

.unowned-list .loading {
	text-align: center;
	padding: 20px;
	color: var(--color-text-muted);
}

.unowned-item {
	display: block;
	padding: 12px 16px;
	margin-bottom: 2px;
	background: var(--color-bg-light);
	border: 1px solid var(--color-border);
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
	color: var(--color-text);
}

.unowned-item:hover {
	background: var(--color-primary);
	color: white;
	transform: translateX(-4px);
	text-decoration: none;
}

.unowned-empty {
	text-align: center;
	padding: 40px 20px;
	color: var(--color-text-muted);
	font-style: italic;
}

/* Mobile responsive: smaller cells and panel adjustments */
@media (max-width: 1290px) {
	.pokedex-grid {
		padding: 2px;
	}

	.pokedex-cell {
		padding: 2px;
	}

	.container {
		padding: 0 2px 0;
	}
}

@media (max-width: 600px) {
	.results-layout {
		flex-direction: column;
	}

	.info-sidebar {
		position: static;
		flex: 1;
		width: 100%;
		max-height: none;
	}

	.cards-main {
		max-height: none;
		width: 100%;
	}

	.cards-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 2px;
	}

	.input-group {
		flex-direction: column;
		align-items: stretch;
	}

	.pokedex-card-display img {
		width: 250px;
	}
}
/* Hide header text when it gets cut off by search box */
@media (max-width: 550px) {
	.page-header h1 a {
		font-size: 0;
	}

	.page-header h1 a::before {
		content: '🎴';
		font-size: 1.5rem;
	}
}
