/**
 * MathMedia Studio — Frontend & Admin Stylesheet
 * 
 * Provides responsive video wrappers, accessible image alignments,
 * and unified block builder UI for Notes and Practice Problems.
 */

/* ==========================================================================
   1. Frontend Content Layout & Render Styles
   ========================================================================== */

.mathmedia-content-container {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin: 12px 0;
}

.mathmedia-stage {
	display: flex;
	flex-direction: column;
	gap: 14px;
	width: 100%;
}

.mathmedia-block {
	position: relative;
	width: 100%;
}

/* Image Alignments */
.mathmedia-block-image {
	margin: 14px 0;
	display: flex;
	flex-direction: column;
}

.mathmedia-block-image img.mathmedia-img {
	width: 100%;
	height: auto;
	border-radius: 8px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
	display: block;
}

.mathmedia-align-center {
	margin-left: auto;
	margin-right: auto;
	text-align: center;
	align-items: center;
}

.mathmedia-align-left {
	margin-right: auto;
	text-align: left;
	align-items: flex-start;
}

.mathmedia-align-right {
	margin-left: auto;
	text-align: right;
	align-items: flex-end;
}

.mathmedia-align-full {
	width: 100% !important;
	max-width: 100% !important;
}

.mathmedia-caption {
	font-size: 0.85rem;
	color: #64748b;
	margin-top: 6px;
	font-style: italic;
	text-align: center;
}

/* Responsive 16:9 Video Embeds */
.mathmedia-block-video {
	margin: 16px 0;
	border-radius: 10px;
	overflow: hidden;
	background: #0f172a;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

.mathmedia-responsive-video {
	position: relative;
	padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
	height: 0;
	overflow: hidden;
	width: 100%;
}

.mathmedia-responsive-video iframe,
.mathmedia-responsive-video video {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* LaTeX Block Spacing */
.mathmedia-block-latex {
	margin: 8px 0;
	overflow-x: auto;
	max-width: 100%;
}

/* ==========================================================================
   2. Admin Block Editor UI (Notes Builder & Problem Meta Box)
   ========================================================================== */

.mathmedia-editor-wrap {
	background: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	padding: 12px;
	margin: 10px 0;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.mathmedia-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding-bottom: 10px;
	margin-bottom: 10px;
	border-bottom: 1px solid #e2e8f0;
	align-items: center;
}

.mms-top-image-toolbar {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	background: #0f172a;
	color: #ffffff;
	padding: 4px 10px;
	border-radius: 6px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	margin-left: 4px;
	animation: mmsFadeIn 0.2s ease-in-out;
}

.mms-top-tb-title {
	font-size: 11px;
	font-weight: 700;
	color: #38bdf8;
	display: inline-flex;
	align-items: center;
	gap: 3px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	padding-right: 4px;
	border-right: 1px solid #334155;
}

@keyframes mmsFadeIn {
	from { opacity: 0; transform: translateY(-3px); }
	to { opacity: 1; transform: translateY(0); }
}

.mathmedia-toolbar-title {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #475569;
	margin-right: 4px;
	display: flex;
	align-items: center;
	gap: 4px;
}

.mathmedia-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
	font-weight: 600;
	padding: 5px 10px;
	border-radius: 5px;
	border: 1px solid #cbd5e1;
	background: #f8fafc;
	color: #334155;
	cursor: pointer;
	transition: all 0.15s ease;
	line-height: 1.4;
}

.mathmedia-btn:hover {
	background: #f1f5f9;
	border-color: #94a3b8;
	color: #0f172a;
}

.mathmedia-btn-primary {
	background: #3b82f6;
	border-color: #2563eb;
	color: #ffffff;
}

.mathmedia-btn-primary:hover {
	background: #2563eb;
	border-color: #1d4ed8;
	color: #ffffff;
}

.mathmedia-btn .dashicons {
	font-size: 15px;
	width: 15px;
	height: 15px;
}

/* Blocks List Container */
.mathmedia-blocks-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-height: 40px;
}

.mathmedia-admin-block {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
	overflow: hidden;
	transition: border-color 0.2s;
}

.mathmedia-admin-block:hover {
	border-color: #cbd5e1;
}

.mathmedia-admin-block.is-active {
	border-color: #3b82f6;
	box-shadow: 0 0 0 1px #3b82f6;
}

/* Block Header */
.mathmedia-block-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: #f1f5f9;
	padding: 6px 10px;
	cursor: grab;
	border-bottom: 1px solid #e2e8f0;
}

.mathmedia-block-header-left {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	font-weight: 700;
	color: #475569;
}

.mathmedia-block-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.mathmedia-block-action-btn {
	background: transparent;
	border: none;
	color: #64748b;
	cursor: pointer;
	padding: 2px 4px;
	border-radius: 3px;
	display: inline-flex;
	align-items: center;
}

.mathmedia-block-action-btn:hover {
	background: #e2e8f0;
	color: #0f172a;
}

.mathmedia-block-action-btn.delete-btn:hover {
	background: #fee2e2;
	color: #dc2626;
}

/* Block Body */
.mathmedia-block-body {
	padding: 10px;
}

.mathmedia-block-body textarea {
	width: 100%;
	font-family: monospace;
	font-size: 13px;
	line-height: 1.5;
	border: 1px solid #cbd5e1;
	border-radius: 4px;
	padding: 8px;
}

/* Image Block Form */
.mathmedia-img-controls {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-top: 8px;
}

.mathmedia-img-preview-wrap {
	display: flex;
	gap: 12px;
	align-items: center;
}

.mathmedia-img-preview-thumb {
	width: 80px;
	height: 80px;
	border-radius: 6px;
	object-fit: cover;
	background: #e2e8f0;
	border: 1px solid #cbd5e1;
}

/* Position Selector (Above / Below) */
.mathmedia-pos-tag {
	font-size: 10px;
	text-transform: uppercase;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 3px;
	background: #e0f2fe;
	color: #0369a1;
}

/* Video Inputs */
.mathmedia-video-inputs {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mathmedia-video-preview-box {
	max-width: 320px;
	margin-top: 8px;
	border-radius: 6px;
	overflow: hidden;
}

/* ==========================================================================
   4. Subsection Visual Media Cards & Modal Styles
   ========================================================================== */

.mn-sub-media-container {
	margin-top: 10px;
}

.mn-media-cards-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.mn-media-card {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 10px;
	transition: all 0.2s ease;
}

.mn-media-card:hover {
	border-color: #cbd5e1;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.mn-media-thumb {
	width: 120px;
	min-width: 120px;
	height: 80px;
	border-radius: 6px;
	overflow: hidden;
	background: #e2e8f0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid #cbd5e1;
}

.mn-media-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.mn-media-thumb iframe,
.mn-media-thumb video {
	width: 100%;
	height: 100%;
	border: none;
}

.mn-media-details {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mn-media-row {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.mn-media-type-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	font-weight: 700;
	color: #1e293b;
	background: #e2e8f0;
	padding: 2px 8px;
	border-radius: 4px;
	text-transform: uppercase;
}

.mn-media-align-group {
	display: inline-flex;
	border: 1px solid #cbd5e1;
	border-radius: 4px;
	overflow: hidden;
}

.mn-btn-align {
	background: #ffffff;
	border: none;
	padding: 3px 8px;
	font-size: 11px;
	color: #475569;
	cursor: pointer;
	border-right: 1px solid #e2e8f0;
	transition: all 0.15s ease;
}

.mn-btn-align:last-child {
	border-right: none;
}

.mn-btn-align.is-active,
.mn-btn-align:hover {
	background: #2563eb;
	color: #ffffff;
}

.mn-media-width-group,
.mn-media-pos-group {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	color: #475569;
}

.mn-media-width-select,
.mn-media-pos-select {
	font-size: 12px;
	padding: 2px 6px;
	border: 1px solid #cbd5e1;
	border-radius: 4px;
	background: #ffffff;
}

.mn-media-inputs input {
	width: 100%;
	font-size: 12px;
	padding: 4px 8px;
	border: 1px solid #cbd5e1;
	border-radius: 4px;
}

.mn-btn-remove-media {
	margin-left: auto;
	background: #fee2e2;
	border: 1px solid #fca5a5;
	color: #dc2626;
	border-radius: 4px;
	cursor: pointer;
	padding: 2px 8px;
	font-size: 14px;
	line-height: 1.2;
}

.mn-btn-remove-media:hover {
	background: #dc2626;
	color: #ffffff;
}

/* Video Selection Modal */
.mn-video-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(15, 23, 42, 0.75);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100150;
}

.mn-video-modal-dialog {
	background: #ffffff;
	border-radius: 10px;
	width: 520px;
	max-width: 90vw;
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
	overflow: hidden;
}

.mn-video-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 18px;
	background: #0f172a;
	color: #ffffff;
	font-weight: 700;
	font-size: 14px;
}

.mn-video-modal-tabs {
	display: flex;
	border-bottom: 1px solid #e2e8f0;
	background: #f8fafc;
}

.mn-video-tab-btn {
	flex: 1;
	padding: 10px;
	text-align: center;
	border: none;
	background: none;
	font-weight: 600;
	font-size: 13px;
	color: #64748b;
	cursor: pointer;
	border-bottom: 2px solid transparent;
}

.mn-video-tab-btn.is-active {
	color: #2563eb;
	border-bottom-color: #2563eb;
	background: #ffffff;
}

.mn-video-tab-content {
	padding: 18px;
}

.mn-video-modal-footer {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 18px;
	background: #f1f5f9;
	border-top: 1px solid #e2e8f0;
}

/* ==========================================================================
   Embedded LaTeX Equation Images & Interactive Toolbar
   ========================================================================== */

.mathmedia-latex-segment {
	margin: 8px 0;
}

.mathmedia-embedded-img {
	margin: 14px 0;
	position: relative;
	transition: all 0.2s ease;
}

.mathmedia-embedded-img img.mathmedia-img {
	width: 100%;
	height: auto;
	border-radius: 6px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
	display: block;
}

.mathmedia-embedded-img.mathmedia-img-center {
	margin-left: auto;
	margin-right: auto;
	text-align: center;
	display: block;
	clear: both;
}

.mathmedia-embedded-img.mathmedia-img-left {
	float: left;
	margin: 8px 18px 14px 0;
	max-width: 50%;
	clear: left;
}

.mathmedia-embedded-img.mathmedia-img-right {
	float: right;
	margin: 8px 0 14px 18px;
	max-width: 50%;
	clear: right;
}

.mathmedia-embedded-img.mathmedia-img-full {
	width: 100% !important;
	max-width: 100% !important;
	margin: 16px 0;
	display: block;
	clear: both;
}

.mathmedia-clearfix {
	clear: both;
	height: 0;
	line-height: 0;
}

/* LaTeX Header Inline Image Button */
.mms-btn-add-img-to-eq {
	background: #ffffff;
	border: 1px solid #3b82f6;
	color: #2563eb;
	border-radius: 4px;
	padding: 2px 8px;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	transition: all 0.15s ease;
}

.mms-btn-add-img-to-eq:hover {
	background: #2563eb;
	color: #ffffff;
}

.mms-btn-add-img-to-eq .dashicons {
	font-size: 14px;
	width: 14px;
	height: 14px;
}

/* Editor Interactive Embedded Image Wrapper */
.mms-eq-img-wrap {
	position: relative;
	margin: 14px 0;
	border: 1.5px dashed #cbd5e1;
	border-radius: 8px;
	padding: 6px;
	background: #ffffff;
	transition: all 0.2s ease;
	display: block;
}

.mms-eq-img-wrap:hover,
.mms-eq-img-wrap.is-selected {
	border-color: #2563eb;
	box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.mms-eq-img-inner {
	display: block;
	cursor: pointer;
}

.mms-eq-preview-img {
	width: 100%;
	height: auto;
	border-radius: 6px;
	display: block;
}

.mms-eq-caption-text {
	font-size: 11px;
	color: #64748b;
	text-align: center;
	margin-top: 4px;
	font-style: italic;
}

/* Image Block Toolbar (Above Image) */
.mms-img-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	background: #0f172a;
	color: #ffffff;
	padding: 5px 8px;
	border-radius: 6px;
	margin-bottom: 6px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	font-size: 11px;
}

.mms-tb-group {
	display: inline-flex;
	align-items: center;
	gap: 3px;
}

.mms-tb-btn {
	background: #1e293b;
	border: 1px solid #334155;
	color: #94a3b8;
	border-radius: 4px;
	padding: 3px 6px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	transition: all 0.15s ease;
}

.mms-tb-btn:hover {
	background: #334155;
	color: #ffffff;
}

.mms-tb-btn.is-active {
	background: #2563eb;
	border-color: #3b82f6;
	color: #ffffff;
}

.mms-tb-btn .dashicons {
	font-size: 14px;
	width: 14px;
	height: 14px;
}

.mms-tb-select {
	background: #1e293b;
	border: 1px solid #334155;
	color: #ffffff;
	border-radius: 4px;
	padding: 2px 4px;
	font-size: 11px;
	cursor: pointer;
}

.mms-tb-caption-input {
	background: #1e293b;
	border: 1px solid #334155;
	color: #ffffff;
	border-radius: 4px;
	padding: 2px 6px;
	font-size: 11px;
	width: 130px;
}

.mms-tb-caption-input:focus {
	outline: none;
	border-color: #3b82f6;
}

.mms-tb-del-btn {
	background: #7f1d1d;
	border-color: #991b1b;
	color: #fca5a5;
}

.mms-tb-del-btn:hover {
	background: #ef4444;
	color: #ffffff;
}

.mms-tb-sep {
	width: 1px;
	height: 16px;
	background: #334155;
	margin: 0 2px;
}

.mms-eq-img-wrap {
	position: relative;
	margin: 10px auto;
	border: 1.5px dashed #93c5fd;
	border-radius: 8px;
	padding: 8px;
	background: #f0f7ff;
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mms-eq-img-wrap:hover,
.mms-eq-img-wrap.is-selected {
	border-color: #2563eb;
	background: #ffffff;
	box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

.mms-eq-img-wrap.is-resizing {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
	cursor: se-resize;
}

.mms-eq-img-wrap.align-center {
	margin-left: auto;
	margin-right: auto;
	text-align: center;
}

.mms-eq-img-wrap.align-left {
	margin-right: auto;
	text-align: left;
}

.mms-eq-img-wrap.align-right {
	margin-left: auto;
	text-align: right;
}

.mms-eq-img-wrap.align-full {
	width: 100% !important;
	max-width: 100% !important;
}

/* Corner Resize Handles */
.mms-resize-handle {
	position: absolute;
	width: 14px;
	height: 14px;
	background: #2563eb;
	border: 2.5px solid #ffffff;
	border-radius: 50%;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
	z-index: 100;
	transition: transform 0.1s ease, background 0.15s ease;
}

.mms-resize-handle:hover {
	transform: scale(1.35);
	background: #1d4ed8;
}

.mms-resize-se {
	bottom: -7px;
	right: -7px;
	cursor: se-resize;
}

.mms-resize-sw {
	bottom: -7px;
	left: -7px;
	cursor: sw-resize;
}

/* Floating Resize Percentage Badge */
.mms-resize-badge {
	position: absolute;
	bottom: 12px;
	right: 12px;
	background: rgba(15, 23, 42, 0.9);
	color: #38bdf8;
	padding: 3px 8px;
	border-radius: 4px;
	font-size: 11px;
	font-weight: 700;
	font-family: monospace;
	letter-spacing: 0.5px;
	pointer-events: none;
	display: none;
	z-index: 102;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Single Unified In-Place LaTeX & Image Canvas
   ========================================================================== */
.mms-visual-canvas-wrap {
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #ffffff;
	padding: 10px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.mms-canvas-segments-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mms-canvas-item {
	position: relative;
	width: 100%;
}

.mms-canvas-textarea {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
	padding: 8px 12px;
	font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
	font-size: 13px;
	line-height: 1.55;
	color: #1e293b;
	background: #f8fafc;
	resize: none;
	overflow-y: hidden;
	min-height: 48px;
	transition: all 0.2s ease;
}

.mms-canvas-textarea:focus {
	border-color: #3b82f6;
	background: #ffffff;
	box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
	outline: none;
}

.mms-canvas-footer {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid #f1f5f9;
}

.mms-btn-canvas-add-img {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	color: #1d4ed8;
	padding: 4px 10px;
	border-radius: 5px;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s ease;
}

.mms-btn-canvas-add-img:hover {
	background: #dbeafe;
	border-color: #93c5fd;
	color: #1e40af;
}

.mms-btn-canvas-add-text {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: #f8fafc;
	border: 1px solid #cbd5e1;
	color: #334155;
	padding: 4px 10px;
	border-radius: 5px;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s ease;
}

.mms-btn-canvas-add-text:hover {
	background: #f1f5f9;
	border-color: #94a3b8;
	color: #0f172a;
}

.mms-btn-toggle-view {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: transparent;
	border: 1px solid #e2e8f0;
	color: #64748b;
	padding: 3px 8px;
	border-radius: 4px;
	font-size: 11px;
	cursor: pointer;
	transition: all 0.15s ease;
}

.mms-btn-toggle-view:hover {
	background: #f8fafc;
	color: #1e293b;
	border-color: #cbd5e1;
}

.mms-code-mode-wrap {
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #ffffff;
	padding: 10px;
}

.mms-code-mode-wrap .mms-latex-code-input {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
	padding: 8px 12px;
	font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
	font-size: 13px;
	line-height: 1.5;
	color: #0f172a;
	background: #ffffff;
}

.mms-code-mode-wrap .mms-latex-code-input:focus {
	outline: none;
	border-color: #3b82f6;
	box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
