/**
 * Frontend styles for Video Chapters - Segmented Timeline Layout
 *
 * Theme colors:
 * - Primary: #ef9b26 (Tutor LMS golden orange)
 * - Background: #2d2d2d (site dark background)
 *
 * @package CFM_Mux_Video_Manager
 */

.cfm-video-chapters {
	margin: 16px 2em 24px;
	background: #2d2d2d;
	border-radius: 8px;
	overflow: hidden;
}

/* Header with toggle */
.cfm-video-chapters .cfm-chapters-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 16px;
	background: #363636;
	cursor: pointer;
	transition: background 0.2s;
}

.cfm-video-chapters .cfm-chapters-header:hover {
	background: #3d3d3d;
}

.cfm-video-chapters .cfm-chapters-title {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	color: #fff;
}

.cfm-video-chapters .cfm-chapters-title svg {
	width: 16px;
	height: 16px;
	fill: #ef9b26;
}

.cfm-video-chapters .cfm-chapters-count {
	font-size: 12px;
	font-weight: 400;
	color: #999;
}

/* Main header caret (not a button - avoids theme overrides) */
.cfm-video-chapters .cfm-chapters-caret {
	width: 20px;
	height: 20px;
	fill: #ef9b26;
	flex-shrink: 0;
	transition: transform 0.2s;
}

.cfm-video-chapters.is-collapsed .cfm-chapters-caret {
	transform: rotate(-90deg);
}

/* Content area */
.cfm-video-chapters .cfm-chapters-content {
	overflow: hidden;
	transition: max-height 0.3s ease-out;
}

.cfm-video-chapters.is-collapsed .cfm-chapters-content {
	max-height: 0 !important;
}

/* Segmented timeline */
.cfm-video-chapters .cfm-chapters-timeline {
	display: flex;
	height: 12px;
	margin: 16px 16px 0;
	background: #444;
	border-radius: 6px;
	overflow: hidden;
}

/* Individual segment */
.cfm-video-chapters .cfm-segment {
	position: relative;
	height: 100%;
	background: #555;
	border-right: 1px solid #2d2d2d;
	cursor: pointer;
	transition: background 0.15s, transform 0.15s;
	transform-origin: center center;
}

.cfm-video-chapters .cfm-segment:last-child {
	border-right: none;
}

.cfm-video-chapters .cfm-segment:hover,
.cfm-video-chapters .cfm-segment.is-hovered {
	background: #ef9b26;
	transform: scaleY(1.5);
	z-index: 10;
}

.cfm-video-chapters .cfm-segment.is-active {
	background: #ef9b26;
	box-shadow: 0 0 8px rgba(239, 155, 38, 0.5);
}

/* JS Tooltip (positioned by JavaScript) */
.cfm-tooltip {
	position: fixed;
	padding: 6px 10px;
	background: #1a1a1a;
	color: #fff;
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
	border-radius: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
	pointer-events: none;
	z-index: 10000;
	opacity: 0;
	transform: translateX(-50%) translateY(-100%);
	transition: opacity 0.05s;
}

.cfm-tooltip.is-visible {
	opacity: 1;
}

/* Tooltip arrow */
.cfm-tooltip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 5px solid transparent;
	border-top-color: #1a1a1a;
}

/* Chapter list toggle button - increased specificity */
.cfm-video-chapters .cfm-chapter-list-toggle {
	padding: 12px 16px 0;
}

.cfm-video-chapters button.cfm-list-toggle-btn {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	background: transparent;
	border: 1px solid #444;
	border-radius: 4px;
	color: #999;
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cfm-video-chapters button.cfm-list-toggle-btn:hover,
.cfm-video-chapters button.cfm-list-toggle-btn:focus {
	background: #363636;
	color: #fff;
	border-color: #555;
}

.cfm-video-chapters .cfm-toggle-icon {
	width: 14px;
	height: 14px;
	fill: currentColor;
	transition: transform 0.2s;
}

.cfm-video-chapters .cfm-chapter-list.is-collapsed + .cfm-chapter-list-toggle .cfm-toggle-icon,
.cfm-video-chapters .cfm-chapter-list-toggle:has(+ .cfm-chapter-list.is-collapsed) .cfm-toggle-icon {
	transform: rotate(-90deg);
}

/* Fix: toggle icon when list is expanded */
.cfm-video-chapters .cfm-chapter-list:not(.is-collapsed) ~ .cfm-chapter-list-toggle .cfm-toggle-icon {
	transform: rotate(0deg);
}

/* Chapter list */
.cfm-video-chapters .cfm-chapter-list {
	margin: 12px 16px 16px;
	max-height: 300px;
	overflow-y: auto;
	overflow-x: hidden;
	transition: max-height 0.3s ease-out, opacity 0.2s, margin 0.2s;
}

.cfm-video-chapters .cfm-chapter-list.is-collapsed {
	max-height: 0 !important;
	opacity: 0;
	margin-top: 0;
	margin-bottom: 0;
	overflow: hidden;
}

/* Chapter list item */
.cfm-video-chapters .cfm-chapter-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	background: #363636;
	border-radius: 4px;
	margin-bottom: 4px;
	cursor: pointer;
	transition: background 0.15s, transform 0.1s;
}

.cfm-video-chapters .cfm-chapter-item:last-child {
	margin-bottom: 0;
}

.cfm-video-chapters .cfm-chapter-item:hover {
	background: #444;
}

.cfm-video-chapters .cfm-chapter-item:active {
	transform: scale(0.99);
}

.cfm-video-chapters .cfm-chapter-item.is-active {
	background: rgba(239, 155, 38, 0.15);
	border-left: 3px solid #ef9b26;
}

.cfm-video-chapters .cfm-chapter-item.is-active .cfm-chapter-time {
	color: #ef9b26;
}

.cfm-video-chapters .cfm-chapter-time {
	flex-shrink: 0;
	font-size: 12px;
	font-family: monospace;
	color: #888;
	min-width: 40px;
}

.cfm-video-chapters .cfm-chapter-title {
	font-size: 13px;
	color: #ddd;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cfm-video-chapters .cfm-chapter-item:hover .cfm-chapter-title {
	color: #fff;
}

/* Scrollbar styling for chapter list */
.cfm-video-chapters .cfm-chapter-list::-webkit-scrollbar {
	width: 6px;
}

.cfm-video-chapters .cfm-chapter-list::-webkit-scrollbar-track {
	background: #2d2d2d;
	border-radius: 3px;
}

.cfm-video-chapters .cfm-chapter-list::-webkit-scrollbar-thumb {
	background: #555;
	border-radius: 3px;
}

.cfm-video-chapters .cfm-chapter-list::-webkit-scrollbar-thumb:hover {
	background: #666;
}

/* Responsive */
@media (max-width: 768px) {
	.cfm-video-chapters {
		margin: 12px 0 20px;
		border-radius: 6px;
	}

	.cfm-video-chapters .cfm-chapters-header {
		padding: 10px 12px;
	}

	.cfm-video-chapters .cfm-chapters-timeline {
		margin: 12px 12px 0;
		height: 16px;
	}

	.cfm-video-chapters .cfm-chapter-list-toggle {
		padding: 10px 12px 0;
	}

	.cfm-video-chapters .cfm-chapter-list {
		margin: 10px 12px 12px;
	}

	.cfm-video-chapters .cfm-chapter-item {
		padding: 8px 10px;
	}

	.cfm-tooltip {
		font-size: 11px;
		padding: 5px 8px;
	}
}

/* Extra small screens */
@media (max-width: 480px) {
	.cfm-video-chapters .cfm-chapters-timeline {
		height: 20px;
	}

	.cfm-video-chapters .cfm-segment:hover,
	.cfm-video-chapters .cfm-segment.is-hovered {
		transform: scaleY(1.3);
	}
}
