/**
 * MasterStudy HTML Lesson — Premium Course Builder & Advanced Code Editor Styles
 */

/* ------------------------------------------------------------------ */
/*  Main Section Container                                             */
/* ------------------------------------------------------------------ */

.ms-html-upload-section {
	margin: 24px 0;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.025);
	padding: 20px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	transition: all 0.3s ease;
	max-width: 100%;
	box-sizing: border-box;
}

/* ------------------------------------------------------------------ */
/*  Toolbar Header & Actions                                           */
/* ------------------------------------------------------------------ */

.ms-html-editor-toolbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-bottom: 16px;
	margin-bottom: 16px;
	border-bottom: 1px solid #f1f5f9;
	flex-wrap: wrap;
	gap: 12px;
}

.ms-html-editor-title {
	font-size: 15px;
	font-weight: 700;
	color: #0f172a;
	display: flex;
	align-items: center;
	gap: 8px;
	letter-spacing: -0.01em;
}

.ms-html-toolbar-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

/* Styled Select Dropdown */
.ms-html-toolbar-select {
	padding: 8px 12px;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	background: #ffffff;
	color: #334155;
	font-size: 12.5px;
	font-weight: 600;
	outline: none;
	cursor: pointer;
	transition: all 0.2s ease;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.ms-html-toolbar-select:focus {
	border-color: #6366f1;
	box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* Toolbar Buttons */
.ms-html-toolbar-btn {
	background: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	color: #475569;
	padding: 8px 14px;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.ms-html-toolbar-btn:hover {
	color: #0f172a;
	background: #f8fafc;
	border-color: #94a3b8;
}

.ms-html-toolbar-btn.active {
	background: #eeeffe;
	border-color: #818cf8;
	color: #4f46e5;
}

.ms-html-upload-label {
	font-size: 12px;
	font-weight: 700;
	color: #64748b;
	margin-bottom: 8px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

/* ------------------------------------------------------------------ */
/*  Split Screen & Single Layouts                                      */
/* ------------------------------------------------------------------ */

.ms-html-editor-split-container {
	display: flex;
	gap: 20px;
	align-items: stretch;
}

.ms-html-editor-pane-code {
	flex: 1.1;
	min-width: 0;
}

.ms-html-editor-pane-preview {
	flex: 0.9;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

/* ------------------------------------------------------------------ */
/*  Tabs Navigation                                                    */
/* ------------------------------------------------------------------ */

.ms-html-tabs {
	display: flex;
	background: #f1f5f9;
	border-radius: 8px;
	padding: 4px;
	margin-bottom: 16px;
	gap: 4px;
	border-bottom: none;
}

.ms-html-tab-btn {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	background: transparent;
	border: none;
	border-bottom: none;
	border-radius: 6px;
	padding: 8px 12px;
	font-size: 13px;
	font-weight: 600;
	color: #64748b;
	cursor: pointer;
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	outline: none;
}

.ms-html-tab-btn:hover {
	color: #0f172a;
	background: rgba(255, 255, 255, 0.5);
}

.ms-html-tab-btn.active {
	color: #6366f1;
	background: #ffffff;
	box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
}

.ms-html-tab-icon {
	font-size: 13px;
	opacity: 0.9;
}

/* ------------------------------------------------------------------ */
/*  Code Fields & Textareas                                             */
/* ------------------------------------------------------------------ */

.ms-html-tab-content {
	display: flex;
	flex-direction: column;
	gap: 16px;
	animation: ms-html-fadeIn 0.25s ease;
}

.ms-html-code-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

/* Custom dark theme styling for CodeMirror & Textareas */
.ms-html-code-textarea,
.ms-html-upload-section .CodeMirror {
	width: 100%;
	height: 380px !important; /* increased height to fit layouts better */
	min-height: 280px;
	font-family: 'Fira Code', Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
	font-size: 13px;
	line-height: 1.6;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #1e1e1e !important;
	color: #d4d4d4 !important;
	resize: vertical;
	outline: none;
	transition: all 0.2s ease;
	box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

.ms-html-code-textarea:focus,
.ms-html-upload-section .CodeMirror-focused {
	border-color: #6366f1 !important;
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), inset 0 2px 4px 0 rgba(0, 0, 0, 0.06) !important;
}

/* ------------------------------------------------------------------ */
/*  CodeMirror Inner Custom Theme                                     */
/* ------------------------------------------------------------------ */

.ms-html-upload-section .CodeMirror-gutters {
	background: #181818 !important;
	border-right: 1px solid #2d2d2d !important;
	border-radius: 7px 0 0 7px;
}

.ms-html-upload-section .CodeMirror-linenumber {
	color: #7c7c7c !important;
	font-family: inherit;
	font-size: 11px;
	padding-right: 10px;
}

.ms-html-upload-section .CodeMirror-cursor {
	border-left: 2px solid #818cf8 !important;
}

/* Syntax Highlighting Colors */
.ms-html-upload-section .cm-tag { color: #818cf8 !important; }
.ms-html-upload-section .cm-attribute { color: #34d399 !important; }
.ms-html-upload-section .cm-string { color: #fb7185 !important; }
.ms-html-upload-section .cm-comment { color: #64748b !important; font-style: italic; }
.ms-html-upload-section .cm-keyword { color: #fb7185 !important; }
.ms-html-upload-section .cm-number { color: #f59e0b !important; }
.ms-html-upload-section .cm-property { color: #38bdf8 !important; }
.ms-html-upload-section .cm-variable { color: #f8fafc !important; }
.ms-html-upload-section .cm-variable-2 { color: #38bdf8 !important; }
.ms-html-upload-section .cm-def { color: #f43f5e !important; }
.ms-html-upload-section .cm-atom { color: #818cf8 !important; }
.ms-html-upload-section .cm-operator { color: #cbd5e1 !important; }
.ms-html-upload-section .cm-meta { color: #38bdf8 !important; }
.ms-html-upload-section .cm-qualifier { color: #f43f5e !important; }
.ms-html-upload-section .cm-builtin { color: #fb7185 !important; }

/* ------------------------------------------------------------------ */
/*  Live Preview Container                                            */
/* ------------------------------------------------------------------ */

.ms-html-preview-container {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.ms-html-preview-frame-wrapper {
	flex: 1;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #ffffff;
	overflow: hidden;
	height: 380px;
	box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
	position: relative;
}

#ms-html-preview-iframe {
	width: 100%;
	height: 100%;
	display: block;
	background: #ffffff;
}

/* ------------------------------------------------------------------ */
/*  Asset / Image Helper Styling                                       */
/* ------------------------------------------------------------------ */

.ms-html-image-helper {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ms-html-media-selector-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin-top: 8px;
}

.ms-html-media-library-btn {
	background: #ffffff;
	border: 2px dashed #cbd5e1;
	border-radius: 8px;
	padding: 48px 20px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	color: #64748b;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.25s ease;
	text-align: center;
	gap: 8px;
}

.ms-html-media-library-btn:hover {
	border-color: #6366f1;
	color: #4f46e5;
	background: #f5f3ff;
}

.ms-html-image-insert-btn {
	background: #10b981;
	border: none;
	border-radius: 6px;
	color: #ffffff;
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.ms-html-image-insert-btn:hover {
	background: #059669;
	box-shadow: 0 4px 12px -2px rgba(16, 185, 129, 0.3);
}

.ms-html-image-upload-zone {
	border: 2px dashed #cbd5e1;
	border-radius: 8px;
	padding: 48px 20px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	color: #64748b;
	background: #f8fafc;
	transition: all 0.25s ease;
	cursor: pointer;
	text-align: center;
	gap: 8px;
}

.ms-html-image-upload-zone span {
	font-size: 13px;
	font-weight: 500;
	color: #64748b;
}

.ms-html-image-upload-zone:hover,
.ms-html-image-upload-zone.dragover {
	border-color: #6366f1;
	color: #4f46e5;
	background: #f5f3ff;
}

.ms-html-image-upload-zone:hover span {
	color: #4f46e5;
}

.ms-html-image-url-box {
	display: flex;
	gap: 10px;
	align-items: center;
	background: #f5f3ff;
	border: 1px solid #ddd6fe;
	border-radius: 8px;
	padding: 14px;
	animation: ms-html-fadeIn 0.3s ease;
}

.ms-html-image-url-input {
	flex: 1;
	font-family: inherit;
	font-size: 13px;
	padding: 8px 12px;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	background: #ffffff;
	color: #334155;
	outline: none;
	transition: all 0.2s ease;
}

.ms-html-image-url-input:focus {
	border-color: #6366f1;
	box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.ms-html-image-copy-btn {
	background: #6366f1;
	border: none;
	border-radius: 6px;
	color: #ffffff;
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.ms-html-image-copy-btn:hover {
	background: #4f46e5;
	box-shadow: 0 4px 12px -2px rgba(99, 102, 241, 0.3);
}

.ms-html-image-clear-btn {
	background: none;
	border: none;
	color: #94a3b8;
	font-size: 24px;
	font-weight: 300;
	cursor: pointer;
	padding: 0 6px;
	line-height: 1;
	transition: color 0.2s ease;
}

.ms-html-image-clear-btn:hover {
	color: #ef4444;
}

/* ------------------------------------------------------------------ */
/*  Animations & Spinners                                              */
/* ------------------------------------------------------------------ */

.ms-html-upload-spinner {
	width: 28px;
	height: 28px;
	border: 3px solid #e2e8f0;
	border-top-color: #6366f1;
	border-radius: 50%;
	animation: ms-html-spin 0.8s linear infinite;
	margin-bottom: 8px;
}

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

@keyframes ms-html-fadeIn {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------ */
/*  Frontend: Student View (unchanged spacing)                         */
/* ------------------------------------------------------------------ */

.masterstudy-html-lesson-container {
	width: 100%;
	margin-bottom: 24px;
	border-radius: 12px;
	overflow: hidden;
	border: 1px solid #e2e8f0;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.025);
}

.masterstudy-html-lesson-container iframe {
	display: block;
	width: 100%;
	min-height: 150px;
	border: none;
	border-radius: 0;
	background: #ffffff;
}

/* ------------------------------------------------------------------ */
/*  Preview Modal Styling                                              */
/* ------------------------------------------------------------------ */

.ms-html-preview-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(15, 23, 42, 0.6);
	backdrop-filter: blur(8px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999999;
	animation: ms-html-modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ms-html-preview-modal-content {
	background: #ffffff;
	border-radius: 16px;
	width: 90%;
	max-width: 1000px;
	height: 85%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
	animation: ms-html-modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ms-html-preview-modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 24px;
	background: #f8fafc;
	border-bottom: 1px solid #e2e8f0;
}

.ms-html-preview-modal-title {
	font-size: 16px;
	font-weight: 700;
	color: #0f172a;
	display: flex;
	align-items: center;
	gap: 10px;
}

.ms-html-preview-modal-actions {
	display: flex;
	align-items: center;
	gap: 14px;
}

.ms-html-preview-modal-btn {
	background: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	color: #475569;
	padding: 6px 12px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
}

.ms-html-preview-modal-btn:hover {
	color: #0f172a;
	background: #f1f5f9;
	border-color: #94a3b8;
}

.ms-html-preview-modal-close {
	background: none;
	border: none;
	color: #64748b;
	font-size: 28px;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.2s ease;
}

.ms-html-preview-modal-close:hover {
	color: #ef4444;
}

.ms-html-preview-modal-body {
	flex: 1;
	background: #ffffff;
	position: relative;
}

.ms-html-preview-modal-body iframe {
	width: 100%;
	height: 100%;
	border: none;
	background: #ffffff;
	display: block;
}

@keyframes ms-html-modalFadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes ms-html-modalSlideUp {
	from { transform: translateY(20px) scale(0.95); opacity: 0; }
	to { transform: translateY(0) scale(1); opacity: 1; }
}

