/* ============================================================================
   DASHBOARD MODALS STYLING
   Copyright (C) 2025, CHIRP Software & Technologies (Pty) Ltd
   Created by: Charl Wessels - van As
   Version 1.0
   ============================================================================
*/

/* ============================================================================
   MODAL STRUCTURE & LAYOUT
   ============================================================================
*/

.modal {
	z-index: 1050 !important;
}

.modal.show {
	z-index: 1050 !important;
	display: flex !important;
	visibility: visible !important;
	opacity: 1 !important;
}

.modal:not(.show) {
	display: none !important;
	visibility: hidden !important;
	opacity: 0 !important;
}

.modal-backdrop {
	z-index: 1040 !important;
}

.modal-content {
	border-radius: 0.5rem;
	border: 1px solid rgba(0, 0, 0, 0.1);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
	z-index: 1050 !important;
}

.modal-header {
	border-bottom: 1px solid #e9ecef;
	background-color: #f8f9fa;
	padding: 1.5rem;
	border-radius: 0.5rem 0.5rem 0 0;
}

.modal-header .modal-title {
	font-weight: 600;
	color: #212529;
	font-size: 1.25rem;
}

.modal-body {
	padding: 1.5rem;
	background-color: #ffffff;
	overflow-y: auto;
	max-height: calc(100vh - 220px);
}

/* ============================================================================
   TAB NAVIGATION & STYLING
   ============================================================================
*/

.nav-tabs {
	border-bottom: 2px solid #dee2e6;
	gap: 0.5rem;
	padding: 0.5rem 0 0 0;
	margin-bottom: 1.5rem;
}

.nav-tabs .nav-link {
	color: #6c757d;
	border: none;
	border-bottom: 3px solid transparent;
	padding: 0.75rem 1.5rem;
	font-weight: 600;
	font-size: 1.05rem;
	transition: all 0.2s ease-in-out;
	cursor: pointer;
	background: none;
	pointer-events: auto;
	position: relative;
	z-index: 1;
}

.nav-tabs .nav-link:hover {
	color: #495057;
	border-bottom-color: #c3cfe2;
}

.nav-tabs .nav-link.active {
	color: #0d6efd;
	border-bottom-color: #0d6efd;
	background-color: transparent;
}

.tab-content {
	animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* ============================================================================
   TABLE STYLING
   ============================================================================
*/

.table {
	margin-bottom: 0;
	font-size: 0.9375rem;
}

.table thead {
	background-color: #f8f9fa;
	border-bottom: 2px solid #dee2e6;
}

.table thead th {
	font-weight: 600;
	color: #212529;
	padding: 0.75rem;
	vertical-align: middle;
	border: none;
}

.table tbody tr {
	border-bottom: 1px solid #dee2e6;
	transition: background-color 0.15s ease-in-out;
}

.table tbody tr:hover {
	background-color: #f8f9fa;
}

.table tbody td {
	padding: 0.75rem;
	vertical-align: middle;
	color: #495057;
}

.table tfoot {
	background-color: #f8f9fa;
	border-top: 2px solid #dee2e6;
}

.table tfoot th {
	font-weight: 600;
	color: #212529;
	padding: 0.75rem;
	border: none;
}

/* ============================================================================
   GL CODE GROUP ROWS - EXPANDABLE HEADERS
   ============================================================================
*/

.table-secondary {
	background-color: #e9ecef !important;
	color: #212529;
	font-weight: 600;
}

.table-secondary td {
	border-bottom: 1px solid #dee2e6;
}

.table-secondary:hover {
	background-color: #dee2e6 !important;
}

.toggle-icon {
	display: inline-block;
	margin-right: 0.5rem;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	font-size: 0.75rem;
	color: #495057;
}

.detail-row {
	display: none;
	background-color: #ffffff;
	font-size: 0.875rem;
	color: #6c757d;
}

.detail-row td {
	border-bottom: 1px solid #f0f0f0;
	padding: 0.5rem 0.75rem;
}

.detail-row td:first-child {
	padding-left: 2rem;
}

.detail-row:hover {
	background-color: #f9f9f9;
}

/* ============================================================================
   AMOUNT FORMATTING & ALIGNMENT
   ============================================================================
*/

.text-end {
	text-align: right !important;
	font-family: 'Courier New', monospace;
}

.amount-value {
	color: #495057;
	font-weight: 500;
}

.amount-total {
	font-weight: 600;
	color: #212529;
	font-size: 1.0625rem;
}

/* ============================================================================
   EMPTY STATE & ERROR MESSAGES
   ============================================================================
*/

.text-muted {
	color: #6c757d !important;
	font-size: 0.9375rem;
}

.text-danger {
	color: #dc3545 !important;
	font-weight: 500;
}

.text-center {
	text-align: center;
	padding: 2rem 1rem !important;
}

/* ============================================================================
   RESPONSIVE BEHAVIOR
   ============================================================================
*/

@media (max-width: 768px) {
	.modal-dialog {
		margin: 0 !important;
		min-height: 100vh;
	}

	.modal-body {
		padding: 1rem;
		max-height: calc(100vh - 150px);
	}

	.table {
		font-size: 0.875rem;
	}

	.table thead th,
	.table tbody td {
		padding: 0.5rem;
	}

	.nav-tabs {
		padding: 0.25rem 0 0 0;
	}

	.nav-tabs .nav-link {
		padding: 0.5rem 1rem;
		font-size: 0.875rem;
	}

	.toggle-icon {
		margin-right: 0.25rem;
	}
}

/* ============================================================================
   SCROLLBAR STYLING (Optional - for better UX)
   ============================================================================
*/

.modal-body::-webkit-scrollbar {
	width: 8px;
}

.modal-body::-webkit-scrollbar-track {
	background: #f1f1f1;
	border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
	background: #888;
	border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
	background: #555;
}

/* ============================================================================
   LOADING STATE
   ============================================================================
*/

.loading-state {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 3rem;
	color: #6c757d;
	font-size: 0.95rem;
}

.loading-state .spinner-border {
	margin-right: 1rem;
}

/* ============================================================================
   CONSISTENCY WITH STEFAN MODAL EXAMPLE
   ============================================================================
*/

.modal-lg {
	max-width: 900px;
}

.modal-fullscreen-lg-down .modal-content {
	border-radius: 0;
}

.modal-footer {
	border-top: 1px solid #e9ecef;
	padding: 1rem 1.5rem;
	background-color: #f8f9fa;
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
}

@media (max-width: 991px) {
	.modal-fullscreen-lg-down {
		max-width: 100%;
		margin: 0;
	}

	.modal-fullscreen-lg-down .modal-content {
		border-radius: 0;
	}
}

/* ============================================================================
   FIX: ENSURE MODAL INTERACTIVITY
   ============================================================================
*/

/* Ensure modal content can receive events */
.modal-content {
	pointer-events: auto;
}

/* Ensure tab buttons are clickable */
.nav-tabs .nav-link {
	pointer-events: auto;
}

/* Ensure body doesn't interfere when modal is open */
body.modal-open {
	overflow: hidden;
}
