/* ========== Brand Theme ========== */
/* Primary: #0056b3 (blue), Text: #313131, BG: #ffffff */

/* ========== Navbar Styles ========== */

.navbar-custom {
	background: #ffffff !important;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
	padding: 0.65rem 1rem;
	border-bottom: 2px solid #f0f0f0;
	transition: all 0.3s ease;
}

.navbar-custom .navbar-brand {
	display: flex;
	align-items: center;
	font-weight: 700;
	font-size: 1.2rem;
	letter-spacing: 0.3px;
	color: #313131 !important;
	padding: 0;
	margin-right: 1.5rem;
}

.navbar-custom .navbar-brand .navbar-logo {
	height: 78px;
	width: auto;
	margin-right: 8px;
	filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

.navbar-custom .navbar-brand .brand-text {
	color: #313131;
}

.navbar-custom .navbar-nav .nav-link {
	color: #555555 !important;
	padding: 0.5rem 0.7rem;
	margin: 0 0.1rem;
	border-radius: 4px;
	transition: all 0.2s ease;
	font-size: 0.88rem;
	font-weight: 500;
	position: relative;
}

.navbar-custom .navbar-nav .nav-link:hover {
	color: #0056b3 !important;
	background: rgba(0, 86, 179, 0.06);
}

.navbar-custom .navbar-nav .nav-item.active > .nav-link {
	color: #0056b3 !important;
	background: rgba(0, 86, 179, 0.08);
}

.navbar-custom .navbar-nav .nav-item.active > .nav-link::after {
	content: "";
	position: absolute;
	bottom: 0;
	left: 20%;
	width: 60%;
	height: 2px;
	background: #0056b3;
	border-radius: 2px;
}

.navbar-custom .nav-item.dropdown > .nav-link.dropdown-toggle::after {
	border-top-color: #999;
	transition: transform 0.3s ease;
}

.navbar-custom .nav-item.dropdown:hover > .nav-link.dropdown-toggle::after {
	transform: rotate(180deg);
}

.dropdown-menu-custom {
	background: #ffffff;
	border: 1px solid #e8e8e8;
	border-radius: 8px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
	padding: 0.4rem;
	margin-top: 6px !important;
	min-width: 200px;
	animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
	from {
		opacity: 0;
		transform: translateY(-5px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.dropdown-menu-custom .dropdown-item {
	color: #444444;
	padding: 0.45rem 1rem;
	border-radius: 5px;
	transition: all 0.15s ease;
	font-size: 0.88rem;
}

.dropdown-menu-custom .dropdown-item:hover {
	background: rgba(0, 86, 179, 0.08);
	color: #0056b3;
}

.dropdown-menu-custom .dropdown-divider {
	border-top-color: #eee;
	margin: 0.25rem 0;
}

.dropdown-menu-custom .text-danger {
	color: #dc3545 !important;
}

.dropdown-menu-custom .text-danger:hover {
	background: rgba(220, 53, 69, 0.08) !important;
	color: #dc3545 !important;
}

@media (min-width: 992px) {
	.navbar-custom .nav-item.dropdown:hover .dropdown-menu-custom {
		display: block;
	}
}

.navbar-custom .navbar-toggler {
	border: 1px solid #ddd;
	padding: 0.3rem 0.5rem;
}

.navbar-custom .navbar-toggler-icon {
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(0,0,0,0.5)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

@media (max-width: 991.98px) {
	.navbar-custom { padding: 0.35rem 0; }
	.navbar-custom .navbar-brand .navbar-logo { height: 40px; width: auto; }
	.navbar-custom .navbar-nav .nav-link { padding: 0.5rem 0.8rem; color: #555 !important; }
	.navbar-custom .navbar-nav .nav-link:hover { background: rgba(0, 86, 179, 0.06); }
	.navbar-custom .navbar-nav .nav-item.active > .nav-link {
		background: rgba(0, 86, 179, 0.08);
		border-left: 3px solid #0056b3;
		border-radius: 0 4px 4px 0;
	}
	.navbar-custom .navbar-nav .nav-item.active > .nav-link::after {
		display: none;
	}
	.dropdown-menu-custom { background: transparent; border: none; box-shadow: none; padding-left: 1rem; animation: none; }
	.dropdown-menu-custom .dropdown-item { color: #555; padding: 0.35rem 1rem; }
}

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	color: #313131;
	background: #f8f9fa;
}

h2 {
	color: #313131;
	font-weight: 600;
	font-size: 1.5rem;
	margin-bottom: 1rem;
}

input.form-control {
	border-radius: 4px;
	padding: 0.3em 0.5em;
	font-size: 0.85em;
	border: 1px solid #ddd;
}

input.form-control:focus {
	border-color: #0056b3;
	box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.15);
}

.btn-primary {
	background: #0056b3;
	border-color: #0056b3;
}
.btn-primary:hover {
	background: #004494;
	border-color: #004494;
}
.btn-success {
	background: #28a745;
	border-color: #28a745;
}
.btn-outline-primary {
	color: #0056b3;
	border-color: #0056b3;
}
.btn-outline-primary:hover {
	background: #0056b3;
	color: #fff;
}

#invoice-form input{ font-size: 0.9em; color: #313131; }
#invoice-form-items-table { font-size: 0.8em; }
input.form-control[type=number] { -moz-appearance: none; -webkit-appearance: textfield; }
.table-bordered td.form-input-td { padding: 0; vertical-align: middle; }
.table-bordered td, .table-bordered th { padding: 0.25em; }
.table-bordered tbody td, .table-bordered tbody th, .table-bordered thead th, .table-bordered thead td { background: #f9f9f9; }
.two-col-form td, .two-col-form th { width: 25%; }

#customer_search_bar, #product_search_bar, #supplier_search_bar {
	display: none; background: #fff; width: 20em; height: 100%; position: absolute;
	right: 0; top: 0; box-shadow: 0 0 1em rgba(0,0,0,0.2); padding: 0.2em; z-index: 1000; border-left: 1px solid #eee;
}

.customer-search-result, .product-search-result {
	padding: 0.3em; margin: 0.3em; border-bottom: 1px solid #eee; cursor: pointer; transition: background 0.15s;
}
.customer-search-result:hover, .product-search-result:hover { background: #f0f4fb; }

[readonly] { caret-color: transparent; transition: none; border: none; }
[readonly]:focus { caret-color: transparent; box-shadow: none; border: none; }
.table-invoice td, .table-invoice th { border: solid #dee2e6 1px; padding: .25rem; }
#table-invoice-total-row { border-top: 2px solid #939393; background: white; }
#invoice-grand-total-table td { font-weight: bold; padding: .25rem; }
#invoice-signature-text-row { border-top: 2px solid #333; }
#invoice-signature-row { border-bottom: 2px solid #333; height: 4em; }

#add_customer_btn, #add_product_btn, #add_supplier_btn { float: right; }
#inventory-table tr:hover { cursor: pointer; }
#book-table tr:hover { cursor: pointer; }
#invoice_profile_data { white-space: pre-line; }

@page { size: auto; margin: 5mm 5mm 5mm 5mm; }
#login-card { margin-top: 5em; text-align: center; }

.card { border: 1px solid #e8e8e8; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.card-header { background: #f8f9fa; border-bottom: 1px solid #e8e8e8; }
.badge-primary { background: #0056b3; }
.badge-success { background: #28a745; }
.badge-warning { background: #ffc107; color: #333; }
.badge-danger { background: #dc3545; }
.badge-info { background: #17a2b8; }

.table thead th { border-bottom: 2px solid #dee2e6; font-weight: 600; color: #555; font-size: 0.85rem; }
.modal-header { border-bottom: 1px solid #e8e8e8; }
.modal-footer { border-top: 1px solid #e8e8e8; }

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
	background: #0056b3 !important; border-color: #0056b3 !important; color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
	background: rgba(0,86,179,0.1) !important; border-color: rgba(0,86,179,0.2) !important;
}

.print-logo { max-height: 50px; margin-bottom: 8px; }

/* ========== Keyboard Shortcut Styles ========== */

.dropdown-menu-custom .dropdown-item kbd {
	float: right;
	font-size: 0.72rem;
	padding: 1px 5px;
	border-radius: 3px;
	background: #f1f3f5;
	border: 1px solid #dee2e6;
	color: #868e96;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	line-height: 1.4;
	margin-left: 12px;
	margin-top: 1px;
}

.keyboard-toggle {
	border: none !important;
	opacity: 0.4;
	transition: opacity 0.2s;
}
.keyboard-toggle:hover {
	opacity: 1;
}
.keyboard-toggle kbd.shortcut-hint {
	font-size: 0.78rem;
	padding: 1px 7px;
	border-radius: 3px;
	background: #f1f3f5;
	border: 1px solid #ced4da;
	color: #868e96;
	cursor: pointer;
}

/* Shortcuts Help Overlay */
.shortcuts-help-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 9999;
	align-items: center;
	justify-content: center;
	overflow-y: auto;
	padding: 20px;
}
.shortcuts-help-overlay.show {
	display: flex;
}
.shortcuts-help-modal {
	background: #fff;
	border-radius: 12px;
	max-width: 480px;
	width: 100%;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	animation: modalFadeIn 0.2s ease;
}
@keyframes modalFadeIn {
	from { opacity: 0; transform: translateY(-10px) scale(0.98); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}
.shortcuts-help-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 20px;
	border-bottom: 1px solid #e9ecef;
}
.shortcuts-help-header .close {
	font-size: 1.5rem;
	font-weight: 700;
	color: #868e96;
	border: none;
	background: none;
	cursor: pointer;
	padding: 0;
	line-height: 1;
}
.shortcuts-help-body {
	padding: 16px 20px;
}
.shortcut-group {
	margin-bottom: 16px;
}
.shortcut-group h6 {
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	color: #868e96;
	margin-bottom: 8px;
	font-weight: 600;
}
.shortcut-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 4px 0;
	font-size: 0.88rem;
}
.shortcut-row span {
	color: #313131;
}
.shortcut-row kbd {
	font-size: 0.75rem;
	padding: 2px 8px;
	border-radius: 4px;
	background: #f1f3f5;
	border: 1px solid #dee2e6;
	color: #495057;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.shortcuts-help-footer {
	padding: 12px 20px;
	border-top: 1px solid #e9ecef;
	text-align: center;
}
.shortcuts-help-footer kbd {
	font-size: 0.72rem;
	padding: 1px 5px;
	border-radius: 3px;
	background: #f1f3f5;
	border: 1px solid #dee2e6;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (max-width: 500px) {
	.shortcuts-help-modal { max-width: 100%; margin: 10px; }
	.shortcut-row { font-size: 0.82rem; }
}

@media (max-width: 991.98px) {
	.keyboard-toggle {
		display: none;
	}
	.dropdown-menu-custom .dropdown-item kbd {
		display: none;
	}
}

/* ========== Mobile Off-Canvas Drawer ========== */

.drawer-backdrop {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 1040;
	opacity: 0;
	transition: opacity 0.3s ease;
}
.drawer-backdrop.show {
	display: block;
	opacity: 1;
}

.mobile-drawer {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: 300px;
	max-width: 85vw;
	background: #ffffff;
	z-index: 1050;
	box-shadow: 2px 0 30px rgba(0,0,0,0.15);
	transform: translateX(-100%);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.mobile-drawer.open {
	transform: translateX(0);
}

.drawer-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #e9ecef;
	background: #f8f9fa;
	flex-shrink: 0;
}
.drawer-title {
	font-size: 1rem;
	color: #313131;
	text-transform: uppercase;
	letter-spacing: 1px;
}
.drawer-close {
	background: none;
	border: none;
	font-size: 1.6rem;
	color: #868e96;
	cursor: pointer;
	padding: 0 4px;
	line-height: 1;
	transition: color 0.2s;
}
.drawer-close:hover {
	color: #dc3545;
}

.drawer-body {
	overflow-y: auto;
	overflow-x: hidden;
	flex: 1;
	padding: 8px 0;
	-webkit-overflow-scrolling: touch;
}

.drawer-nav {
	list-style: none;
	padding: 0;
	margin: 0;
}
.drawer-nav li {
	margin: 0;
}
.drawer-section-label {
	padding: 12px 20px 4px;
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1.2px;
	color: #adb5bd;
}
.drawer-link {
	display: flex;
	align-items: center;
	padding: 12px 20px;
	color: #444;
	font-size: 0.92rem;
	text-decoration: none;
	transition: all 0.15s ease;
	border-left: 3px solid transparent;
}
.drawer-link i {
	width: 20px;
	text-align: center;
	color: #868e96;
	transition: color 0.15s;
}
.drawer-link:hover {
	background: rgba(0, 86, 179, 0.06);
	color: #0056b3;
	text-decoration: none;
	border-left-color: #0056b3;
}
.drawer-link:hover i {
	color: #0056b3;
}
.drawer-link.text-danger:hover {
	background: rgba(220, 53, 69, 0.08);
	color: #dc3545;
	border-left-color: #dc3545;
}
.drawer-link.text-danger:hover i {
	color: #dc3545;
}

.drawer-divider {
	height: 1px;
	background: #e9ecef;
	margin: 8px 16px;
}

@media (min-width: 992px) {
	.drawer-backdrop,
	.mobile-drawer {
		display: none !important;
	}
}

/* ========== Responsive Table Improvements ========== */

@media (max-width: 767.98px) {
	.table-responsive-stack {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
	.table-responsive-stack table {
		min-width: 600px;
	}
	.card .dataTables_wrapper {
		overflow-x: auto;
	}
	.dataTables_wrapper .dataTables_filter {
		text-align: left !important;
		float: none !important;
		margin-bottom: 8px;
	}
	.dataTables_wrapper .dataTables_length {
		float: none !important;
		margin-bottom: 8px;
	}
	/* Card layout for small tables */
	.table-card-view thead {
		display: none;
	}
	.table-card-view tr {
		display: block;
		border: 1px solid #e8e8e8;
		border-radius: 6px;
		padding: 10px 12px;
		margin-bottom: 8px;
		background: white;
	}
	.table-card-view td {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 4px 0;
		border: none !important;
		font-size: 0.85rem;
	}
	.table-card-view td:before {
		content: attr(data-label);
		font-weight: 600;
		color: #555;
		margin-right: 12px;
		flex-shrink: 0;
	}
}

/* ========== Touch-Friendly Mobile ========== */

@media (max-width: 767.98px) {
	body {
		font-size: 15px;
	}
	.container, .container-fluid {
		padding-left: 12px;
		padding-right: 12px;
	}
	h2 {
		font-size: 1.25rem;
	}
	.card-body {
		padding: 12px;
	}
	.btn {
		padding: 0.4rem 0.75rem;
		font-size: 0.85rem;
	}
	.form-control {
		font-size: 16px; /* Prevent iOS zoom on focus */
		height: auto;
		padding: 10px 12px;
	}
	/* Stack form labels on mobile */
	.row.form-group,
	.form-group.row {
		flex-direction: column;
	}
	.row.form-group > [class*="col-"],
	.form-group.row > [class*="col-"] {
		max-width: 100%;
		flex: 0 0 100%;
		padding: 2px 0;
	}
	/* Better alert spacing */
	.alert {
		padding: 10px 14px;
		margin-bottom: 10px;
		font-size: 0.88rem;
	}
	/* Full-width buttons */
	.btn-block-mobile {
		width: 100%;
		display: block;
	}
	/* Card grid: single column on mobile */
	.row > [class*="col-"] {
		padding-left: 6px;
		padding-right: 6px;
	}
	/* Tab label sizing */
	.nav-label {
		font-size: 0.85rem;
	}
}