/**
 * EDD Usage Monitor — Shared Stylesheet
 * Dark theme, extracted from server-rendered dashboard.js
 */

:root {
	--bg-primary: #0f172a;
	--bg-secondary: #1e293b;
	--bg-card: #334155;
	--text-primary: #f1f5f9;
	--text-secondary: #94a3b8;
	--accent-blue: #3b82f6;
	--accent-green: #22c55e;
	--accent-yellow: #eab308;
	--accent-orange: #f97316;
	--accent-red: #ef4444;
	--accent-purple: #a855f7;
	--border: #475569;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	background: var(--bg-primary);
	color: var(--text-primary);
	line-height: 1.6;
	padding: 20px;
}

.container {
	max-width: 1400px;
	margin: 0 auto;
}

/* ───── Header ───── */
header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 30px;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--border);
}

h1 {
	font-size: 24px;
	font-weight: 600;
}

h2 {
	font-size: 18px;
	font-weight: 600;
	margin-bottom: 16px;
	color: var(--text-primary);
}

.timestamp {
	color: var(--text-secondary);
	font-size: 14px;
}

.header-info {
	display: flex;
	align-items: center;
	gap: 20px;
}

/* ───── Nav Tabs ───── */
.nav-tabs {
	display: flex;
	gap: 8px;
}

.nav-tab {
	padding: 8px 16px;
	border-radius: 6px;
	text-decoration: none;
	font-size: 14px;
	font-weight: 500;
	transition: all 0.2s;
}

.nav-tab-inactive {
	background: var(--bg-secondary);
	color: var(--text-secondary);
	border: 1px solid var(--border);
}

.nav-tab-inactive:hover {
	background: var(--bg-card);
	color: var(--text-primary);
}

.nav-tab-active {
	background: var(--accent-blue);
	color: white;
	border: 1px solid var(--accent-blue);
}

.nav-tab-active-purple {
	background: var(--accent-purple);
	color: white;
	border: 1px solid var(--accent-purple);
}

/* ───── Buttons ───── */
.refresh-btn {
	background: var(--accent-blue);
	color: white;
	border: none;
	padding: 8px 16px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	text-decoration: none;
	display: inline-block;
}

.refresh-btn:hover {
	background: #2563eb;
}

.refresh-btn-purple {
	background: var(--accent-purple);
}

.refresh-btn-purple:hover {
	background: #9333ea;
}

.settings-btn {
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	color: var(--text-secondary);
	width: 36px;
	height: 36px;
	border-radius: 6px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	transition: all 0.2s;
}

.settings-btn:hover {
	background: var(--bg-card);
	color: var(--text-primary);
}

.btn {
	padding: 10px 20px;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	border: none;
	transition: all 0.2s;
}

.btn-primary { background: var(--accent-blue); color: white; }
.btn-primary:hover { background: #2563eb; }

.btn-secondary {
	background: var(--bg-card);
	color: var(--text-primary);
	border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

/* ───── Alert Banner ───── */
.alert-banner {
	background: linear-gradient(135deg, #7f1d1d, #991b1b);
	border: 1px solid var(--accent-red);
	border-radius: 8px;
	padding: 16px 20px;
	margin-bottom: 24px;
	display: flex;
	align-items: center;
	gap: 12px;
}

.alert-banner.hidden { display: none; }

.alert-icon { font-size: 24px; }

.alert-content h3 { font-size: 16px; margin-bottom: 4px; }

.alert-content p { font-size: 14px; color: #fca5a5; }

/* ───── Grid Layouts ───── */
.grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 20px;
	margin-bottom: 30px;
}

.cards-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
	gap: 24px;
	margin-bottom: 30px;
}

.summary-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 16px;
	margin-bottom: 30px;
}

.chart-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 20px;
	margin-bottom: 30px;
}

/* ───── Cards ───── */
.card {
	background: var(--bg-secondary);
	border-radius: 12px;
	padding: 24px;
	border: 1px solid var(--border);
}

.total-card {
	background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
	border: 2px solid var(--accent-blue);
}

.card-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
}

.card-title {
	font-size: 18px;
	font-weight: 600;
}

.card-badge {
	font-size: 12px;
	padding: 4px 10px;
	border-radius: 20px;
	font-weight: 500;
}

.badge-good {
	background: rgba(34, 197, 94, 0.2);
	color: var(--accent-green);
}

.badge-warning {
	background: rgba(234, 179, 8, 0.2);
	color: var(--accent-yellow);
}

.badge-danger {
	background: rgba(239, 68, 68, 0.2);
	color: var(--accent-red);
}

/* ───── Summary Cards ───── */
.summary-card {
	background: var(--bg-secondary);
	border-radius: 12px;
	padding: 20px;
	border: 1px solid var(--border);
}

.summary-value {
	font-size: 32px;
	font-weight: 700;
	color: var(--accent-blue);
}

.summary-label {
	font-size: 14px;
	color: var(--text-secondary);
	margin-top: 4px;
}

.summary-sublabel {
	font-size: 12px;
	color: var(--text-secondary);
	margin-top: 2px;
	font-style: italic;
}

/* ───── Cost Display ───── */
.cost-display { margin-bottom: 20px; }

.cost-amount {
	font-size: 36px;
	font-weight: 700;
	color: var(--accent-blue);
}

.total-card .cost-amount { font-size: 48px; }

.cost-label {
	font-size: 14px;
	color: var(--text-secondary);
}

/* ───── Progress Bars ───── */
.progress-bar {
	height: 8px;
	background: var(--bg-card);
	border-radius: 4px;
	overflow: hidden;
	margin: 12px 0;
}

.progress-fill {
	height: 100%;
	border-radius: 4px;
	transition: width 0.3s ease;
}

.progress-good { background: var(--accent-green); }
.progress-warning { background: var(--accent-yellow); }
.progress-danger { background: var(--accent-red); }

/* ───── Usage Bars ───── */
.usage-bars { margin-top: 16px; }

.usage-bar-item { margin-bottom: 12px; }
.usage-bar-item:last-child { margin-bottom: 0; }

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

.usage-bar-label { color: var(--text-secondary); }
.usage-bar-values { color: var(--text-primary); font-weight: 500; }

.usage-bar-track {
	height: 6px;
	background: var(--bg-card);
	border-radius: 3px;
	overflow: hidden;
}

.usage-bar-fill {
	height: 100%;
	border-radius: 3px;
	transition: width 0.3s ease;
}

.usage-bar-good { background: var(--accent-green); }
.usage-bar-warning { background: var(--accent-yellow); }
.usage-bar-danger { background: var(--accent-red); }

/* ───── Stats Grid ───── */
.stats-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}

.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat {
	background: var(--bg-card);
	padding: 12px;
	border-radius: 8px;
}

.stat-value {
	font-size: 20px;
	font-weight: 600;
}

.stat-label {
	font-size: 12px;
	color: var(--text-secondary);
}

/* ───── Breakdown ───── */
.breakdown {
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
}

.breakdown-item {
	display: flex;
	justify-content: space-between;
	padding: 8px 0;
	font-size: 14px;
}

.breakdown-label { color: var(--text-secondary); }

/* ───── Note / Info Box ───── */
.note {
	background: var(--bg-card);
	padding: 12px 16px;
	border-radius: 8px;
	font-size: 14px;
	color: var(--text-secondary);
	margin-top: 16px;
	margin-bottom: 16px;
}

.note::before {
	content: "i";
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	background: var(--accent-blue);
	color: white;
	border-radius: 50%;
	font-size: 12px;
	font-weight: 600;
	margin-right: 8px;
}

/* ───── Error Message ───── */
.error-message {
	background: rgba(239, 68, 68, 0.1);
	border: 1px solid var(--accent-red);
	border-radius: 8px;
	padding: 16px;
	color: var(--accent-red);
	margin-bottom: 12px;
}

/* ───── Loading State ───── */
.loading-state {
	text-align: center;
	padding: 80px 20px;
	color: var(--text-secondary);
}

.loading-spinner {
	width: 40px;
	height: 40px;
	border: 3px solid var(--border);
	border-top-color: var(--accent-blue);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
	margin: 0 auto 16px;
}

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

.loading-text {
	font-size: 16px;
}

/* ───── Footer ───── */
footer {
	margin-top: 40px;
	padding-top: 20px;
	border-top: 1px solid var(--border);
	text-align: center;
	color: var(--text-secondary);
	font-size: 14px;
}

/* ───── Settings Modal ───── */
.modal-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.7);
	z-index: 1000;
	align-items: center;
	justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
	background: var(--bg-secondary);
	border-radius: 12px;
	border: 1px solid var(--border);
	width: 90%;
	max-width: 600px;
	max-height: 90vh;
	overflow-y: auto;
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20px 24px;
	border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 18px; font-weight: 600; }

.modal-close {
	background: none;
	border: none;
	color: var(--text-secondary);
	font-size: 24px;
	cursor: pointer;
	padding: 0;
	line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

.modal-content { padding: 24px; }

.modal-footer {
	display: flex;
	gap: 12px;
	padding: 20px 24px;
	border-top: 1px solid var(--border);
	align-items: center;
}

.settings-section { margin-bottom: 24px; }
.settings-section:last-child { margin-bottom: 0; }

.settings-section-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--text-secondary);
	margin-bottom: 12px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--border);
}

.threshold-row {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 16px;
	margin-bottom: 12px;
}

.threshold-group { display: flex; flex-direction: column; gap: 6px; }

.threshold-label {
	font-size: 12px;
	color: var(--text-secondary);
	display: flex;
	align-items: center;
	gap: 6px;
}

.threshold-color { width: 10px; height: 10px; border-radius: 50%; }

.threshold-input {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 10px 12px;
	color: var(--text-primary);
	font-size: 14px;
	width: 100%;
}

.threshold-input:focus { outline: none; border-color: var(--accent-blue); }

.threshold-hint { font-size: 11px; color: var(--text-secondary); }

.save-status { font-size: 14px; margin-left: auto; }
.save-status.success { color: var(--accent-green); }
.save-status.error { color: var(--accent-red); }

/* ───── Workers View ───── */
.workers-table {
	width: 100%;
	background: var(--bg-secondary);
	border-radius: 12px;
	overflow: hidden;
	border: 1px solid var(--border);
}

.workers-table th,
.workers-table td {
	padding: 16px;
	text-align: left;
}

.workers-table th {
	background: var(--bg-card);
	color: var(--text-secondary);
	font-weight: 500;
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.workers-table tr { border-bottom: 1px solid var(--border); }
.workers-table tr:last-child { border-bottom: none; }
.workers-table tr:hover td { background: rgba(59, 130, 246, 0.05); }

.worker-name { font-weight: 600; color: var(--accent-blue); }

.error-rate {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: 20px;
	font-size: 13px;
	font-weight: 500;
}

.error-rate-good { background: rgba(34, 197, 94, 0.2); color: var(--accent-green); }
.error-rate-warning { background: rgba(234, 179, 8, 0.2); color: var(--accent-yellow); }
.error-rate-danger { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

.perf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.perf-metric { font-size: 14px; }
.perf-value { font-weight: 600; }
.perf-unit { color: var(--text-secondary); font-size: 12px; }
.perf-label { color: var(--text-secondary); font-size: 11px; }

.status-codes { display: flex; gap: 8px; flex-wrap: wrap; }

.status-badge {
	padding: 2px 8px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 500;
}

.status-2xx { background: rgba(34, 197, 94, 0.2); color: var(--accent-green); }
.status-3xx { background: rgba(59, 130, 246, 0.2); color: var(--accent-blue); }
.status-4xx { background: rgba(234, 179, 8, 0.2); color: var(--accent-yellow); }
.status-5xx { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

.mini-chart { display: flex; align-items: flex-end; gap: 2px; height: 30px; }

.mini-bar {
	width: 6px;
	background: var(--accent-blue);
	border-radius: 2px;
	min-height: 2px;
}

.mini-bar-error { background: var(--accent-red); }

/* ───── Multicurrency View ───── */
.usage-display { margin-bottom: 20px; }

.usage-amount {
	font-size: 42px;
	font-weight: 700;
	color: var(--accent-purple);
}

.usage-label {
	font-size: 14px;
	color: var(--text-secondary);
}

.performance-section {
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
}

.performance-header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 12px;
}

.performance-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--text-secondary);
}

.status-indicator {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 500;
}

.status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
}

.performance-stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 12px;
}

.perf-stat { text-align: center; }
.perf-value { font-size: 18px; font-weight: 600; }
.perf-label { font-size: 11px; color: var(--text-secondary); }

.plan-info {
	background: var(--bg-card);
	padding: 12px 16px;
	border-radius: 8px;
	font-size: 13px;
	margin-top: 16px;
}

.plan-info-row {
	display: flex;
	justify-content: space-between;
	padding: 4px 0;
}

.plan-info-label { color: var(--text-secondary); }

.section-title {
	font-size: 20px;
	font-weight: 600;
	margin-bottom: 20px;
	color: var(--text-primary);
}

.cache-info {
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
}

.cache-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 12px;
}

.cache-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.cache-timestamp { font-size: 13px; color: var(--accent-blue); }

.data-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	max-height: 200px;
	overflow-y: auto;
	padding: 12px;
	background: var(--bg-card);
	border-radius: 8px;
}

.data-list::-webkit-scrollbar { width: 6px; }
.data-list::-webkit-scrollbar-track { background: var(--bg-card); border-radius: 3px; }
.data-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.data-tag {
	display: inline-block;
	padding: 4px 8px;
	background: var(--bg-primary);
	border-radius: 4px;
	font-size: 12px;
	font-family: monospace;
	color: var(--text-secondary);
}

.country-tag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	background: var(--bg-primary);
	border-radius: 4px;
	font-size: 12px;
}

.country-tag.eu-country { border: 1px solid var(--accent-blue); }
.country-code { font-family: monospace; color: var(--accent-purple); font-weight: 600; }
.country-rate { color: var(--accent-green); font-weight: 500; }

.rate-tag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	background: var(--bg-primary);
	border-radius: 4px;
	font-size: 12px;
}

.rate-tag .currency-code { font-family: monospace; color: var(--accent-purple); font-weight: 600; }
.rate-tag .currency-rate { color: var(--accent-green); font-weight: 500; font-family: monospace; }

/* ───── Recommendations View ───── */
.chart-section {
	background: var(--bg-secondary);
	border-radius: 12px;
	padding: 24px;
	border: 1px solid var(--border);
	margin-bottom: 20px;
}

.bar-chart { display: flex; flex-direction: column; gap: 12px; }

.bar-row { display: flex; align-items: center; gap: 12px; }

.bar-label {
	width: 100px;
	font-size: 14px;
	color: var(--text-secondary);
	text-align: right;
	flex-shrink: 0;
}

.bar-container {
	flex: 1;
	background: var(--bg-card);
	border-radius: 6px;
	height: 32px;
	position: relative;
	overflow: hidden;
}

.bar-fill {
	height: 100%;
	border-radius: 6px;
	display: flex;
	align-items: center;
	padding: 0 12px;
	color: white;
	font-size: 13px;
	font-weight: 600;
	transition: width 0.3s ease;
	min-width: 0;
}

.bar-value { width: 60px; text-align: right; font-size: 14px; font-weight: 600; }

.stores-table {
	width: 100%;
	background: var(--bg-secondary);
	border-radius: 12px;
	overflow: hidden;
	border: 1px solid var(--border);
	margin-bottom: 20px;
}

.stores-table th,
.stores-table td { padding: 16px; text-align: left; }

.stores-table th {
	background: var(--bg-card);
	color: var(--text-secondary);
	font-weight: 500;
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.stores-table tr { border-bottom: 1px solid var(--border); }
.stores-table tr:last-child { border-bottom: none; }
.stores-table tbody tr:hover { background: rgba(168, 85, 247, 0.05); }

.status-badge.status-ready { background: rgba(34, 197, 94, 0.2); color: var(--accent-green); }
.status-badge.status-not-initialized { background: rgba(148, 163, 184, 0.2); color: var(--text-secondary); }
.status-badge.status-unknown { background: rgba(234, 179, 8, 0.2); color: var(--accent-yellow); }

.activity-badge {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 500;
}

.activity-active { background: rgba(34, 197, 94, 0.2); color: var(--accent-green); }
.activity-inactive { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-title { font-size: 20px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state-text { font-size: 14px; }

.metric-highlight { color: var(--accent-purple); font-weight: 600; }

.timeline-chart {
	background: var(--bg-secondary);
	border-radius: 12px;
	padding: 24px;
	border: 1px solid var(--border);
	margin-bottom: 24px;
}

.timeline-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
}

.timeline-legend { display: flex; gap: 16px; flex-wrap: wrap; }

.legend-item {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	color: var(--text-secondary);
}

.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

.timeline-svg { width: 100%; height: 200px; }
.timeline-grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 4; }
.timeline-axis-label { fill: var(--text-secondary); font-size: 11px; }
.timeline-bar { transition: opacity 0.2s; }
.timeline-bar:hover { opacity: 0.8; }

/* ───── Responsive ───── */
@media (max-width: 1200px) {
	.workers-table, .stores-table { display: block; overflow-x: auto; }
}

@media (max-width: 900px) {
	.cards-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
	.grid, .stats-grid { grid-template-columns: 1fr; }
	.chart-grid { grid-template-columns: 1fr; }
	.performance-stats { grid-template-columns: repeat(2, 1fr); }

	header {
		flex-direction: column;
		gap: 12px;
		text-align: center;
	}

	.header-info { flex-direction: column; }
}

@media (max-width: 600px) {
	.threshold-row { grid-template-columns: 1fr; }
}
