/**
 * Nova Addon - Nutrition Frontend Styles
 *
 * @package NovaAddon
 * @since 1.0.0
 */

/* CSS Variables */
:root {
	--nova-nutrition-primary: #4CAF50;
	--nova-nutrition-warning: #ff9800;
	--nova-nutrition-danger: #f44336;
	--nova-nutrition-info: #2196F3;
	--nova-nutrition-bg: #f9f9f9;
	--nova-nutrition-border: #e0e0e0;
	--nova-nutrition-text: #333;
	--nova-nutrition-text-muted: #666;
}

/* Trigger Button (On-Demand Mode) */
.nova-nutrition-trigger {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	margin: 16px 0;
	background: var(--nova-nutrition-bg);
	border: 1px solid var(--nova-nutrition-border);
	border-radius: 8px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	color: var(--nova-nutrition-text);
	transition: background-color 0.2s, border-color 0.2s;
}

.nova-nutrition-trigger:hover {
	background: #f0f0f0;
	border-color: #ccc;
}

.nova-nutrition-trigger .icon {
	font-size: 18px;
	transition: transform 0.3s;
}

.nova-nutrition-trigger.expanded .icon {
	transform: rotate(180deg);
}

/* Collapsible Container */
.nova-nutrition-collapsible {
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.3s ease-out;
}

.nova-nutrition-collapsible.expanded {
	max-height: 2000px;
}

/* Nutrition Facts Container */
.nova-nutrition-facts {
	background: #fff;
	border: 1px solid var(--nova-nutrition-border);
	border-radius: 8px;
	padding: 16px;
	margin: 16px 0;
}

.nova-nutrition-facts__title {
	font-size: 16px;
	font-weight: 600;
	margin: 0 0 4px;
	color: var(--nova-nutrition-text);
}

.nova-nutrition-facts__serving {
	font-size: 13px;
	color: var(--nova-nutrition-text-muted);
	margin: 0 0 16px;
}

/* Table Display Mode */
.nova-nutrition-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.nova-nutrition-table th,
.nova-nutrition-table td {
	padding: 8px 12px;
	text-align: left;
	border-bottom: 1px solid var(--nova-nutrition-border);
}

.nova-nutrition-table th {
	background: var(--nova-nutrition-bg);
	font-weight: 600;
	color: var(--nova-nutrition-text);
}

.nova-nutrition-table td.amount {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.nova-nutrition-table td.rda {
	text-align: right;
	width: 80px;
}

/* Progress Bar Display Mode */
.nova-nutrition-bars {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.nova-nutrient-bar {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.nova-nutrient-bar__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 13px;
}

.nova-nutrient-bar__name {
	font-weight: 500;
	color: var(--nova-nutrition-text);
}

.nova-nutrient-bar__amount {
	color: var(--nova-nutrition-text-muted);
}

.nova-nutrient-bar__track {
	height: 8px;
	background: #e9ecef;
	border-radius: 4px;
	overflow: hidden;
}

.nova-nutrient-bar__fill {
	height: 100%;
	border-radius: 4px;
	transition: width 0.3s ease-out, background-color 0.3s;
}

/* RDA Percentage Colors */
.nova-nutrient-bar__fill.rda-low {
	background: #adb5bd; /* < 50% */
}

.nova-nutrient-bar__fill.rda-adequate {
	background: var(--nova-nutrition-primary); /* 50-100% */
}

.nova-nutrient-bar__fill.rda-high {
	background: var(--nova-nutrition-warning); /* 100-150% */
}

.nova-nutrient-bar__fill.rda-excess {
	background: var(--nova-nutrition-danger); /* > 150% or above UL */
}

.nova-nutrient-bar__percentage {
	font-size: 12px;
	font-weight: 600;
	min-width: 50px;
	text-align: right;
}

/* Category Groups */
.nova-nutrition-category {
	margin-bottom: 16px;
}

.nova-nutrition-category:last-child {
	margin-bottom: 0;
}

.nova-nutrition-category__title {
	font-size: 14px;
	font-weight: 600;
	color: var(--nova-nutrition-text);
	margin: 0 0 8px;
	padding-bottom: 4px;
	border-bottom: 2px solid var(--nova-nutrition-primary);
}

/* Alert Badge */
.nova-nutrition-alert {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 500;
}

.nova-nutrition-alert.warning {
	background: #fff3cd;
	color: #856404;
}

.nova-nutrition-alert.danger {
	background: #f8d7da;
	color: #721c24;
}

.nova-nutrition-alert .icon {
	font-size: 14px;
}

/* Cart Nutrition Summary */
.nova-cart-nutrition {
	background: #fff;
	border: 1px solid var(--nova-nutrition-border);
	border-radius: 8px;
	padding: 16px;
	margin: 16px 0;
}

.nova-cart-nutrition__title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 16px;
	font-weight: 600;
	margin: 0 0 8px;
}

.nova-cart-nutrition__subtitle {
	font-size: 13px;
	color: var(--nova-nutrition-text-muted);
	margin: 0 0 16px;
}

.nova-cart-nutrition__profile {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	background: var(--nova-nutrition-bg);
	border-radius: 4px;
	margin-bottom: 16px;
	font-size: 13px;
}

.nova-cart-nutrition__profile-change {
	color: var(--nova-nutrition-info);
	text-decoration: underline;
	cursor: pointer;
}

/* Floating Action Button */
.nova-nutrition-fab {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--nova-nutrition-primary);
	color: #fff;
	border: none;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	transition: transform 0.2s, box-shadow 0.2s;
}

.nova-nutrition-fab:hover {
	transform: scale(1.1);
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.nova-nutrition-fab.has-alerts::after {
	content: '!';
	position: absolute;
	top: -4px;
	right: -4px;
	width: 20px;
	height: 20px;
	background: var(--nova-nutrition-danger);
	border-radius: 50%;
	font-size: 12px;
	font-weight: bold;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Loading State */
.nova-nutrition-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	color: var(--nova-nutrition-text-muted);
}

.nova-nutrition-loading .spinner {
	width: 20px;
	height: 20px;
	border: 2px solid var(--nova-nutrition-border);
	border-top-color: var(--nova-nutrition-primary);
	border-radius: 50%;
	animation: nova-spin 0.8s linear infinite;
	margin-right: 8px;
}

@keyframes nova-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Skeleton Loader */
.nova-nutrition-skeleton {
	padding: 16px;
}

.nova-nutrition-skeleton .skeleton-row {
	height: 20px;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: nova-skeleton-loading 1.5s infinite;
	border-radius: 4px;
	margin-bottom: 12px;
}

.nova-nutrition-skeleton .skeleton-row:last-child {
	margin-bottom: 0;
}

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

/* Responsive */
@media screen and (max-width: 600px) {
	.nova-nutrition-facts {
		padding: 12px;
	}

	.nova-nutrition-table th,
	.nova-nutrition-table td {
		padding: 6px 8px;
		font-size: 13px;
	}

	.nova-nutrient-bar__header {
		font-size: 12px;
	}

	.nova-nutrition-fab {
		bottom: 16px;
		right: 16px;
		width: 48px;
		height: 48px;
		font-size: 20px;
	}
}

/* Nutrition Filter */
.nova-nutrition-filter {
	margin: 16px 0;
}

.nova-nutrition-filter__toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	background: var(--nova-nutrition-bg);
	border: 1px solid var(--nova-nutrition-border);
	border-radius: 8px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	color: var(--nova-nutrition-text);
	width: 100%;
	text-align: left;
}

.nova-nutrition-filter__toggle:hover {
	background: #f0f0f0;
}

.nova-nutrition-filter__toggle .toggle-icon {
	margin-left: auto;
	transition: transform 0.2s;
}

.nova-nutrition-filter__toggle[aria-expanded="true"] .toggle-icon {
	transform: rotate(180deg);
}

.nova-nutrition-filter__panel {
	display: none;
	padding: 16px;
	background: #fff;
	border: 1px solid var(--nova-nutrition-border);
	border-top: none;
	border-radius: 0 0 8px 8px;
}

.nova-nutrition-filter__panel[aria-hidden="false"] {
	display: block;
}

.nova-nutrition-filter__section {
	margin-bottom: 16px;
}

.nova-nutrition-filter__section h4 {
	margin: 0 0 8px;
	font-size: 14px;
	font-weight: 600;
}

.nova-nutrition-filter__checkboxes {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
}

.nova-nutrition-filter__category {
	flex: 1;
	min-width: 150px;
}

.nova-nutrition-filter__category strong {
	display: block;
	margin-bottom: 8px;
	font-size: 12px;
	color: var(--nova-nutrition-text-muted);
}

.nova-nutrition-filter__checkbox {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 4px;
	font-size: 13px;
	cursor: pointer;
}

.nova-nutrition-filter__sort {
	width: 100%;
	max-width: 300px;
	padding: 8px 12px;
	border: 1px solid var(--nova-nutrition-border);
	border-radius: 4px;
}

.nova-nutrition-filter__actions {
	display: flex;
	gap: 12px;
	padding-top: 16px;
	border-top: 1px solid var(--nova-nutrition-border);
}

.nova-nutrition-filter__submit {
	padding: 10px 24px;
	background: var(--nova-nutrition-primary);
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
}

.nova-nutrition-filter__submit:hover {
	opacity: 0.9;
}

.nova-nutrition-filter__reset {
	padding: 10px 16px;
	color: var(--nova-nutrition-text-muted);
	text-decoration: none;
}

.nova-nutrition-filter__reset:hover {
	color: var(--nova-nutrition-text);
}

/* Shortcode Styles */
.nova-nutrition-shortcode {
	margin: 16px 0;
}

.nova-nutrition-shortcode__serving {
	font-size: 13px;
	color: var(--nova-nutrition-text-muted);
	margin-bottom: 12px;
}

.nova-nutrition-shortcode__category h4 {
	font-size: 14px;
	font-weight: 600;
	margin: 16px 0 8px;
	padding-bottom: 4px;
	border-bottom: 2px solid var(--nova-nutrition-primary);
}

.nova-nutrient-inline {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.nova-nutrient-inline .bar {
	width: 60px;
	height: 8px;
	background: #e9ecef;
	border-radius: 4px;
	overflow: hidden;
}

.nova-nutrient-inline .bar-fill {
	height: 100%;
	border-radius: 4px;
}

.nova-cart-nutrition-shortcode__alerts .alert {
	padding: 8px 12px;
	border-radius: 4px;
	margin-bottom: 8px;
	font-size: 13px;
}

.nova-cart-nutrition-shortcode__alerts .danger {
	background: #f8d7da;
	color: #721c24;
}

.nova-cart-nutrition-shortcode__alerts .warning {
	background: #fff3cd;
	color: #856404;
}

.nova-cart-nutrition-shortcode__item {
	display: flex;
	justify-content: space-between;
	padding: 6px 0;
	border-bottom: 1px dotted var(--nova-nutrition-border);
}

.nova-cart-nutrition-shortcode__item:last-child {
	border-bottom: none;
}

.nova-cart-nutrition-shortcode__item .rda {
	color: var(--nova-nutrition-text-muted);
	font-size: 12px;
}

/* Nutrition Compare Table */
.nova-nutrition-compare__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.nova-nutrition-compare__table th,
.nova-nutrition-compare__table td {
	padding: 12px;
	text-align: center;
	border: 1px solid var(--nova-nutrition-border);
}

.nova-nutrition-compare__table th {
	background: var(--nova-nutrition-bg);
}

.nova-nutrition-compare__table .product-image {
	width: 60px;
	height: 60px;
	object-fit: cover;
	border-radius: 4px;
	margin-bottom: 8px;
}

.nova-nutrition-compare__table .product-name {
	display: block;
	font-size: 12px;
}

.nova-nutrition-compare__table .nutrient-name {
	text-align: left;
	font-weight: 500;
}

/* RDA Bar Shortcode */
.nova-rda-bar-shortcode {
	margin: 8px 0;
}

.nova-rda-bar-shortcode__header {
	display: flex;
	justify-content: space-between;
	margin-bottom: 4px;
	font-size: 13px;
}

.nova-rda-bar-shortcode__track {
	height: 10px;
	background: #e9ecef;
	border-radius: 5px;
	overflow: hidden;
}

.nova-rda-bar-shortcode__fill {
	height: 100%;
	border-radius: 5px;
	transition: width 0.3s;
}

.nova-rda-bar-shortcode__footer {
	text-align: right;
	margin-top: 4px;
}

.nova-rda-bar-shortcode__footer .percentage {
	font-size: 12px;
	font-weight: 600;
}
