/**
 * File: device-listing.css
 * Description: Base structural styles for IoT device listing widget
 * Plugin Name: My Account Extensions
 * Plugin URI: https://gitlab.dp-microsystems.de/ansari/web/ansari-de/-/tree/master/wp-data/wp-content/mu-plugins/my-account-extensions/features/device-listing
 *
 * Author: Kambis Ansari
 * Author URI: https://gitlab.dp-microsystems.de/kambis.ansari
 * License: Proprietary
 *
 * @package My_Account_Extensions
 * @version 20251123-0808
 * @change 20251123-0808: Fixed @version timestamp - batched update (Batch 2)
 * @change 20251123-0745 Session (2025-11-23 | 07:15): v3.2.0 compliance - standard headers
 * @since 20251115-0842
 */

/* ==========================================================================
   Filter Form
   ========================================================================== */

.mae-device-listing-filters {
	margin-bottom: 2rem;
	padding: 1.5rem;
	background: #f9f9f9;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
}

/* More specific selector to override Elementor global typography (without !important) */
.elementor-widget-iot-device-listing .elementor-widget-container .mae-device-listing-filters h3 {
	margin-top: 0;
	margin-bottom: 1rem;
	font-size: 20px;
	font-weight: 600;
}

.mae-filter-row {
	display: flex;
	gap: 1rem;
	margin-bottom: 1rem;
	flex-wrap: wrap;
}

.mae-filter-group {
	flex: 1;
	min-width: 200px;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.mae-filter-group label {
	font-weight: 500;
	font-size: 0.9rem;
}

.mae-filter-group select {
	padding: 0.5rem;
	border: 1px solid #ccc;
	border-radius: 3px;
	font-size: 1rem;
}

/* Organization Badge (for non-admin users) */
.mae-org-badge {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem 1rem;
	background: #e8f4f8;
	border-left: 4px solid #0073aa;
	border-radius: 3px;
}

.mae-org-badge .org-value {
	font-weight: 600;
	color: #0073aa;
}

.mae-org-badge .org-badge-label {
	color: #666;
	font-size: 0.9rem;
	font-style: italic;
}

/* Filter Button */
.mae-filter-apply {
	padding: 0.75rem 2rem;
	background: #0073aa;
	color: #fff;
	border: none;
	border-radius: 3px;
	font-size: 1rem;
	cursor: pointer;
	transition: background 0.3s ease;
}

.mae-filter-apply:hover {
	background: #005a87;
}

/* ==========================================================================
   Widget Container
   ========================================================================== */

.mae-device-listing-widget {
	width: 100%;
	max-width: 100%;
	min-width: 0;
}

/* ==========================================================================
   Table Container
   ========================================================================== */

.mae-device-listing-table-container {
	overflow-x: auto;
	margin-bottom: 2rem;
	width: 100%;
	max-width: 100%;
	min-width: 0;
}

/* ==========================================================================
   Device Table
   ========================================================================== */

.mae-device-table {
	width: 100%;
	max-width: 100%;
	border-collapse: collapse;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	table-layout: fixed;
}

/* More specific selectors to override Elementor/WooCommerce defaults */
.elementor-widget-iot-device-listing .mae-device-table thead th {
	background: #e8f4f8;
	padding: 0.5rem 1rem;
	text-align: left;
	font-weight: 600;
	border-bottom: 2px solid #0073aa;
	position: sticky;
	top: 0;
	z-index: 10;
}

.elementor-widget-iot-device-listing .mae-device-table tbody tr {
	border-bottom: 1px solid #eee;
	transition: background 0.2s ease;
}

.elementor-widget-iot-device-listing .mae-device-table tbody tr:hover {
	background: #f9f9f9;
}

.elementor-widget-iot-device-listing .mae-device-table td {
	padding: 0.375rem 1rem;
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.device-status-badge {
	display: inline-block;
	padding: 0.25rem 0.75rem;
	border-radius: 12px;
	font-size: 0.85rem;
	font-weight: 500;
	text-align: center;
}

.device-online {
	background: #d4edda;
	color: #155724;
}

.device-offline {
	background: #f8d7da;
	color: #721c24;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.mae-device-listing-loading {
	padding: 2rem;
	text-align: center;
}

.loading-skeleton {
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: loading 1.5s ease-in-out infinite;
	border-radius: 4px;
	height: 40px;
	margin-bottom: 0.5rem;
}

@keyframes loading {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

/* ==========================================================================
   Error Messages
   ========================================================================== */

.mae-device-listing-error {
	padding: 1.5rem;
	background: #f8d7da;
	border: 1px solid #f5c6cb;
	border-radius: 4px;
	color: #721c24;
}

.mae-device-listing-error .error-message {
	margin: 0;
}

.mae-device-listing-error details {
	margin-top: 1rem;
	padding: 1rem;
	background: #fff;
	border-radius: 3px;
}

.mae-device-listing-error summary {
	cursor: pointer;
	font-weight: 600;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.no-devices-message {
	padding: 2rem;
	text-align: center;
	color: #666;
	font-style: italic;
}

/* ==========================================================================
   DataTables Overrides
   ========================================================================== */

/* DataTables wrapper */
.dataTables_wrapper {
	width: 100%;
	max-width: 100%;
	min-width: 0;
}

/* Top controls container (search and length menu) */
.dataTables_wrapper .datatable-top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	margin-bottom: 1rem;
	flex-wrap: wrap;
}

.dataTables_wrapper .dataTables_length {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	white-space: nowrap;
	min-width: fit-content;
}

.dataTables_wrapper .dataTables_length label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	white-space: nowrap;
	margin: 0;
}

.dataTables_wrapper .dataTables_length select {
	padding: 0.25rem;
	min-width: 60px;
}

.dataTables_wrapper .dataTables_filter {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	white-space: nowrap;
	min-width: fit-content;
}

.dataTables_wrapper .dataTables_filter label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	white-space: nowrap;
	margin: 0;
}

.dataTables_wrapper .dataTables_filter input {
	padding: 0.5rem;
	border: 1px solid #ccc;
	border-radius: 3px;
	min-width: 200px;
}

/* Bottom controls container (info and pagination) */
.dataTables_wrapper .datatable-bottom {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	margin-top: 1rem;
	flex-wrap: wrap;
}

.dataTables_wrapper .dataTables_info {
	color: #666;
	white-space: nowrap;
	min-width: fit-content;
}

.dataTables_wrapper .dataTables_paginate {
	white-space: nowrap;
	min-width: fit-content;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
	padding: 0.5rem 0.75rem;
	margin: 0 0.25rem;
	border: 1px solid #ddd;
	border-radius: 3px;
	background: #fff;
	cursor: pointer;
	transition: all 0.2s ease;
	color: #333;
	text-decoration: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
	background: #f5f5f5;
	border-color: #999;
	color: #333;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
	background: #e8f4f8;
	color: #0073aa;
	border-color: #0073aa;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
	background: #d4ebf2;
	border-color: #005a87;
	color: #005a87;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
	opacity: 0.5;
	cursor: not-allowed;
	background: #fff;
	border-color: #ddd;
	color: #999;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
	.mae-filter-row {
		flex-direction: column;
	}

	.mae-filter-group {
		min-width: 100%;
	}

	.mae-device-table thead {
		display: none;
	}

	.mae-device-table tbody tr {
		display: block;
		margin-bottom: 1rem;
		border: 1px solid #ddd;
		border-radius: 4px;
	}

	.mae-device-table td {
		display: block;
		text-align: right;
		padding: 0.5rem 1rem;
		border-bottom: 1px solid #eee;
	}

	.mae-device-table td:last-child {
		border-bottom: none;
	}

	.mae-device-table td::before {
		content: attr(data-label);
		float: left;
		font-weight: 600;
	}
}

@media (max-width: 480px) {
	.mae-device-listing-filters {
		padding: 1rem;
	}

	.mae-filter-apply {
		width: 100%;
	}
}
