/**
 * Frontend Styles
 *
 * @package SBSM\AITranscription
 */

/* Search Container */
.sbsm-transcript-search {
	max-width: 800px;
	margin: 30px auto;
	padding: 0 15px;
}

/* Search Form */
.sbsm-search-form {
	margin-bottom: 30px;
}

.sbsm-search-input-wrapper {
	display: flex;
	gap: 10px;
	margin-bottom: 15px;
}

.sbsm-search-input {
	flex: 1;
	padding: 12px 15px;
	font-size: 16px;
	border: 2px solid #ddd;
	border-radius: 4px;
	transition: border-color 0.3s;
	background-color: #fff !important;
	color: #1a1a1a !important;
}

.sbsm-search-input:focus {
	outline: none;
	border-color: #0073aa;
	box-shadow: 0 0 0 1px #0073aa;
}

.sbsm-search-button {
	padding: 12px 24px;
	background: #0073aa;
	color: white;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 16px;
	font-weight: 500;
	transition: background 0.3s;
}

.sbsm-search-button:hover {
	background: #005a87;
}

.sbsm-search-button .dashicons {
	font-size: 20px;
	width: 20px;
	height: 20px;
}

/* Filters */
.sbsm-search-filters {
	padding: 15px;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;
	margin-top: 15px;
}

.sbsm-search-filters label {
	display: block;
	margin-bottom: 10px;
}

.sbsm-search-filters select {
	padding: 5px 10px;
	border: 1px solid #ddd;
	border-radius: 3px;
}

.sbsm-toggle-filters {
	background: none;
	border: none;
	color: #0073aa;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 13px;
	padding: 5px 0;
	transition: color 0.3s;
}

.sbsm-toggle-filters:hover {
	color: #005a87;
	text-decoration: underline;
}

.sbsm-toggle-filters .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

/* Loading Indicator */
.sbsm-search-loading {
	text-align: center;
	padding: 40px 20px;
	color: #666;
}

.sbsm-search-loading .spinner {
	float: none;
	margin: 0 auto 10px;
}

/* Search Results */
.sbsm-search-results {
	margin-top: 30px;
}

.sbsm-search-result {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 20px;
	margin-bottom: 15px;
	transition: box-shadow 0.3s, transform 0.2s;
}

.sbsm-search-result:hover {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	transform: translateY(-2px);
}

.sbsm-result-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 15px;
	flex-wrap: wrap;
	gap: 10px;
}

.sbsm-result-header h3 {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
}

.sbsm-result-header h3 a {
	color: #0073aa;
	text-decoration: none;
	transition: color 0.3s;
}

.sbsm-result-header h3 a:hover {
	color: #005a87;
	text-decoration: underline;
}

.sbsm-result-timestamp {
	background: #0073aa;
	color: white;
	padding: 5px 12px;
	border-radius: 3px;
	font-weight: bold;
	font-size: 14px;
	white-space: nowrap;
}

.sbsm-result-content {
	margin: 15px 0;
	line-height: 1.7;
	color: #333;
}

.sbsm-result-content p {
	margin: 0;
}

/* Q&A Badge */
.sbsm-qa-badge {
	background: #d4edda;
	border: 1px solid #c3e6cb;
	padding: 12px;
	border-radius: 4px;
	margin-top: 15px;
}

.sbsm-qa-badge strong {
	color: #155724;
	display: block;
	margin-bottom: 8px;
}

.sbsm-qa-badge p {
	margin: 5px 0 0 0;
	color: #155724;
}

/* Result Actions */
.sbsm-result-actions {
	margin-top: 15px;
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
}

.sbsm-result-actions .button,
.sbsm-segment-actions .button {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 8px 16px;
	text-decoration: none;
	border-radius: 4px;
	transition: all 0.3s;
}

.sbsm-result-actions .button-primary,
.sbsm-segment-actions .button-primary {
	background: #0073aa;
	color: white;
	border: none;
}

.sbsm-result-actions .button-primary:hover,
.sbsm-segment-actions .button-primary:hover {
	background: #005a87;
}

.sbsm-result-actions .button .dashicons,
.sbsm-segment-actions .button .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

/* Load More */
.sbsm-load-more-wrapper {
	text-align: center;
	margin-top: 30px;
	padding: 20px 0;
}

.sbsm-load-more {
	padding: 12px 30px;
	font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
	.sbsm-search-input-wrapper {
		flex-direction: column;
	}

	.sbsm-search-button {
		width: 100%;
		justify-content: center;
	}

	.sbsm-result-header {
		flex-direction: column;
		align-items: flex-start;
	}

	.sbsm-result-actions,
	.sbsm-segment-actions {
		flex-direction: column;
		width: 100%;
	}

	.sbsm-result-actions .button,
	.sbsm-segment-actions .button {
		width: 100%;
		justify-content: center;
	}

	.sbsm-transcript-search {
		padding: 0 10px;
	}
}

@media (max-width: 480px) {
	.sbsm-search-input {
		font-size: 14px;
	}

	.sbsm-result-header h3 {
		font-size: 16px;
	}

	.sbsm-search-result {
		padding: 15px;
	}
}

/* =====================================================
   AI Q&A Interface Styles
   ===================================================== */

/* Question Textarea */
.sbsm-search-input.sbsm-ai-question {
	min-height: 80px;
	resize: vertical;
	font-family: inherit;
	line-height: 1.5;
}

/* AI Loading State */
.sbsm-ai-loading {
	text-align: center;
	padding: 60px 20px;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 8px;
	margin-top: 30px;
}

.sbsm-ai-loading.hidden {
	display: none;
}

/* Loading Spinner */
.sbsm-spinner {
	width: 48px;
	height: 48px;
	border: 4px solid #d4d4d4;
	border-top-color: #6bb3a0;
	border-radius: 50%;
	animation: sbsm-spin 1s linear infinite;
	margin: 0 auto 15px;
}

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

/* Reduced motion: show static spinner */
@media (prefers-reduced-motion: reduce) {
	.sbsm-spinner {
		animation: none;
		border-color: #6bb3a0;
	}
}

.sbsm-ai-loading p {
	color: #666;
	margin: 0;
	font-size: 15px;
}

.sbsm-ai-loading p:last-child {
	font-size: 13px;
	color: #999;
	margin-top: 8px;
}

/* AI Response Container */
.sbsm-ai-response {
	background: #fff;
	border: 1px solid #eee;
	border-radius: 8px;
	padding: 25px;
	margin-top: 30px;
}

.sbsm-ai-response.hidden {
	display: none;
}

/* Crisis Response Styling */
.sbsm-ai-response.sbsm-crisis-response {
	background: #fff5f5;
	border-color: #feb2b2;
}

.sbsm-ai-response.sbsm-crisis-response .sbsm-ai-answer {
	border-left: 4px solid #e53e3e;
	padding-left: 20px;
}

/* AI Answer Section */
.sbsm-ai-answer {
	margin-bottom: 25px;
}

.sbsm-ai-answer h3 {
	margin: 0 0 15px 0;
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: #666;
}

.sbsm-ai-answer-content {
	font-size: 16px;
	line-height: 1.8;
	color: #333;
}

.sbsm-ai-answer-content p {
	margin: 0 0 15px 0;
}

.sbsm-ai-answer-content p:last-child {
	margin-bottom: 0;
}

/* Markdown Headings in Answer */
.sbsm-ai-answer-content h3.sbsm-md-h1 {
	font-size: 1.3em;
	font-weight: 600;
	margin: 20px 0 12px 0;
	color: #222;
	line-height: 1.4;
}

.sbsm-ai-answer-content h3.sbsm-md-h1:first-child {
	margin-top: 0;
}

.sbsm-ai-answer-content h4.sbsm-md-h2 {
	font-size: 1.15em;
	font-weight: 600;
	margin: 18px 0 10px 0;
	color: #333;
	line-height: 1.4;
}

.sbsm-ai-answer-content h4.sbsm-md-h2:first-child {
	margin-top: 0;
}

.sbsm-ai-answer-content h5.sbsm-md-h3 {
	font-size: 1.05em;
	font-weight: 600;
	margin: 15px 0 8px 0;
	color: #444;
	line-height: 1.4;
}

.sbsm-ai-answer-content h5.sbsm-md-h3:first-child {
	margin-top: 0;
}

/* Markdown Lists in Answer - Using explicit CSS counters for reliability */
.sbsm-ai-answer-content ul.sbsm-md-list,
.sbsm-ai-answer-content ol.sbsm-md-list {
    margin: 15px 0 !important;
    padding-left: 0 !important;
    list-style: none !important;
}

.sbsm-ai-answer-content ol.sbsm-md-list {
    counter-reset: sbsm-list-counter !important;
}

.sbsm-ai-answer-content ul.sbsm-md-list li,
.sbsm-ai-answer-content ol.sbsm-md-list li {
    margin-bottom: 8px !important;
    line-height: 1.6 !important;
    padding-left: 30px !important;
    position: relative !important;
}

.sbsm-ai-answer-content ul.sbsm-md-list li:last-child,
.sbsm-ai-answer-content ol.sbsm-md-list li:last-child {
    margin-bottom: 0 !important;
}

/* Ordered list numbering via CSS counter */
.sbsm-ai-answer-content ol.sbsm-md-list li {
    counter-increment: sbsm-list-counter !important;
}

.sbsm-ai-answer-content ol.sbsm-md-list li::before {
    content: counter(sbsm-list-counter) ". " !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    font-weight: 500 !important;
    color: inherit !important;
    display: inline !important;
    background: none !important;
    width: auto !important;
    height: auto !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Unordered list bullets */
.sbsm-ai-answer-content ul.sbsm-md-list li::before {
    content: "\2022" !important;  /* Bullet character */
    position: absolute !important;
    left: 10px !important;
    top: 0 !important;
    color: inherit !important;
    display: inline !important;
    background: none !important;
    width: auto !important;
    height: auto !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Reset any theme ::after markers */
.sbsm-ai-answer-content ol.sbsm-md-list li::after,
.sbsm-ai-answer-content ul.sbsm-md-list li::after {
    content: none !important;
    display: none !important;
}

/* Source Reference in Answer Text */
.sbsm-source-ref {
	background: #e8f4fc;
	color: #0073aa;
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
}

/* Markdown Links in Answer */
.sbsm-ai-answer-content a.sbsm-md-link {
	color: #0073aa;
	text-decoration: underline;
	transition: color 0.2s;
}

.sbsm-ai-answer-content a.sbsm-md-link:hover {
	color: #005a87;
}

.sbsm-ai-answer-content a.sbsm-md-link:visited {
	color: #5c3d9a;
}

/* Error Message */
.sbsm-error-message {
	color: #c53030;
	background: #fff5f5;
	border: 1px solid #feb2b2;
	padding: 15px;
	border-radius: 4px;
}

/* AI Sources Section */
.sbsm-ai-sources {
	border-top: 1px solid #eee;
	padding-top: 20px;
}

.sbsm-ai-sources.hidden {
	display: none;
}

.sbsm-ai-sources h4 {
	margin: 0 0 15px 0;
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: #666;
}

.sbsm-ai-sources-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

.sbsm-source-item {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px;
	background: #fff;
	border: 1px solid #eee;
	border-radius: 4px;
	margin-bottom: 8px;
	transition: background-color 0.2s;
}

.sbsm-source-item:last-child {
	margin-bottom: 0;
}

.sbsm-source-item:hover {
	background: #fafafa;
}

.sbsm-source-label {
	background: #0073aa;
	color: #fff;
	padding: 3px 8px;
	border-radius: 3px;
	font-size: 12px;
	font-weight: 600;
}

.sbsm-source-title {
	font-weight: 500;
	color: #333;
}

.sbsm-source-timestamp {
	color: #666;
	font-size: 14px;
}

.sbsm-source-play-btn {
	background: #0073aa;
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	margin-left: auto;
	transition: background-color 0.2s, transform 0.2s;
}

.sbsm-source-play-btn:hover {
	background: #005a87;
	transform: scale(1.1);
}

.sbsm-source-play-btn svg {
	width: 16px;
	height: 16px;
}

/* Keyword Cloud */
.sbsm-keyword-cloud {
	margin-bottom: 30px;
	text-align: center;
}

.sbsm-keyword-cloud.hidden {
	display: none;
}

.sbsm-keyword-cloud p {
	color: #666;
	font-size: 14px;
	margin-bottom: 12px;
}

.sbsm-keyword-cloud-items {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}

.sbsm-keyword-cloud-item {
	background: #f0f0f0;
	border: 1px solid #ddd;
	color: #333;
	padding: 6px 14px;
	border-radius: 20px;
	font-size: 14px;
	cursor: pointer;
	transition: all 0.2s;
}

.sbsm-keyword-cloud-item:hover {
	background: #0073aa;
	border-color: #0073aa;
	color: #fff;
}

/* Player Modal */
.sbsm-player-modal {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 100000;
}

.sbsm-modal-backdrop {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.75);
}

.sbsm-modal-content {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: #fff;
	border-radius: 8px;
	max-width: 90%;
	max-height: 90vh;
	width: 800px;
	overflow: hidden;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.sbsm-modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 15px 20px;
	background: #f5f5f5;
	border-bottom: 1px solid #ddd;
}

.sbsm-player-title {
	font-weight: 600;
	font-size: 16px;
	margin: 0;
	color: #333;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	flex: 1;
	margin-right: 15px;
}

.sbsm-modal-close {
	background: none;
	border: none;
	font-size: 28px;
	color: #666;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	transition: color 0.2s;
}

.sbsm-modal-close:hover {
	color: #333;
}

.sbsm-player-container {
	padding: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	background: #000;
}

.sbsm-player-container video,
.sbsm-player-container audio {
	max-width: 100%;
}

.sbsm-player-container audio {
	min-width: 300px;
}

/* Modal open state */
body.sbsm-modal-open {
	overflow: hidden;
}

/* =====================================================
   Responsive Adjustments for AI Q&A
   ===================================================== */

@media (max-width: 768px) {
	.sbsm-ai-response {
		padding: 20px 15px;
	}

	.sbsm-source-item {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.sbsm-source-play-btn {
		margin-left: 0;
	}

	.sbsm-modal-content {
		width: 95%;
		max-height: 85vh;
	}

	.sbsm-player-title {
		font-size: 14px;
	}
}

@media (max-width: 480px) {
	.sbsm-ai-loading {
		padding: 40px 15px;
	}

	.sbsm-ai-answer-content {
		font-size: 15px;
		line-height: 1.7;
	}

	.sbsm-keyword-cloud-item {
		font-size: 13px;
		padding: 5px 12px;
	}
}

/* =====================================================
   Howler.js Custom Audio Player
   ===================================================== */

.sbsm-howler-player {
	display: flex;
	align-items: center;
	gap: 15px;
	background: #1a1a1a;
	padding: 15px 20px;
	border-radius: 8px;
	width: 100%;
	max-width: 500px;
}

.sbsm-howler-playpause {
	background: #0073aa;
	border: none;
	border-radius: 50%;
	width: 44px;
	height: 44px;
	min-width: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #fff;
	transition: background-color 0.2s, transform 0.1s;
}

.sbsm-howler-playpause:hover {
	background: #005a87;
}

.sbsm-howler-playpause:active {
	transform: scale(0.95);
}

.sbsm-howler-playpause svg {
	width: 24px;
	height: 24px;
}

.sbsm-howler-progress-container {
	flex: 1;
}

.sbsm-howler-progress {
	height: 8px;
	background: #333;
	border-radius: 4px;
	cursor: pointer;
	position: relative;
	overflow: hidden;
}

.sbsm-howler-progress:hover {
	background: #444;
}

.sbsm-howler-progress-fill {
	height: 100%;
	background: #0073aa;
	border-radius: 4px;
	width: 0%;
	transition: width 0.1s linear;
}

.sbsm-howler-time {
	color: #ccc;
	font-size: 13px;
	font-family: monospace;
	white-space: nowrap;
	min-width: 90px;
	text-align: right;
}

.sbsm-howler-time .sbsm-current-time {
	color: #fff;
}

/* Fallback player styles */
.sbsm-fallback-player {
	width: 100%;
	max-width: 500px;
}

/* Responsive Howler Player */
@media (max-width: 480px) {
	.sbsm-howler-player {
		gap: 10px;
		padding: 12px 15px;
	}

	.sbsm-howler-playpause {
		width: 40px;
		height: 40px;
		min-width: 40px;
	}

	.sbsm-howler-playpause svg {
		width: 20px;
		height: 20px;
	}

	.sbsm-howler-time {
		font-size: 12px;
		min-width: 80px;
	}
}

