/**
 * Modern Admin styles for Hooktrace timeline UI.
 */

/* Prevent body scroll when modal is open */
body.trace-modal-open {
	overflow: hidden !important;
	position: fixed;
	width: 100%;
	height: 100%;
}

.trace-timeline-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 999999;
	animation: fadeIn 0.2s ease-out;
	overflow: hidden;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.trace-timeline-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.75);
	backdrop-filter: blur(4px);
}

.trace-timeline-container {
	position: absolute;
	top: 32px;
	left: 50%;
	transform: translateX(-50%);
	width: 95%;
	max-width: 1600px;
	max-height: calc(100vh - 64px);
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
	from {
		transform: translateX(-50%) translateY(-10px);
		opacity: 0;
	}
	to {
		transform: translateX(-50%) translateY(0);
		opacity: 1;
	}
}

.trace-timeline-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 20px;
	border-bottom: 1px solid #e5e7eb;
	background: #1e293b;
	color: #fff;
}

.trace-timeline-header h2 {
	color: #fff;
	margin: 0;
	font-size: 14px;
	font-weight: 500;
	letter-spacing: -0.02em;
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
}

.trace-timeline-header h2 code {
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	padding: 4px 10px;
	border-radius: 4px;
	font-size: 13px;
	font-weight: 600;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
}

.trace-timeline-header .trace-hook-count {
	font-weight: 400;
	color: rgba(255, 255, 255, 0.6);
	font-size: 12px;
}

.trace-header-filter {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
}

.trace-header-filter label {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.7);
	font-weight: 500;
}

.trace-header-filter .trace-filter-select {
	padding: 5px 10px;
	font-size: 12px;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: #fff;
	border-radius: 4px;
	min-width: 150px;
	max-width: 250px;
}

.trace-header-filter .trace-filter-select option {
	background: #1e293b;
	color: #fff;
}

.trace-timeline-close,
.trace-clear-selection {
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: #fff;
	font-size: 12px;
	line-height: 1;
	cursor: pointer;
	padding: 6px 12px;
	border-radius: 4px;
	transition: all 0.15s ease;
	font-weight: 500;
}

.trace-timeline-close {
	font-size: 18px;
	padding: 4px;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.trace-timeline-close:hover,
.trace-clear-selection:hover {
	background: rgba(255, 255, 255, 0.2);
	transform: translateY(-1px);
}

.trace-timeline-close:active,
.trace-clear-selection:active {
	transform: translateY(0);
}

/* Filters */
.trace-filters {
	display: flex;
	gap: 16px;
	padding: 20px 28px;
	border-bottom: 1px solid #e5e7eb;
	background: #f8fafc;
	align-items: center;
	flex-wrap: wrap;
}

.trace-search-box {
	flex: 1;
	min-width: 280px;
	position: relative;
}


.trace-search-input {
	width: 100%;
	padding: 10px 14px;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	font-size: 14px;
	transition: all 0.2s ease;
	background: #fff;
}

.trace-search-input:focus {
	outline: none;
	border-color: #3b82f6;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.trace-filter-group {
	display: flex;
	align-items: center;
	gap: 10px;
}

.trace-filter-group label {
	font-size: 13px;
	font-weight: 600;
	color: #475569;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.trace-filter-select {
	padding: 10px 14px;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	font-size: 13px;
	background: #fff;
	cursor: pointer;
	transition: all 0.2s ease;
	font-weight: 500;
	min-width: 120px;
}

.trace-filter-select:focus {
	outline: none;
	border-color: #3b82f6;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Selected Hook Info */
.trace-selected-hook-info {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	overflow: hidden;
}

#trace-selected-hook-details {
	flex: 1;
	overflow-y: auto;
	padding: 0 20px 16px 20px;
	background: #f8fafc;
	min-height: 0;
}

/* Hooks List */
.trace-timeline-content {
	flex: 1;
	overflow-y: auto;
	padding: 24px 28px;
	background: #f8fafc;
}

.trace-hook-item {
	padding: 16px 20px;
	margin-bottom: 12px;
	border-left: 4px solid #3b82f6;
	background: #ffffff;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
	display: flex;
	justify-content: space-between;
	align-items: center;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.trace-hook-item:hover {
	background: #f1f5f9;
	border-left-color: #2563eb;
	transform: translateX(4px);
	box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.trace-hook-item:active {
	transform: translateX(2px);
}

.trace-hook-name {
	font-weight: 600;
	color: #1e40af;
	font-size: 15px;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
	letter-spacing: -0.01em;
}

.trace-hook-count {
	font-weight: 400;
	color: #64748b;
	font-size: 13px;
	margin-left: 8px;
	opacity: 0.7;
}

.trace-hook-meta {
	display: flex;
	gap: 10px;
	align-items: center;
}

.trace-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 4px;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.3px;
}

.trace-badge-core {
	background: #dc2626;
	color: #fff;
}

.trace-badge-theme {
	background: #0284c7;
	color: #fff;
}

.trace-badge-plugin {
	background: #16a34a;
	color: #fff;
}

.trace-badge-action {
	background: #7c3aed;
	color: #fff;
}

.trace-badge-filter {
	background: #ea580c;
	color: #fff;
}

/* Compact Callback View */
.trace-callback-item {
	padding: 10px 14px;
	margin-bottom: 8px;
	border-left: 3px solid #10b981;
	background: #ffffff;
	border-radius: 6px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	transition: all 0.15s ease;
}

.trace-callback-item:hover {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	border-left-color: #059669;
}

.trace-callback-header {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.trace-callback-name {
	font-weight: 600;
	color: #0f172a;
	font-size: 13px;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
	word-break: break-all;
}

.trace-callback-meta {
	font-size: 11px;
	color: #64748b;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
	background: #f1f5f9;
	padding: 2px 6px;
	border-radius: 4px;
}

/* File path display */
.trace-file-path {
	font-size: 11px;
	color: #94a3b8;
	margin-top: 6px;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
	line-height: 1.4;
}

.trace-file-path-text {
	word-break: break-all;
	margin-bottom: 4px;
}

.trace-file-links {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.trace-file-link {
	color: #3b82f6;
	text-decoration: none;
	transition: color 0.15s ease;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	padding: 2px 6px;
	border-radius: 3px;
	background: rgba(59, 130, 246, 0.1);
}

.trace-file-link:hover {
	color: #2563eb;
	background: rgba(59, 130, 246, 0.15);
	text-decoration: none;
}

.trace-file-link .dashicons {
	font-size: 14px;
	width: 14px;
	height: 14px;
	vertical-align: middle;
	opacity: 0.8;
}

.trace-file-link-local {
	color: #10b981;
	background: rgba(16, 185, 129, 0.1);
}

.trace-file-link-local:hover {
	color: #059669;
	background: rgba(16, 185, 129, 0.15);
}

.trace-file-link-wp {
	color: #3b82f6;
	background: rgba(59, 130, 246, 0.1);
}

.trace-file-link-wp:hover {
	color: #2563eb;
	background: rgba(59, 130, 246, 0.15);
}

.trace-file-link-separator {
	color: #cbd5e1;
	margin: 0 2px;
}

/* Empty state */
.trace-empty {
	text-align: center;
	padding: 80px 20px;
	color: #64748b;
}

.trace-empty-icon {
	font-size: 64px;
	margin-bottom: 20px;
	opacity: 0.4;
	filter: grayscale(0.3);
}

.trace-empty p {
	margin: 0;
	font-size: 15px;
	font-weight: 500;
	color: #475569;
}

.trace-empty p:first-of-type {
	font-size: 18px;
	font-weight: 600;
	color: #334155;
	margin-bottom: 8px;
}

/* Scrollbar styling */
.trace-timeline-content::-webkit-scrollbar,
#trace-selected-hook-details::-webkit-scrollbar {
	width: 10px;
}

.trace-timeline-content::-webkit-scrollbar-track,
#trace-selected-hook-details::-webkit-scrollbar-track {
	background: #f1f5f9;
	border-radius: 5px;
}

.trace-timeline-content::-webkit-scrollbar-thumb,
#trace-selected-hook-details::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 5px;
	border: 2px solid #f1f5f9;
}

.trace-timeline-content::-webkit-scrollbar-thumb:hover,
#trace-selected-hook-details::-webkit-scrollbar-thumb:hover {
	background: #94a3b8;
}

/* Loading state */
.trace-loading {
	text-align: center;
	padding: 60px;
	color: #64748b;
}

/* Responsive adjustments */
@media (max-width: 768px) {
	.trace-timeline-container {
		top: 0;
		width: 100%;
		max-height: 100vh;
		border-radius: 0;
	}

	.trace-timeline-header {
		padding: 20px;
	}

	.trace-filters {
		padding: 16px 20px;
		flex-direction: column;
		align-items: stretch;
	}

	.trace-search-box {
		min-width: 100%;
	}

	.trace-filter-group {
		width: 100%;
		justify-content: space-between;
	}

	.trace-filter-select {
		flex: 1;
	}

	.trace-timeline-content {
		padding: 16px 20px;
	}

	.trace-callback-details {
		grid-template-columns: 1fr;
	}
}

/* Smooth transitions for all interactive elements */
.trace-hook-item,
.trace-callback-item,
.trace-detail-item,
.trace-timeline-close,
.trace-clear-selection {
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus states for accessibility */
.trace-hook-item:focus-visible,
.trace-callback-item:focus-visible {
	outline: 2px solid #3b82f6;
	outline-offset: 2px;
}

/* Sticky header for filter and stats */
.trace-sticky-header {
	position: sticky;
	top: 0;
	z-index: 10;
	background: #f8fafc;
	margin: -16px -20px 12px -20px;
	padding: 12px 20px 10px 20px;
}

/* Statistics Banner */
.trace-stats-banner {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 10px 14px;
	background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
	border-radius: 8px;
}

.trace-stat-item {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 6px;
}

.trace-stat-label {
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.6);
	letter-spacing: 0.3px;
}

.trace-stat-value {
	font-size: 13px;
	font-weight: 700;
	color: #fff;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
}

/* Duration Badge in callback header */
.trace-duration-badge {
	display: inline-block;
	padding: 3px 8px;
	background: #f59e0b;
	color: #fff;
	border-radius: 4px;
	font-size: 11px;
	font-weight: 700;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
	margin-left: auto;
}

/* Callbacks list container - no nested scroll */
.trace-callbacks-list {
	padding-top: 20px;
	/* Single scroll area from parent */
}

/* Responsive adjustments for stats */
@media (max-width: 768px) {
	.trace-timeline-header {
		flex-wrap: wrap;
		gap: 8px;
	}

	.trace-timeline-header h2 {
		width: 100%;
	}

	.trace-header-filter {
		margin-left: 0;
	}

	.trace-sticky-header {
		margin: -12px -16px 10px -16px;
		padding: 10px 16px 8px 16px;
	}

	#trace-selected-hook-details {
		padding: 12px 16px;
	}

	.trace-stats-banner {
		flex-wrap: wrap;
	}

	.trace-callback-header {
		flex-wrap: wrap;
	}
}
