/*
Template: VerdaLink Dashboard - Mobile Responsive CSS
Author: Enhanced for Mobile Compatibility
Focus: Comprehensive mobile responsiveness for all pages and components
Version: 2.0 - Complete Mobile Optimization
*/

/* ================================================
   MOBILE FIRST RESPONSIVE DESIGN
   ================================================ */

/* Extra Large Devices (1400px and up) */
@media (min-width: 1400px) {
	.container {
		max-width: 1320px;
	}

	.page-summary-item {
		padding: 20px 25px;
	}

	.page-summary-item i {
		font-size: 2.5rem;
	}

	.page-summary-item .summary-text .value {
		font-size: 2.2rem;
	}
}

/* Large Devices (1200px to 1399px) */
@media (max-width: 1399px) {
	.iq-sidebar {
		width: 240px;
	}

	body.sidebar-main .content-page {
		margin-left: 240px;
	}

	.page-summary-item {
		padding: 18px 22px;
	}

	.page-summary-item i {
		font-size: 2.2rem;
	}

	.page-summary-item .summary-text .value {
		font-size: 2rem;
	}

	.iq-card-body {
		padding: 20px;
	}
}

/* Medium Large Devices (992px to 1199px) */
@media (max-width: 1199px) {
	.iq-sidebar {
		width: 220px;
	}

	body.sidebar-main .content-page {
		margin-left: 220px;
	}

	.page-summary-item {
		padding: 16px 20px;
	}

	.page-summary-item i {
		font-size: 2rem;
	}

	.page-summary-item .summary-text .value {
		font-size: 1.8rem;
	}

	.page-summary-item .summary-text .title {
		font-size: 0.9rem;
	}

	.iq-card-body {
		padding: 18px;
	}

	.navbar-list li>a {
		padding: 8px 12px;
	}

	.user-role-badge-gradient {
		font-size: 0.75rem;
		padding: 4px 8px;
	}
}

/* ================================================
   MOBILE SIDEBAR AND NAVIGATION
   ================================================ */

/* Medium Devices (768px to 991px) */
@media (max-width: 991px) {

	/* Sidebar Mobile Behavior */
	.iq-sidebar {
		position: fixed;
		left: -280px;
		top: 0;
		height: 100vh;
		z-index: 1050;
		transition: all 0.3s ease;
		box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
		width: 280px;
		max-width: 85vw;
	}

	body.sidebar-main .iq-sidebar {
		left: 0;
	}

	body.sidebar-main .content-page {
		margin-left: 0;
	}

	/* Top Navbar Mobile */
	.iq-top-navbar {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 1040;
		width: 100vw;
	}

	.iq-top-navbar .iq-navbar-custom .iq-menu-bt {
		display: block !important;
		position: absolute;
		right: 80px;
		top: 18px;
		z-index: 1060;
	}

	.navbar-toggler {
		display: block !important;
		position: absolute;
		right: 15px;
		top: 18px;
		z-index: 1060;
	}

	/* Content Area */
	.content-page {
		margin-left: 0;
		padding: 80px 15px 20px;
		width: 100vw;
	}

	/* Page Summary Bar */
	.page-summary-bar {
		flex-direction: column;
		gap: 15px;
		padding: 15px;
	}

	.page-summary-item {
		width: 100%;
		padding: 15px;
		text-align: center;
	}

	.page-summary-item i {
		font-size: 1.8rem;
		margin-bottom: 10px;
	}

	.page-summary-item .summary-text .value {
		font-size: 1.6rem;
	}

	.page-summary-item .summary-text .title {
		font-size: 0.85rem;
	}

	/* Cards */
	.iq-card {
		margin-bottom: 20px;
	}

	.iq-card-body {
		padding: 15px;
	}

	/* Tables */
	.table-responsive {
		font-size: 0.85rem;
	}

	.personnel-table,
	.vehicles-table,
	.system-logs-table {
		font-size: 0.85rem;
	}

	.personnel-table th,
	.vehicles-table th,
	.system-logs-table th {
		padding: 10px 8px;
		font-size: 0.8rem;
		font-weight: 600;
	}

	.personnel-table td,
	.vehicles-table td,
	.system-logs-table td {
		padding: 10px 8px;
		vertical-align: middle;
	}

	/* Mobile Navigation */
	.navbar-list {
		position: fixed;
		top: 65px;
		left: 0;
		right: 0;
		background: white;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
		padding: 15px;
		transform: translateY(-100%);
		transition: transform 0.3s ease;
		z-index: 1030;
	}

	.navbar-list.show {
		transform: translateY(0);
	}

	@keyframes slideDown {
		from {
			transform: translateY(-100%);
		}

		to {
			transform: translateY(0);
		}
	}

	.navbar-list>li>a {
		padding: 12px 15px;
		border-radius: 8px;
		margin: 2px 0;
	}

	.navbar-list>li>a:hover {
		background: rgba(0, 146, 69, 0.1);
	}

	.navbar-list>li>a:active {
		background: rgba(0, 146, 69, 0.2);
		transform: scale(0.98);
	}

	/* User Dropdown */
	.navbar-list li.dropdown>a#userDropdown {
		padding: 12px 15px;
		border-radius: 8px;
	}

	.user-role-badge-gradient {
		font-size: 0.7rem;
		padding: 4px 8px;
	}

	/* Notification Dropdown */
	.navbar-list .notification-dropdown-reworked {
		position: fixed;
		top: 70px;
		left: 10px;
		right: 10px;
		width: auto;
		max-width: none;
		max-height: 60vh;
		overflow-y: auto;
		border-radius: 12px;
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
	}

	/* Footer */
	.iq-footer {
		margin-left: 0;
		width: 100vw;
	}

	/* Map and Charts */
	.dashboard-map-preview-no-header {
		height: 300px;
	}

	.routes-charts-card .iq-card-body {
		max-height: 400px;
	}

	/* Personnel Grid */
	.personnel-grid {
		grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
		gap: 20px;
	}

	/* Route Cards */
	.route-card {
		margin-bottom: 15px;
	}

	.route-header-modern {
		padding: 15px;
	}

	.route-code-display {
		font-size: 0.85rem;
	}

	.route-name-display {
		font-size: 1rem;
	}

	.stats-badge {
		font-size: 0.75rem;
		padding: 4px 8px;
	}

	/* Container Grid */
	.containers-grid {
		grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
		gap: 15px;
	}

	.container-card-modern {
		padding: 15px;
	}

	/* Modals */
	.modal-dialog {
		margin: 10px;
		max-width: calc(100vw - 20px);
	}

	.modal-body {
		padding: 20px;
	}

	/* Forms */
	.form-control,
	.custom-select {
		font-size: 16px;
		padding: 12px 15px;
	}

	/* Buttons */
	.btn {
		padding: 10px 20px;
		font-size: 0.9rem;
		min-height: 44px;
	}

	.btn-sm {
		padding: 8px 16px;
		font-size: 0.85rem;
		min-height: 38px;
	}
}

/* ================================================
   SMALL MOBILE DEVICES (576px and below)
   ================================================ */

@media (max-width: 575px) {
	.page-summary-item {
		padding: 12px;
		font-size: 0.8rem;
	}

	.page-summary-item i {
		font-size: 1.5rem;
		margin-bottom: 8px;
	}

	.page-summary-item .summary-text .value {
		font-size: 1.3rem;
	}

	.page-summary-item .summary-text .title {
		font-size: 0.75rem;
	}

	.iq-card-body {
		padding: 12px;
	}

	.iq-card-header {
		padding: 15px 12px;
	}

	.personnel-table tbody td,
	.vehicles-table tbody td,
	.system-logs-table tbody td {
		padding: 8px 6px;
		font-size: 0.8rem;
	}

	.btn {
		padding: 8px 16px;
		font-size: 0.85rem;
		min-height: 40px;
	}

	.btn-sm {
		padding: 6px 12px;
		font-size: 0.8rem;
		min-height: 36px;
	}

	.iq-top-navbar .iq-navbar-custom .iq-menu-bt {
		right: 60px;
		top: 15px;
	}

	.navbar-toggler {
		right: 10px;
		top: 15px;
	}

	.navbar-list li.dropdown>a#userDropdown {
		padding: 10px 12px;
	}

	.user-role-badge-gradient {
		font-size: 0.65rem;
		padding: 3px 6px;
	}

	.dashboard-map-preview-no-header {
		height: 250px;
	}

	.routes-charts-card .iq-card-body {
		max-height: 350px;
	}

	.modal-dialog {
		margin: 5px;
		max-width: calc(100vw - 10px);
	}

	.modal-body {
		padding: 15px;
	}

	.iq-footer {
		padding: 10px 15px;
	}

	.iq-sidebar-logo a span {
		display: none;
	}

	.navbar-breadcrumb {
		font-size: 0.9rem;
	}

	.badge {
		font-size: 0.7rem;
		padding: 0.25em 0.5em;
	}

	.form-control-sm {
		height: calc(1.5em + 0.5rem + 2px);
		padding: 0.25rem 0.5rem;
		font-size: 0.8rem;
	}
}

/* ================================================
   EXTRA SMALL MOBILE DEVICES (375px and below)
   ================================================ */

@media (max-width: 375px) {
	.content-page {
		padding: 70px 10px 15px;
	}

	.page-summary-item {
		padding: 10px;
		font-size: 0.75rem;
	}

	.page-summary-item i {
		font-size: 1.3rem;
		margin-bottom: 6px;
	}

	.page-summary-item .summary-text .value {
		font-size: 1.1rem;
	}

	.page-summary-item .summary-text .title {
		font-size: 0.7rem;
	}

	.iq-card-body {
		padding: 10px;
	}

	.iq-card-header {
		padding: 12px 10px;
	}

	.btn {
		padding: 6px 12px;
		font-size: 0.8rem;
		min-height: 36px;
	}

	.dashboard-map-preview-no-header {
		height: 200px;
	}

	.routes-charts-card .iq-card-body {
		max-height: 300px;
	}
}

/* ================================================
   LANDSCAPE ORIENTATION FIXES
   ================================================ */

@media (max-width: 767px) and (orientation: landscape) {
	.content-page {
		padding: 60px 15px 10px;
	}

	.page-summary-bar {
		flex-direction: row;
		overflow-x: auto;
		padding: 10px;
	}

	.page-summary-item {
		min-width: 120px;
		flex: 0 0 auto;
		margin-right: 10px;
	}

	.dashboard-map-preview-no-header {
		height: 200px;
	}

	.routes-charts-card .iq-card-body {
		max-height: 250px;
	}

	.modal-dialog {
		margin: 5px;
		max-height: 90vh;
		overflow-y: auto;
	}
}

@media (min-width: 768px) and (max-width: 991px) and (orientation: landscape) {
	.page-summary-bar {
		flex-direction: row;
		overflow-x: auto;
		padding: 15px;
	}

	.page-summary-item {
		min-width: 150px;
		flex: 0 0 auto;
		margin-right: 15px;
		font-size: 0.9rem;
		padding: 12px 15px;
	}
}

/* ================================================
   HIGH DPI DISPLAYS
   ================================================ */

@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
	.iq-card {
		border-width: 0.5px;
	}

	.table-responsive {
		border-width: 0.5px;
	}

	.btn {
		border-width: 0.5px;
	}

	.form-control {
		border-width: 0.5px;
	}
}

/* ================================================
   PRINT STYLES
   ================================================ */

@media print {

	.iq-sidebar,
	.iq-top-navbar,
	.navbar-list,
	.modal,
	.dropdown-menu {
		display: none !important;
	}

	.content-page {
		margin-left: 0 !important;
		padding: 0 !important;
	}

	.iq-card {
		border: 1px solid #ccc !important;
		box-shadow: none !important;
	}

	.page-summary-bar {
		display: flex !important;
		flex-direction: row !important;
	}

	.personnel-table tbody tr,
	.vehicles-table tbody tr,
	.system-logs-table tbody tr {
		page-break-inside: avoid;
		border-bottom: 1px solid #ccc;
	}
}

/* ================================================
   ACCESSIBILITY AND PERFORMANCE
   ================================================ */

@media (prefers-reduced-motion: reduce) {

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

@media (prefers-color-scheme: dark) {
	/* Dark mode support can be added here */
}

@media (prefers-reduced-motion: no-preference) {

	.btn:focus,
	.form-control:focus,
	.dropdown-toggle:focus {
		transition: all 0.2s ease;
	}
}

/* ================================================
   TOUCH DEVICE OPTIMIZATIONS
   ================================================ */

@media (hover: none) and (pointer: coarse) {

	.btn,
	.custom-btn,
	.action-btn,
	.footer-btn {
		min-height: 44px;
		touch-action: manipulation;
	}

	.table-actions .btn-action {
		min-height: 44px;
		padding: 8px 12px;
	}

	.form-control,
	.custom-select {
		min-height: 44px;
		touch-action: manipulation;
	}
}

/* ================================================
   MOBILE SPECIFIC ENHANCEMENTS
   ================================================ */

/* Mobile scroll improvements */
@media (max-width: 767px) {
	.content-page {
		-webkit-overflow-scrolling: touch;
		scroll-behavior: smooth;
	}

	.iq-sidebar {
		-webkit-overflow-scrolling: touch;
		scroll-behavior: smooth;
	}

	/* Mobile card enhancements */
	.iq-card {
		border-radius: 12px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	}

	.iq-card:hover {
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	}

	.iq-card-header {
		border-radius: 12px 12px 0 0;
	}

	.iq-card-body {
		border-radius: 0 0 12px 12px;
	}

	/* Mobile form enhancements */
	.form-control,
	.custom-select {
		border-radius: 8px;
		border: 2px solid #e9ecef;
		font-size: 16px;
		padding: 12px 15px;
	}

	.form-control:focus,
	.custom-select:focus {
		border-color: var(--primary-green);
		box-shadow: 0 0 0 3px rgba(0, 146, 69, 0.1);
	}

	.form-control.is-invalid {
		border-color: #dc3545;
		box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
	}

	/* Mobile error states */
	.mobile-error {
		background: #f8d7da;
		border: 1px solid #f5c6cb;
		color: #721c24;
		padding: 10px;
		border-radius: 8px;
		margin: 10px 0;
		animation: fadeIn 0.3s ease;
	}

	@keyframes fadeIn {
		from {
			opacity: 0;
			transform: translateY(-10px);
		}

		to {
			opacity: 1;
			transform: translateY(0);
		}
	}

	/* Mobile table enhancements */
	.personnel-table tbody tr,
	.vehicles-table tbody tr,
	.system-logs-table tbody tr {
		transition: background-color 0.2s ease;
		border-radius: 8px;
		margin-bottom: 5px;
		animation: slideInUp 0.3s ease;
	}

	@keyframes slideInUp {
		from {
			opacity: 0;
			transform: translateY(20px);
		}

		to {
			opacity: 1;
			transform: translateY(0);
		}
	}

	.table-actions {
		flex-wrap: wrap;
		gap: 5px;
	}

	@keyframes fadeInScale {
		from {
			opacity: 0;
			transform: scale(0.9);
		}

		to {
			opacity: 1;
			transform: scale(1);
		}
	}

	/* Mobile modal enhancements */
	.modal-content {
		border-radius: 16px;
		border: none;
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
	}

	.modal-header {
		border-radius: 16px 16px 0 0;
		border-bottom: 2px solid #e9ecef;
	}

	.modal-body {
		padding: 20px;
	}

	.modal-footer {
		border-radius: 0 0 16px 16px;
		border-top: 2px solid #e9ecef;
	}

	.modal.show .modal-dialog {
		animation: modalSlideUp 0.3s ease;
	}

	@keyframes modalSlideUp {
		from {
			opacity: 0;
			transform: translateY(50px);
		}

		to {
			opacity: 1;
			transform: translateY(0);
		}
	}

	/* Mobile loading states */
	.loading-placeholder {
		background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
		background-size: 200% 100%;
		animation: loading 1.5s infinite;
		border-radius: 8px;
	}

	@keyframes loading {
		0% {
			background-position: 200% 0;
		}

		100% {
			background-position: -200% 0;
		}
	}

	/* Mobile notification dropdown */
	.notification-dropdown-reworked {
		border-radius: 12px;
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
	}

	.notification-dropdown-reworked .list-group-item {
		border-radius: 8px;
		margin-bottom: 5px;
		border: none;
		background: #f8f9fa;
	}

	.notification-dropdown-reworked .list-group-item:first-child {
		border-radius: 8px 8px 0 0;
	}

	.notification-dropdown-reworked .list-group-item:last-child {
		border-radius: 0 0 8px 8px;
		margin-bottom: 0;
	}

	/* Mobile chart enhancements */
	.chart-container {
		border-radius: 12px;
		overflow: hidden;
	}

	.apexcharts-canvas {
		border-radius: 12px;
	}

	.apexcharts-tooltip {
		border-radius: 8px;
	}

	.apexcharts-legend {
		font-size: 0.85rem;
		padding: 10px;
	}

	/* Mobile map enhancements */
	.dashboard-map-preview-no-header {
		border-radius: 12px;
		overflow: hidden;
	}

	.map-placeholder {
		border-radius: 12px;
	}

	.main-map-button {
		border-radius: 8px;
	}

	.main-map-button a {
		border-radius: 8px;
	}

	/* Mobile personnel card enhancements */
	.personnel-card {
		border-radius: 12px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
		transition: all 0.2s ease;
	}

	.personnel-card:hover {
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
		transform: translateY(-2px);
	}

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

	/* Mobile route card enhancements */
	.route-card {
		border-radius: 12px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	}

	.route-header-modern {
		border-radius: 12px 12px 0 0;
	}

	.route-details-modern {
		border-radius: 0 0 12px 12px;
	}

	.action-btn {
		border-radius: 8px;
		min-height: 44px;
	}

	.action-btn:active {
		transform: scale(0.95);
	}

	/* Mobile container card enhancements */
	.container-card-modern {
		border-radius: 12px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	}

	.container-card-headerbar {
		border-radius: 12px 12px 0 0;
	}

	.container-card-body {
		border-radius: 0;
	}

	.footer-btn {
		border-radius: 8px;
		min-height: 44px;
	}

	.footer-btn:active {
		transform: scale(0.95);
	}

	/* Mobile button enhancements */
	.btn,
	.custom-btn,
	.action-btn,
	.footer-btn {
		border-radius: 8px;
		font-weight: 600;
		transition: all 0.2s ease;
		border: none;
		position: relative;
		overflow: hidden;
	}

	.btn:focus,
	.custom-btn:focus,
	.action-btn:focus,
	.footer-btn:focus {
		outline: none;
		box-shadow: 0 0 0 3px rgba(0, 146, 69, 0.3);
	}

	/* High contrast mode support */
	@media (prefers-contrast: high) {
		.iq-card {
			border: 2px solid #000;
		}

		.btn {
			border: 2px solid #000;
		}
	}

	/* Reduced motion support */
	@media (prefers-reduced-motion: reduce) {

		.page-summary-item,
		.personnel-card,
		.route-card,
		.container-card-modern {
			animation: none;
			transition: none;
		}
	}

	/* Mobile image optimization */
	img[data-src] {
		opacity: 0;
		transition: opacity 0.3s ease;
	}

	img[data-src].loaded {
		opacity: 1;
	}

	/* Mobile chart loading */
	.chart-container {
		position: relative;
		background: #f8f9fa;
		border-radius: 12px;
		overflow: hidden;
	}

	.chart-container.loaded {
		background: transparent;
	}

	/* Mobile error handling */
	.mobile-error {
		background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
		border: 2px solid #f5c6cb;
		color: #721c24;
		padding: 15px;
		border-radius: 12px;
		margin: 15px 0;
		position: relative;
		overflow: hidden;
		animation: slideInRight 0.3s ease;
	}

	.mobile-error::before {
		content: '⚠️';
		position: absolute;
		left: 15px;
		top: 50%;
		transform: translateY(-50%);
		font-size: 1.2rem;
	}

	@keyframes slideInRight {
		from {
			opacity: 0;
			transform: translateX(30px);
		}

		to {
			opacity: 1;
			transform: translateX(0);
		}
	}

	/* Mobile success states */
	.mobile-success {
		background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
		border: 2px solid #c3e6cb;
		color: #155724;
		padding: 15px;
		border-radius: 12px;
		margin: 15px 0;
		position: relative;
		overflow: hidden;
		animation: slideInRight 0.3s ease;
	}

	.mobile-success::before {
		content: '✅';
		position: absolute;
		left: 15px;
		top: 50%;
		transform: translateY(-50%);
		font-size: 1.2rem;
	}

	/* Mobile loading states */
	.mobile-loading {
		background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
		border: 2px solid #bbdefb;
		color: #1976d2;
		padding: 15px;
		border-radius: 12px;
		margin: 15px 0;
		position: relative;
		overflow: hidden;
		animation: slideInRight 0.3s ease;
	}

	.mobile-loading::before {
		content: '';
		position: absolute;
		left: 15px;
		top: 50%;
		transform: translateY(-50%);
		width: 20px;
		height: 20px;
		border: 2px solid #1976d2;
		border-top: 2px solid transparent;
		border-radius: 50%;
		animation: spin 1s linear infinite;
	}

	@keyframes spin {
		0% {
			transform: translateY(-50%) rotate(0deg);
		}

		100% {
			transform: translateY(-50%) rotate(360deg);
		}
	}

	/* Mobile offline indicator */
	.offline-indicator {
		position: fixed;
		top: 70px;
		left: 20px;
		right: 20px;
		background: #dc3545;
		color: white;
		padding: 10px 15px;
		border-radius: 8px;
		text-align: center;
		font-weight: 600;
		z-index: 9999;
		transform: translateY(-100%);
		transition: transform 0.3s ease;
		box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
	}

	.offline-indicator.show {
		transform: translateY(0);
	}

	.offline-indicator::before {
		content: '📡';
		margin-right: 8px;
	}

	/* Mobile PWA install prompt */
	.pwa-install-prompt {
		position: fixed;
		bottom: 20px;
		left: 20px;
		right: 20px;
		background: linear-gradient(135deg, #009245 0%, #34D399 100%);
		color: white;
		padding: 15px;
		border-radius: 12px;
		text-align: center;
		font-weight: 600;
		z-index: 9999;
		transform: translateY(100%);
		transition: transform 0.3s ease;
		box-shadow: 0 4px 12px rgba(0, 146, 69, 0.3);
	}

	.pwa-install-prompt.show {
		transform: translateY(0);
	}

	@keyframes slideUp {
		from {
			transform: translateY(100%);
		}

		to {
			transform: translateY(0);
		}
	}

	.pwa-install-prompt .close-btn {
		position: absolute;
		top: 10px;
		right: 10px;
		background: none;
		border: none;
		color: white;
		font-size: 1.2rem;
		cursor: pointer;
	}
}