/* Database Explorer Styles */

/* Table container with fixed height */
.table-responsive {
	min-height: 400px;
	position: relative;
}

/* Ensure table takes full height of container */
.table {
	width: 100%;
	margin-bottom: 0;
}

/* Empty table state */
.table:empty::after {
	content: "No records found";
	display: block;
	text-align: center;
	padding: 2rem;
	color: #6c757d;
	font-style: italic;
}

/* Empty table message styling */
.empty-table-message {
	min-height: 300px;
}

.empty-table-message td {
	vertical-align: middle;
}

.empty-table-message .bi-inbox {
	opacity: 0.5;
	display: block;
	margin: 0 auto;
}

/* Truncate long text in table cells */
.table td.text-break {
	max-width: 300px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Date column styling */
.table td.date-column {
	font-family: monospace;
	background-color: rgba(0, 123, 255, 0.05);
}

/* Hover effect for table rows */
.table tbody tr:hover {
	background-color: rgba(0, 123, 255, 0.1);
}

/* Custom styling for exports */
.btn-success {
	margin-left: 8px;
}

/* Table header styling */
.table-dark th {
	font-weight: 600;
	text-transform: uppercase;
	font-size: 0.85rem;
	padding: 12px 8px;
}

/* Sorting styles */
.table-dark th a {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0;
	transition: all 0.2s;
}

.table-dark th a:hover {
	opacity: 0.9;
}

.table-dark th a i {
	margin-left: 5px;
	font-size: 0.9rem;
}

/* Card styling */
.card {
	border-radius: 8px;
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
	margin-bottom: 2rem;
}

.card-header {
	background-color: #f8f9fa;
	border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

/* Make pagination more prominent */
.pagination {
	margin-top: 1.5rem;
}

.page-link {
	color: #007bff;
	background-color: #fff;
	border: 1px solid #dee2e6;
}

.page-item.active .page-link {
	background-color: #007bff;
	border-color: #007bff;
}

/* JSON/pre formatting */
pre {
	margin: 0;
	font-size: 0.85rem;
	white-space: pre-wrap;
}

/* Code styling for home page */
code {
	background: #f0f0f0;
	padding: 2px 5px;
	border-radius: 3px;
	font-family: monospace;
}

/* Date filter styling */
.date-filter-form {
	background-color: #f8f9fa;
	padding: 15px;
	border-radius: 5px;
	margin-bottom: 15px;
}

.date-filter-form .form-label {
	font-weight: 600;
	font-size: 0.85rem;
	margin-bottom: 0.25rem;
}

.date-filter-form .form-select,
.date-filter-form .form-control {
	font-size: 0.9rem;
	border-radius: 4px;
}

.date-filter-form .form-control[type="date"] {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, sans-serif;
}

.date-filter-form .btn-primary {
	font-weight: 500;
}

/* Active filters styling */
.active-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 10px;
}

.filter-badge {
	display: inline-flex;
	align-items: center;
	background-color: #e9f5ff;
	color: #0066cc;
	border-radius: 16px;
	padding: 4px 12px;
	font-size: 0.85rem;
}

.filter-badge .filter-label {
	font-weight: 600;
	margin-right: 5px;
}

.filter-badge .filter-value {
	font-weight: normal;
}

/* Responsive adjustments */
@media (max-width: 768px) {
	.table td.text-break {
		max-width: 150px;
	}

	.date-filter-form .col-md-3 {
		margin-bottom: 10px;
	}
	
	/* Hide desktop elements on mobile */
	.d-none.d-md-block {
		display: none !important;
	}
	
	/* Show mobile elements */
	.d-block.d-md-none {
		display: block !important;
	}
	
	/* Ensure mobile database views handle overflow properly */
	.mobile-database-explorer,
	.mobile-database-show {
		max-width: 100vw;
		overflow-x: hidden;
	}
	
	/* Better field value handling */
	.mobile-record-card .field-value {
		word-break: break-all;
		overflow-wrap: break-word;
		hyphens: auto;
		max-width: 100%;
		text-align: left;
	}
	
	/* Improve grid layout on very small screens */
	.mobile-record-card .record-field {
		grid-template-columns: minmax(80px, 35%) 1fr;
	}
	
	/* Handle long webhook payloads */
	.webhook-payload-cell {
		max-width: calc(100vw - 3rem);
	}
}

/* Webhook Payload Cell Styling */
.webhook-payload-cell {
	font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
	font-size: 0.85rem;
	padding: 4px 8px;
	background-color: rgba(13, 202, 240, 0.1);
	border-radius: 4px;
	display: inline-block;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	transition: all 0.2s ease;
}

.webhook-payload-cell:hover {
	background-color: rgba(13, 202, 240, 0.2);
	transform: scale(1.02);
	box-shadow: 0 2px 8px rgba(13, 202, 240, 0.3);
}

/* Webhook Modal Styling */
.modal-xl {
	max-width: 90vw;
}

#webhookPayloadModal .modal-content {
	height: 80vh;
	display: flex;
	flex-direction: column;
}

#webhookPayloadModal .modal-body {
	flex: 1;
	overflow: hidden;
	padding: 1.5rem;
}

.webhook-payload-container {
	height: 100%;
	border: 1px solid #dee2e6;
	border-radius: 6px;
	overflow: hidden;
	background-color: #f8f9fa;
}

.webhook-payload-json-display {
	margin: 0;
	padding: 1.5rem;
	height: 100%;
	overflow: auto;
	background-color: #2d3748;
	color: #e2e8f0;
	font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
	font-size: 0.875rem;
	line-height: 1.5;
	white-space: pre-wrap;
	word-wrap: break-word;
	border: none;
	tab-size: 2;
}

/* Custom scrollbar for JSON display */
.webhook-payload-json-display::-webkit-scrollbar {
	width: 12px;
	height: 12px;
}

.webhook-payload-json-display::-webkit-scrollbar-track {
	background: rgba(255, 255, 255, 0.1);
	border-radius: 6px;
}

.webhook-payload-json-display::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.3);
	border-radius: 6px;
}

.webhook-payload-json-display::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.5);
}

.webhook-payload-json-display::-webkit-scrollbar-corner {
	background: rgba(255, 255, 255, 0.1);
}

/* Modal header styling */
#webhookPayloadModal .modal-header {
	background-color: #f8f9fa;
	border-bottom: 1px solid #dee2e6;
	padding: 1rem 1.5rem;
}

#webhookPayloadModal .modal-title {
	color: #495057;
	font-weight: 600;
}

/* Copy button styling */
#copyPayloadBtn {
	transition: all 0.2s ease;
}

#copyPayloadBtn:hover {
	transform: translateY(-1px);
	box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

#copyPayloadBtn.copied {
	background-color: #28a745;
	border-color: #28a745;
	color: white;
}

/* Warning styling for invalid JSON */
.webhook-payload-cell.text-warning {
	background-color: rgba(255, 193, 7, 0.1);
	border-left: 3px solid #ffc107;
}

.webhook-payload-cell.text-warning:hover {
	background-color: rgba(255, 193, 7, 0.2);
	box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

/* Empty payload styling */
.webhook-payload-cell .text-muted {
	font-style: italic;
	color: #6c757d !important;
}

/* Responsive modal adjustments */
@media (max-width: 768px) {
	.modal-xl {
		max-width: 95vw;
	}

	#webhookPayloadModal .modal-content {
		height: 85vh;
	}

	.webhook-payload-json-display {
		font-size: 0.75rem;
		padding: 1rem;
	}
}

/* JSON display area in modal */
#webhookPayloadContent {
	background-color: #1e1e1e;
	color: #d4d4d4;
	padding: 20px;
	border-radius: 8px;
	font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
	font-size: 13px;
	line-height: 1.5;
	white-space: pre;
	overflow-wrap: break-word;
	word-break: break-all;
	overflow-y: auto;
	border: 1px solid #404040;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);

	/* Improve text selection */
	-webkit-user-select: text;
	-moz-user-select: text;
	-ms-user-select: text;
	user-select: text;

	/* Better scrollbar styling */
	scrollbar-width: thin;
	scrollbar-color: #555 #1e1e1e;
}

#webhookPayloadContent::-webkit-scrollbar {
	width: 8px;
}

#webhookPayloadContent::-webkit-scrollbar-track {
	background: #1e1e1e;
	border-radius: 4px;
}

#webhookPayloadContent::-webkit-scrollbar-thumb {
	background: #555;
	border-radius: 4px;
}

#webhookPayloadContent::-webkit-scrollbar-thumb:hover {
	background: #777;
}

/* Improve readability of JSON structure */
#webhookPayloadContent {
	/* Add subtle highlighting for better structure visibility */
	text-shadow: 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Copy button styling */
.btn-outline-secondary {
	border-color: #6c757d;
	color: #6c757d;
	transition: all 0.2s ease;
}

.btn-outline-secondary:hover {
	background-color: #6c757d;
	border-color: #6c757d;
	color: white;
}

.btn-success {
	background-color: #198754;
	border-color: #198754;
	transition: all 0.2s ease;
}

/* Accordion styling for empty tables */
#emptyTablesAccordion {
	border-top: 2px solid #dee2e6;
	padding-top: 1rem;
}

#emptyTablesAccordion .accordion-button {
	background-color: #f8f9fa;
	color: #6c757d;
	font-weight: 500;
}

#emptyTablesAccordion .accordion-button:not(.collapsed) {
	background-color: #e9ecef;
	color: #495057;
}

#emptyTablesAccordion .accordion-button:focus {
	box-shadow: none;
	border-color: #dee2e6;
}

#emptyTablesAccordion .accordion-body {
	padding: 0.5rem;
	background-color: #fafbfc;
}

/* Badge styling for empty table count */
.badge.bg-secondary {
	font-size: 0.75rem;
	padding: 0.25rem 0.5rem;
}

/* Disabled button styling */
.btn-outline-success[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Last updated column styling - only for database explorer tables */
.database-explorer-table td:nth-child(3) {
	font-family: monospace;
	white-space: nowrap;
}

/* Mobile-specific styles for Database Explorer */
@media (max-width: 768px) {
	/* Mobile filter form styles */
	.mobile-filter-form {
		background-color: #f8f9fa;
		padding: 1rem;
		border-radius: 8px;
	}
	
	.mobile-filter-form .form-label {
		font-weight: 600;
		font-size: 0.875rem;
		margin-bottom: 0.5rem;
	}
	
	.mobile-filter-form .form-control,
	.mobile-filter-form .form-select {
		font-size: 16px; /* Prevents zoom on iOS */
		min-height: 44px;
		border-radius: 6px;
	}
	
	/* Active filters mobile styling */
	.active-filters-mobile {
		margin-top: 1rem;
		padding: 1rem;
		background: white;
		border-radius: 8px;
		border: 1px solid #dee2e6;
	}
	
	/* Mobile modal adjustments */
	.modal-fullscreen .modal-content {
		border-radius: 0;
	}
	
	.modal-fullscreen .modal-body {
		padding: 0;
		display: flex;
		flex-direction: column;
	}
	
	/* Improved touch targets */
	.mobile-database-explorer .btn,
	.mobile-database-show .btn {
		min-height: 44px;
		padding: 0.5rem 1rem;
	}
	
	.mobile-database-explorer .btn-sm,
	.mobile-database-show .btn-sm {
		min-height: 36px;
		padding: 0.375rem 0.75rem;
	}
	
	/* Prevent horizontal scroll */
	.mobile-database-explorer,
	.mobile-database-show {
		overflow-x: hidden;
	}
	
	/* Mobile webhook payload display */
	.webhook-payload-json-display {
		font-size: 0.75rem !important;
		padding: 1rem !important;
	}
	
	/* Improve readability on small screens */
	.mobile-record-card .field-value {
		word-break: break-word;
		hyphens: auto;
	}
	
	/* Sticky elements z-index management */
	.mobile-db-header {
		z-index: 1020;
	}
	
	.mobile-webhook-toolbar {
		z-index: 1021;
	}
}

/* Touch-specific enhancements */
@media (hover: none) and (pointer: coarse) {
	/* Remove hover effects on mobile */
	.mobile-table-card:hover,
	.mobile-record-card:hover {
		transform: none;
		box-shadow: 0 2px 4px rgba(0,0,0,0.05);
	}
	
	/* Active states for touch */
	.mobile-table-card:active,
	.mobile-record-card:active {
		transform: scale(0.98);
		opacity: 0.95;
	}
	
	/* Larger tap targets for links in tables */
	.mobile-record-card a {
		padding: 0.25rem 0.5rem;
		margin: -0.25rem -0.5rem;
		display: inline-block;
	}
}

/* Small phones (below 576px) */
@media (max-width: 576px) {
	/* Reduce padding on very small screens */
	.mobile-database-explorer .container-fluid {
		padding-left: 0.75rem;
		padding-right: 0.75rem;
		max-width: 100%;
		overflow-x: hidden;
	}
	
	.mobile-filters-content {
		padding: 0.75rem;
	}
	
	.mobile-data-container {
		padding: 0.5rem;
		max-width: 100%;
		overflow-x: hidden;
	}
	
	/* Stack pagination controls vertically on very small screens */
	.mobile-pagination .pagination-controls {
		flex-wrap: wrap;
		justify-content: center;
	}
	
	.mobile-pagination .form-select {
		margin: 0.5rem 0;
		width: 100% !important;
		max-width: 200px;
	}
	
	/* Ensure cards don't overflow */
	.mobile-table-card,
	.mobile-record-card {
		max-width: 100%;
		word-wrap: break-word;
		overflow-wrap: break-word;
	}
	
	/* Handle long table names */
	.table-name {
		max-width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	
	/* Adjust button groups for mobile */
	.table-card-actions {
		flex-wrap: wrap;
	}
	
	.table-card-actions .btn {
		min-width: 0;
		flex: 1 1 45%;
	}
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
	.mobile-db-header {
		position: relative;
		padding: 0.5rem;
	}
	
	.mobile-metric-card {
		padding: 0.5rem;
	}
	
	.mobile-record-card {
		padding: 0.75rem;
	}
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
	/* Fix for iOS momentum scrolling */
	.mobile-data-container {
		-webkit-overflow-scrolling: touch;
	}
	
	/* Fix for iOS input zoom */
	.mobile-filter-form input[type="text"],
	.mobile-filter-form input[type="date"],
	.mobile-filter-form select {
		font-size: 16px;
	}
}

/* Print styles */
@media print {
	/* Hide mobile views when printing */
	.mobile-database-explorer,
	.mobile-database-show {
		display: none !important;
	}
	
	/* Show desktop view when printing */
	.d-none.d-md-block {
		display: block !important;
	}
}
