/* Desktop table improvements */
.modern-hcode-table {
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0,0,0,0.1);
	background: #fff;
}

.modern-hcode-table thead th {
	background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
	border-bottom: 2px solid #dee2e6;
	position: sticky;
	top: 0;
	z-index: 10;
	font-weight: 600;
	color: #495057;
	text-transform: uppercase;
	font-size: 0.85em;
	letter-spacing: 0.5px;
}

.modern-hcode-table tbody tr {
	transition: all 0.2s ease;
	border-bottom: 1px solid #f1f3f4;
}

.modern-hcode-table tbody tr:nth-child(even) {
	background-color: #fafbfc;
}

.modern-hcode-table tbody tr:hover {
	background-color: #e3f2fd;
	transform: translateY(-1px);
	box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.modern-hcode-table td {
	padding: 12px 16px;
	vertical-align: middle;
	border: none;
}

.modern-hcode-table a {
	color: #1976d2;
	text-decoration: none;
	font-weight: 500;
	transition: color 0.2s ease;
}

.modern-hcode-table a:hover {
	color: #1565c0;
	text-decoration: underline;
}

/* Status indicators */
.status-active {
	color: #2e7d32;
	font-weight: 600;
}

.status-inactive {
	color: #d32f2f;
	font-weight: 600;
}

/* Action buttons */
.action-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 6px 12px;
	border: 1px solid #ddd;
	border-radius: 6px;
	background: #fff;
	color: #495057;
	text-decoration: none;
	font-size: 0.875em;
	transition: all 0.2s ease;
}

.action-btn:hover {
	background: #f8f9fa;
	border-color: #1976d2;
	color: #1976d2;
}

.action-btn-primary {
	background: #1976d2;
	color: #fff;
	border-color: #1976d2;
}

.action-btn-primary:hover {
	background: #1565c0;
	border-color: #1565c0;
	color: #fff;
}

/* Search and filter improvements */
.table-controls {
	background: #f8f9fa;
	padding: 16px;
	border-radius: 8px;
	margin-bottom: 16px;
	border: 1px solid #e9ecef;
}

.table-controls .form-control {
	border-radius: 6px;
	border: 1px solid #ced4da;
	padding: 8px 12px;
}

.table-controls .btn {
	border-radius: 6px;
	padding: 8px 16px;
	font-weight: 500;
	transition: all 0.2s ease;
}

/* Pagination improvements */
.modern-pagination {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	margin: 24px 0;
	flex-wrap: wrap;
}

.modern-pagination a, 
.modern-pagination span {
	display: inline-flex;
	align-items: center;
	padding: 8px 12px;
	border: 1px solid #dee2e6;
	border-radius: 6px;
	color: #495057;
	text-decoration: none;
	font-weight: 500;
	transition: all 0.2s ease;
}

.modern-pagination a:hover {
	background: #1976d2;
	color: #fff;
	border-color: #1976d2;
}

.modern-pagination .current-page {
	background: #1976d2;
	color: #fff;
	border-color: #1976d2;
}

/* Results info */
.results-info {
	color: #6c757d;
	font-size: 0.9em;
	margin-bottom: 12px;
	font-weight: 500;
}

/* Mobile responsive design */
@media (max-width: 767.98px) {
	/* Hide table structure on mobile */
	.modern-hcode-table,
	.modern-hcode-table thead,
	.modern-hcode-table tbody,
	.modern-hcode-table th,
	.modern-hcode-table td,
	.modern-hcode-table tr {
		display: block;
	}

	.modern-hcode-table thead tr {
		position: absolute;
		top: -9999px;
		left: -9999px;
	}

	.modern-hcode-table tr {
		background: #fff;
		border: 1px solid #e9ecef;
		border-radius: 8px;
		margin-bottom: 16px;
		padding: 16px;
		box-shadow: 0 2px 4px rgba(0,0,0,0.1);
	}

	.modern-hcode-table tr:hover {
		transform: none;
		box-shadow: 0 4px 8px rgba(0,0,0,0.15);
	}

	.modern-hcode-table td {
		border: none;
		border-bottom: 1px solid #f1f3f4;
		position: relative;
		padding: 12px 8px 12px 40%;
		margin-bottom: 8px;
		min-height: 40px;
		display: flex;
		align-items: center;
	}

	.modern-hcode-table td:last-child {
		border-bottom: none;
		margin-bottom: 0;
	}

	.modern-hcode-table td::before {
		content: attr(data-cell);
		position: absolute;
		left: 8px;
		top: 50%;
		transform: translateY(-50%);
		width: 35%;
		padding-right: 8px;
		white-space: nowrap;
		font-weight: 600;
		color: #495057;
		font-size: 0.875em;
		text-transform: uppercase;
		letter-spacing: 0.5px;
	}

	/* Mobile-specific styles */
	.table-controls {
		padding: 12px;
	}

	.table-controls .row > div {
		margin-bottom: 8px;
	}

	.table-controls .btn {
		width: 100%;
		margin-bottom: 4px;
	}

	.modern-pagination {
		justify-content: space-between;
		gap: 4px;
	}

	.modern-pagination a,
	.modern-pagination span {
		padding: 6px 8px;
		font-size: 0.875em;
	}

	/* Action buttons on mobile */
	.action-btn {
		padding: 4px 8px;
		font-size: 0.8em;
	}
}

/* Tablet responsive */
@media (min-width: 768px) and (max-width: 991.98px) {
	.modern-hcode-table {
		font-size: 0.9em;
	}
	
	.modern-hcode-table th,
	.modern-hcode-table td {
		padding: 10px 12px;
	}
	
	.table-controls .btn {
		padding: 6px 12px;
		font-size: 0.875em;
	}
}

/* Loading and indicators */
.htmx-indicator {
	display: none;
}

.htmx-request .htmx-indicator {
	display: block;
	text-align: center;
	padding: 20px;
}

.htmx-request .table-container {
	opacity: 0.7;
	pointer-events: none;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
	.modern-hcode-table tbody tr,
	.action-btn,
	.modern-pagination a,
	.table-controls .btn {
		transition: none;
	}
	
	.modern-hcode-table tbody tr:hover {
		transform: none;
	}
}

/* HCODE Display with colored first character */
.hcode-display {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.5px;
}

.hcode-first-char {
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  color: white;
  margin-right: 2px;
  transition: all 0.3s ease;
}

.hcode-first-char:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.hcode-remaining {
  background: #f8f9fa;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  color: #495057;
}

/* Character color mapping for HCODE first characters - REAL DATABASE CHARACTERS */
.hcode-first-char.char-a { background: linear-gradient(135deg, #667eea, #764ba2); } /* Province Public Health Office */
.hcode-first-char.char-b { background: linear-gradient(135deg, #f093fb, #f5576c); } /* District Public Health Office */
.hcode-first-char.char-c { background: linear-gradient(135deg, #4ECDC4, #44A08D); } /* Private Clinic */
.hcode-first-char.char-d { background: linear-gradient(135deg, #FBAB7E, #F7CE68); } /* Drugstore */
.hcode-first-char.char-e { background: linear-gradient(135deg, #FF6B6B, #FF8E53); } /* Hospitals */
.hcode-first-char.char-f { background: linear-gradient(135deg, #FF5722, #FF9800); } /* Government Hospital Outside MOH */
.hcode-first-char.char-g { background: linear-gradient(135deg, #4CAF50, #81C784); } /* Health Centers/Stations */
.hcode-first-char.char-h { background: linear-gradient(135deg, #E91E63, #AD1457); } /* Private Hospital */
.hcode-first-char.char-i { background: linear-gradient(135deg, #9C27B0, #673AB7); } /* Academic Center */

/* Legacy colors for backward compatibility */
.hcode-first-char.char-p { background: linear-gradient(135deg, #45B7D1, #96C93D); } /* Private - Blue/Green */
.hcode-first-char.char-m { background: linear-gradient(135deg, #4158D0, #C850C0); } /* Medical - Blue/Purple */
.hcode-first-char.char-n { background: linear-gradient(135deg, #0093E9, #80D0C7); } /* Nursing - Blue/Cyan */
.hcode-first-char.char-l { background: linear-gradient(135deg, #FBAB7E, #F7CE68); } /* Laboratory - Orange/Yellow */
.hcode-first-char.char-r { background: linear-gradient(135deg, #85FFBD, #FFFB7D); } /* Rehabilitation - Green/Yellow */
.hcode-first-char.char-s { background: linear-gradient(135deg, #667eea, #764ba2); } /* Specialized - Purple/Blue */
.hcode-first-char.char-u { background: linear-gradient(135deg, #f093fb, #f5576c); } /* University - Pink/Red */
.hcode-first-char.char-t { background: linear-gradient(135deg, #a8edea, #fed6e3); } /* Traditional - Light Blue/Pink */
.hcode-first-char.char-o { background: linear-gradient(135deg, #ff9a9e, #fecfef); } /* Others - Pink gradient */
.hcode-first-char.char-w { background: linear-gradient(135deg, #a18cd1, #fbc2eb); } /* Wellness - Purple/Pink */

/* Code Character Colors for About Page */
.code-character {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-weight: 600;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.code-character:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Different colors for different character types */
.code-character.char-h { background: linear-gradient(135deg, #FF6B6B, #FF8E53); }
.code-character.char-c { background: linear-gradient(135deg, #4ECDC4, #44A08D); }
.code-character.char-p { background: linear-gradient(135deg, #45B7D1, #96C93D); }
.code-character.char-g { background: linear-gradient(135deg, #F093FB, #F5576C); }
.code-character.char-m { background: linear-gradient(135deg, #4158D0, #C850C0); }
.code-character.char-n { background: linear-gradient(135deg, #0093E9, #80D0C7); }
.code-character.char-d { background: linear-gradient(135deg, #8EC5FC, #E0C3FC); }
.code-character.char-l { background: linear-gradient(135deg, #FBAB7E, #F7CE68); }
.code-character.char-r { background: linear-gradient(135deg, #85FFBD, #FFFB7D); }
.code-character.char-s { background: linear-gradient(135deg, #667eea, #764ba2); }
.code-character.char-u { background: linear-gradient(135deg, #f093fb, #f5576c); }
.code-character.char-e { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.code-character.char-t { background: linear-gradient(135deg, #a8edea, #fed6e3); }
.code-character.char-o { background: linear-gradient(135deg, #ff9a9e, #fecfef); }
.code-character.char-w { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }

/* Color Legend */
.color-legend {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 12px;
  padding: 1.5rem;
  border: 2px solid #e9ecef;
  margin-bottom: 1.5rem;
}

.color-legend h5 {
  color: #2c3e50;
  margin-bottom: 1rem;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem;
  background: white;
  border-radius: 8px;
  transition: all 0.3s ease;
  border: 1px solid #dee2e6;
}

.legend-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #adb5bd;
}

.legend-item span:last-child {
  font-size: 0.9rem;
  color: #495057;
  font-weight: 500;
}