/**
 * Dresium Analytics Page Styles
 * RG-WEBDEV 2025-11-04: WooCommerce-style analytics dashboard
 *
 * @package Dresium
 * @since 2.0.0
 */

/* Remove default wrap padding for better layout */
.woocommerce-settings .dresium-analytics-container {
	margin: 0 0 20px 0;
	padding: 0;
	max-width: none;
}

/* KPI Cards - WooCommerce style */
.dresium-kpi-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}

.dresium-kpi-card {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 2px;
	padding: 24px;
	display: flex;
	align-items: flex-start;
	gap: 16px;
	box-shadow: 0 1px 1px rgba(0,0,0,.04);
	transition: box-shadow 0.2s;
}

.dresium-kpi-card:hover {
	box-shadow: 0 2px 4px rgba(0,0,0,.08);
}

.dresium-kpi-icon {
	font-size: 32px;
	line-height: 1;
	opacity: 0.8;
}

.dresium-kpi-content {
	flex: 1;
	min-width: 0;
}

.dresium-kpi-value {
	font-size: 32px;
	font-weight: 600;
	color: #1d2327;
	line-height: 1.2;
	margin-bottom: 4px;
}

.dresium-kpi-label {
	font-size: 12px;
	color: #646970;
	font-weight: 400;
	text-transform: none;
}

/* Filters - WooCommerce style */
.dresium-analytics-filters {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 2px;
	padding: 16px 20px;
	margin-bottom: 24px;
	box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.dresium-analytics-filters label {
	font-weight: 500;
	margin-right: 12px;
	color: #1d2327;
	font-size: 13px;
}

.dresium-analytics-filters select {
	min-width: 200px;
	padding: 6px 24px 6px 8px;
	border: 1px solid #8c8f94;
	border-radius: 2px;
	font-size: 13px;
	background: #fff;
}

.dresium-analytics-filters select:focus {
	border-color: #2271b1;
	outline: 2px solid transparent;
	outline-offset: 0;
	box-shadow: 0 0 0 1px #2271b1;
}

/* Chart Container - WooCommerce style */
.dresium-chart-container {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 2px;
	padding: 24px;
	margin-bottom: 24px;
	box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.dresium-chart-container h3 {
	margin-top: 0;
	margin-bottom: 16px;
	font-size: 18px;
	font-weight: 600;
	color: #1d2327;
}

.dresium-chart-wrapper {
	position: relative;
	width: 100%;
	min-height: 300px;
}

.dresium-chart-wrapper canvas {
	display: block;
	width: 100%;
}

.dresium-chart-loading,
.dresium-chart-empty {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 300px;
	background: #f9f9f9;
	border-radius: 4px;
	color: #7e8993;
	font-style: italic;
}

/* Chart Legend */
.dresium-chart-legend {
	display: flex;
	gap: 20px;
	margin-bottom: 16px;
	flex-wrap: wrap;
}

.dresium-chart-legend-item {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: #50575e;
}

.dresium-chart-legend-color {
	width: 14px;
	height: 14px;
	border-radius: 3px;
	flex-shrink: 0;
}

/* Chart Summary Stats */
.dresium-chart-summary {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}

.dresium-chart-summary-item {
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	padding: 16px;
	text-align: center;
}

.dresium-chart-summary-value {
	display: block;
	font-size: 24px;
	font-weight: 600;
	color: #1d2327;
	margin-bottom: 4px;
}

.dresium-chart-summary-label {
	display: block;
	font-size: 12px;
	color: #646970;
}

/* Legacy chart container */
.dresium-analytics-chart {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 2px;
	padding: 24px;
	margin-bottom: 24px;
	box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.dresium-analytics-chart h2 {
	margin-top: 0;
	margin-bottom: 20px;
	font-size: 18px;
	font-weight: 600;
	color: #1d2327;
}

#dresium-chart-container {
	min-height: 400px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f9f9f9;
	border-radius: 4px;
	padding: 20px;
}

/* Products Table - WooCommerce style */
.dresium-analytics-table {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 2px;
	padding: 0;
	margin-bottom: 24px;
	box-shadow: 0 1px 1px rgba(0,0,0,.04);
	overflow: hidden;
}

/* Table Header with Search */
.dresium-table-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	background: #f6f7f7;
	border-bottom: 1px solid #c3c4c7;
	gap: 16px;
	flex-wrap: wrap;
}

.dresium-table-header h2 {
	margin: 0;
	padding: 0;
	font-size: 18px;
	font-weight: 600;
	color: #1d2327;
	border: none;
	background: none;
}

.dresium-table-search {
	flex-shrink: 0;
}

.dresium-table-search .select2-container {
	min-width: 250px;
}

/* Active Filter Indicator */
.dresium-active-filter {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 20px;
	background: #e7f5ff;
	border-bottom: 1px solid #c3c4c7;
	font-size: 13px;
}

.dresium-active-filter span {
	color: #646970;
}

.dresium-active-filter strong {
	color: #1d2327;
}

.dresium-clear-filter {
	background: none;
	border: none;
	color: #d63638;
	cursor: pointer;
	padding: 2px 8px;
	font-size: 12px;
	border-radius: 3px;
	margin-left: 8px;
}

.dresium-clear-filter:hover {
	background: #fcf0f1;
	text-decoration: underline;
}

/* Legacy h2 style (for backwards compat) */
.dresium-analytics-table > h2 {
	margin: 0;
	padding: 16px 20px;
	font-size: 18px;
	font-weight: 600;
	color: #1d2327;
	border-bottom: 1px solid #c3c4c7;
	background: #f6f7f7;
}

.dresium-analytics-table table {
	margin: 0;
	border: none;
	background: #fff;
}

.dresium-analytics-table th {
	font-weight: 600;
	background: #fff;
	color: #1d2327;
	font-size: 13px;
	padding: 12px 16px;
	border-bottom: 1px solid #c3c4c7;
}

.dresium-analytics-table td {
	vertical-align: middle;
	padding: 12px 16px;
	font-size: 13px;
	border-bottom: 1px solid #dcdcde;
}

.dresium-analytics-table tbody tr:last-child td {
	border-bottom: none;
}

.dresium-analytics-table tbody tr:hover {
	background: #f6f7f7;
}

.dresium-analytics-table .product-name {
	font-weight: 500;
	color: #1d2327;
}

.dresium-analytics-table .conversion-rate {
	color: #00a32a;
	font-weight: 500;
}

.dresium-analytics-table .revenue {
	color: #1d2327;
	font-weight: 500;
}

.dresium-analytics-table .roi-badge {
	display: inline-block;
	padding: 3px 8px;
	border-radius: 2px;
	font-size: 12px;
	font-weight: 500;
}

.dresium-analytics-table .roi-high {
	background: #d5e5d7;
	color: #00550c;
}

.dresium-analytics-table .roi-medium {
	background: #fcf3cf;
	color: #8a6116;
}

.dresium-analytics-table .roi-low {
	background: #f0d0d0;
	color: #8a1616;
}

/* Pagination */
.dresium-pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 20px;
	background: #f6f7f7;
	border-top: 1px solid #c3c4c7;
	gap: 16px;
	flex-wrap: wrap;
}

.dresium-pagination-info {
	color: #646970;
	font-size: 13px;
}

.dresium-pagination-controls {
	display: flex;
	align-items: center;
	gap: 12px;
}

.dresium-pagination-controls .button {
	min-width: auto;
}

.dresium-pagination-controls .button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.dresium-pagination-pages {
	font-size: 13px;
	color: #50575e;
}

.dresium-pagination-pages strong {
	color: #1d2327;
}

/* Info Box - WooCommerce notice style */
.dresium-analytics-info {
	background: #fff;
	border-left: 4px solid #72aee6;
	padding: 12px 20px;
	margin: 24px 0;
	box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.dresium-analytics-info h3 {
	margin-top: 0;
	margin-bottom: 12px;
	color: #1d2327;
	font-size: 14px;
	font-weight: 600;
}

.dresium-analytics-info ul {
	margin: 12px 0;
	padding-left: 24px;
}

.dresium-analytics-info li {
	margin-bottom: 8px;
	font-size: 13px;
	color: #50575e;
}

.dresium-analytics-info .description {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid #dcdcde;
	color: #646970;
	font-style: italic;
	font-size: 13px;
}

/* Menu ordering - force Dresium before Settings in Analytics submenu */
#adminmenuwrap #toplevel_page_wc-admin-path--analytics-overview .wp-submenu {
	display: flex;
	flex-direction: column;
}

/* Settings second-to-last (Dresium will be last but we'll move it) */
#adminmenuwrap #toplevel_page_wc-admin-path--analytics-overview .wp-submenu > li:nth-last-child(2) {
	order: 3;
}

/* Dresium is last child, move it before Settings */
#adminmenuwrap #toplevel_page_wc-admin-path--analytics-overview .wp-submenu > li:last-child {
	order: 2;
}

/* Clickable product rows */
.dresium-product-row {
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.dresium-product-row:hover {
	background: #e7f5ff !important;
}

.dresium-product-row:hover .product-name {
	color: #2271b1;
}

.dresium-product-drill {
	opacity: 0;
	color: #2271b1;
	transition: opacity 0.15s ease;
	margin-left: 4px;
}

.dresium-product-row:hover .dresium-product-drill {
	opacity: 1;
}

/* Modal Overlay */
.dresium-modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

/* Modal Container */
.dresium-modal {
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 4px 40px rgba(0, 0, 0, 0.25);
	max-width: 900px;
	width: 100%;
	max-height: 90vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

/* Modal Header */
.dresium-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid #dcdcde;
	background: #f6f7f7;
}

.dresium-modal-header h2 {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	color: #1d2327;
}

.dresium-modal-close {
	background: none;
	border: none;
	font-size: 24px;
	color: #646970;
	cursor: pointer;
	padding: 4px 8px;
	line-height: 1;
	border-radius: 4px;
	transition: all 0.15s ease;
}

.dresium-modal-close:hover {
	background: #dcdcde;
	color: #1d2327;
}

/* Modal Content */
.dresium-modal-content {
	padding: 24px;
	overflow-y: auto;
	flex: 1;
}

.dresium-modal-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	color: #646970;
	font-style: italic;
}

/* Product Header in Modal */
.dresium-product-header {
	display: flex;
	align-items: flex-start;
	gap: 20px;
	margin-bottom: 24px;
	padding-bottom: 20px;
	border-bottom: 1px solid #dcdcde;
}

.dresium-product-image {
	width: 100px;
	height: 100px;
	object-fit: cover;
	border-radius: 4px;
	border: 1px solid #dcdcde;
}

.dresium-product-info h3 {
	margin: 0 0 8px 0;
	font-size: 18px;
	font-weight: 600;
	color: #1d2327;
}

.dresium-product-link {
	color: #2271b1;
	text-decoration: none;
	font-size: 13px;
}

.dresium-product-link:hover {
	color: #135e96;
	text-decoration: underline;
}

/* Modal KPIs */
.dresium-modal-kpis {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 12px;
	margin-bottom: 24px;
}

.dresium-modal-kpi {
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	padding: 16px;
	text-align: center;
}

.dresium-modal-kpi-value {
	display: block;
	font-size: 24px;
	font-weight: 600;
	color: #1d2327;
	margin-bottom: 4px;
}

.dresium-modal-kpi-label {
	display: block;
	font-size: 11px;
	color: #646970;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* Users Table in Modal */
.dresium-modal-users {
	margin-top: 24px;
}

.dresium-modal-users h4 {
	margin: 0 0 12px 0;
	font-size: 14px;
	font-weight: 600;
	color: #1d2327;
}

.dresium-users-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.dresium-users-table th {
	background: #f6f7f7;
	padding: 10px 12px;
	text-align: left;
	font-weight: 600;
	color: #1d2327;
	border-bottom: 1px solid #dcdcde;
}

.dresium-users-table td {
	padding: 10px 12px;
	border-bottom: 1px solid #f0f0f0;
	color: #50575e;
}

.dresium-users-table tbody tr:last-child td {
	border-bottom: none;
}

.dresium-users-table tbody tr:hover {
	background: #f9f9f9;
}

/* Status Badges */
.dresium-badge {
	display: inline-block;
	padding: 3px 8px;
	border-radius: 3px;
	font-size: 11px;
	font-weight: 500;
	text-transform: uppercase;
}

.dresium-badge-success {
	background: #d5e5d7;
	color: #00550c;
}

.dresium-badge-pending {
	background: #f0f0f0;
	color: #646970;
}

/* Tooltip Helper - Question mark icons with hover explanations */
/* RG-WEBDEV 2026-03-15: Added for KPI card explanations */
.dresium-tooltip-helper {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	margin-left: 6px;
	vertical-align: middle;
	cursor: help;
}

.dresium-tooltip-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	background: #1d2327;
	color: #fff;
	border-radius: 50%;
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	transition: background 0.2s ease;
}

.dresium-tooltip-helper:hover .dresium-tooltip-icon,
.dresium-tooltip-helper:focus .dresium-tooltip-icon {
	background: #2271b1;
}

.dresium-tooltip-content {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	min-width: 220px;
	max-width: 300px;
	padding: 10px 12px;
	background: #1d2327;
	color: #fff;
	font-size: 12px;
	font-weight: 400;
	line-height: 1.5;
	text-align: left;
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	z-index: 10000;
	pointer-events: none;
}

/* Tooltip arrow */
.dresium-tooltip-content::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 6px solid transparent;
	border-top-color: #1d2327;
}

/* Show tooltip on hover/focus */
.dresium-tooltip-helper:hover .dresium-tooltip-content,
.dresium-tooltip-helper:focus .dresium-tooltip-content {
	opacity: 1;
	visibility: visible;
}

/* Tooltip positioning adjustments for edge cases */
.dresium-kpi-card:first-child .dresium-tooltip-content,
.dresium-kpi-card:nth-child(2) .dresium-tooltip-content {
	left: 0;
	transform: translateX(0);
}

.dresium-kpi-card:first-child .dresium-tooltip-content::after,
.dresium-kpi-card:nth-child(2) .dresium-tooltip-content::after {
	left: 12px;
	transform: translateX(0);
}

.dresium-kpi-card:last-child .dresium-tooltip-content,
.dresium-kpi-card:nth-last-child(2) .dresium-tooltip-content {
	left: auto;
	right: 0;
	transform: translateX(0);
}

.dresium-kpi-card:last-child .dresium-tooltip-content::after,
.dresium-kpi-card:nth-last-child(2) .dresium-tooltip-content::after {
	left: auto;
	right: 12px;
	transform: translateX(0);
}

/* Responsive */
@media (max-width: 768px) {
	.dresium-kpi-cards {
		grid-template-columns: 1fr;
	}

	.dresium-analytics-filters select {
		min-width: 100%;
		margin-top: 10px;
	}

	.dresium-table-header {
		flex-direction: column;
		align-items: stretch;
	}

	.dresium-table-search {
		width: 100%;
	}

	.dresium-table-search .select2-container {
		min-width: 100% !important;
		width: 100% !important;
	}

	.dresium-pagination {
		flex-direction: column;
		text-align: center;
	}

	.dresium-pagination-controls {
		width: 100%;
		justify-content: center;
	}

	.dresium-modal {
		max-height: 100vh;
		border-radius: 0;
	}

	.dresium-modal-kpis {
		grid-template-columns: repeat(2, 1fr);
	}

	.dresium-product-header {
		flex-direction: column;
		align-items: center;
		text-align: center;
	}
}
