/**
 * AIEdu File Manager - Frontend Styling
 * Scoped cleanly under .aiedu-fm-* to prevent theme conflicts.
 * Version: 1.1.0
 */

.aiedu-fm-wrap {
	width: 100%;
	margin: 24px 0;
	box-sizing: border-box;
}

.aiedu-fm-wrap *,
.aiedu-fm-wrap *::before,
.aiedu-fm-wrap *::after,
.aiedu-fm-modal *,
.aiedu-fm-modal *::before,
.aiedu-fm-modal *::after {
	box-sizing: inherit;
}

/* Toolbar: Search, Filter, Switcher */
.aiedu-fm-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 20px;
	background: #ffffff;
	padding: 16px;
	border-radius: 10px;
	border: 1px solid #e2e8f0;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.aiedu-fm-search-box {
	position: relative;
	flex: 1;
	min-width: 240px;
}

.aiedu-fm-search-icon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	color: #94a3b8;
	font-size: 15px;
	pointer-events: none;
}

.aiedu-fm-search-input {
	width: 100%;
	padding: 10px 14px 10px 38px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	font-size: 14px;
	color: #1e293b;
	background: #f8fafc;
	transition: all 0.2s ease;
	outline: none;
}

.aiedu-fm-search-input:focus {
	border-color: #2563eb;
	background: #ffffff;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.aiedu-fm-folder-filter select {
	padding: 10px 14px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	font-size: 14px;
	color: #1e293b;
	background: #f8fafc;
	cursor: pointer;
	outline: none;
	transition: all 0.2s ease;
}

.aiedu-fm-folder-filter select:focus {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.aiedu-fm-view-switcher {
	display: flex;
	gap: 4px;
	background: #f1f5f9;
	padding: 3px;
	border-radius: 8px;
}

.aiedu-fm-switch-btn {
	background: transparent;
	border: none;
	padding: 6px 10px;
	border-radius: 6px;
	cursor: pointer;
	color: #64748b;
	font-size: 16px;
	line-height: 1;
	transition: all 0.15s ease;
}

.aiedu-fm-switch-btn:hover {
	color: #1e293b;
}

.aiedu-fm-switch-btn.active {
	background: #ffffff;
	color: #2563eb;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Badges */
.aiedu-fm-badge-folder {
	display: inline-block;
	background: #eff6ff;
	color: #1d4ed8;
	border: 1px solid #dbeafe;
	font-size: 12px;
	font-weight: 500;
	padding: 3px 8px;
	border-radius: 6px;
}

.aiedu-fm-badge-count {
	display: inline-block;
	background: #f1f5f9;
	color: #475569;
	font-size: 12px;
	font-weight: 500;
	padding: 3px 8px;
	border-radius: 6px;
}

.aiedu-fm-lock-tag {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	background: #fffbeb;
	color: #b45309;
	border: 1px solid #fef3c7;
	font-size: 11px;
	font-weight: 600;
	padding: 2px 6px;
	border-radius: 4px;
	margin-left: 6px;
}

/* Tooltip info button */
.aiedu-fm-tooltip {
	display: inline-block;
	color: #94a3b8;
	cursor: help;
	margin-left: 6px;
	font-size: 13px;
	vertical-align: middle;
}

/* Buttons */
.aiedu-fm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 7px 14px;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none !important;
	cursor: pointer;
	transition: all 0.2s ease;
	border: 1px solid transparent;
	line-height: 1.3;
}

.aiedu-fm-btn-preview {
	background: #f8fafc;
	border-color: #cbd5e1;
	color: #334155;
}

.aiedu-fm-btn-preview:hover {
	background: #e2e8f0;
	color: #0f172a;
}

.aiedu-fm-btn-download {
	background: #2563eb;
	color: #ffffff !important;
}

.aiedu-fm-btn-download:hover {
	background: #1d4ed8;
	color: #ffffff !important;
	box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.aiedu-fm-btn-secondary {
	background: #e2e8f0;
	color: #334155;
}

.aiedu-fm-btn-secondary:hover {
	background: #cbd5e1;
}

/* Table View */
.aiedu-fm-table-responsive {
	overflow-x: auto;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.aiedu-fm-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
	text-align: left;
}

.aiedu-fm-table th {
	background: #f8fafc;
	color: #475569;
	font-weight: 600;
	padding: 14px 18px;
	border-bottom: 1px solid #e2e8f0;
	text-transform: uppercase;
	font-size: 12px;
	letter-spacing: 0.5px;
}

.aiedu-fm-table td {
	padding: 14px 18px;
	border-bottom: 1px solid #f1f5f9;
	vertical-align: middle;
	color: #334155;
}

.aiedu-fm-table tr:last-child td {
	border-bottom: none;
}

.aiedu-fm-table tr:hover td {
	background: #fcfdfe;
}

.aiedu-fm-title-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
}

.aiedu-fm-icon-wrap svg {
	width: 26px;
	height: 26px;
	display: block;
}

.aiedu-fm-doc-title {
	font-size: 14px;
	font-weight: 600;
	color: #0f172a;
}

.aiedu-fm-col-action {
	text-align: right;
	white-space: nowrap;
}

.aiedu-fm-col-action .aiedu-fm-btn {
	margin-left: 6px;
}

.aiedu-fm-no-data {
	text-align: center;
	padding: 36px 20px;
	color: #64748b;
	font-size: 14px;
}

/* Grid Card View */
.aiedu-fm-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 18px;
}

.aiedu-fm-card {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	padding: 18px;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aiedu-fm-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.06);
	border-color: #cbd5e1;
}

.aiedu-fm-card-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	margin-bottom: 12px;
}

.aiedu-fm-card-icon svg {
	width: 36px;
	height: 36px;
	display: block;
}

.aiedu-fm-card-body {
	flex: 1;
}

.aiedu-fm-card-title {
	margin: 0 0 8px;
	font-size: 15px;
	font-weight: 600;
	color: #0f172a;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.aiedu-fm-card-desc {
	margin: 0 0 12px;
	font-size: 13px;
	color: #64748b;
	line-height: 1.5;
}

.aiedu-fm-card-meta {
	display: flex;
	align-items: center;
	gap: 14px;
	font-size: 12px;
	color: #64748b;
	margin-top: 10px;
}

.aiedu-fm-card-footer {
	display: flex;
	gap: 8px;
	margin-top: 16px;
	padding-top: 14px;
	border-top: 1px solid #f1f5f9;
}

.aiedu-fm-card-footer .aiedu-fm-btn {
	flex: 1;
}

/* Frontend Pagination */
.aiedu-fm-pagination {
	margin-top: 24px;
	display: flex;
	justify-content: center;
}

.aiedu-fm-pagination-numbers {
	display: flex;
	gap: 6px;
}

.aiedu-fm-page-btn {
	background: #ffffff;
	border: 1px solid #cbd5e1;
	color: #334155;
	padding: 6px 12px;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.15s ease;
}

.aiedu-fm-page-btn:hover {
	background: #f1f5f9;
}

.aiedu-fm-page-btn.active {
	background: #2563eb;
	color: #ffffff;
	border-color: #2563eb;
}

/* Modal Popup */
.aiedu-fm-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.aiedu-fm-modal-backdrop {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(15, 23, 42, 0.65);
	backdrop-filter: blur(4px);
}

.aiedu-fm-modal-box {
	position: relative;
	background: #ffffff;
	border-radius: 12px;
	max-width: 800px;
	width: 92%;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
	overflow: hidden;
	z-index: 2;
	animation: aieduModalZoom 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes aieduModalZoom {
	from {
		opacity: 0;
		transform: scale(0.95);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

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

.aiedu-fm-modal-title-wrap {
	display: flex;
	align-items: center;
	gap: 10px;
}

.aiedu-fm-modal-title-wrap h3 {
	margin: 0;
	font-size: 17px;
	color: #0f172a;
	font-weight: 600;
}

.aiedu-fm-modal-close-btn {
	background: transparent;
	border: none;
	font-size: 24px;
	color: #64748b;
	cursor: pointer;
	line-height: 1;
	padding: 4px;
	border-radius: 4px;
}

.aiedu-fm-modal-close-btn:hover {
	color: #0f172a;
}

.aiedu-fm-modal-body {
	padding: 24px;
	overflow-y: auto;
	flex: 1;
	max-height: 70vh;
}

.aiedu-fm-modal-footer {
	padding: 14px 24px;
	border-top: 1px solid #e2e8f0;
	background: #f8fafc;
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

/* Modal Content Types */
.aiedu-preview-iframe {
	width: 100%;
	height: 550px;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	background: #f8fafc;
}

.aiedu-preview-img-wrap {
	text-align: center;
}

.aiedu-preview-img-wrap img {
	max-width: 100%;
	max-height: 500px;
	border-radius: 6px;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.aiedu-preview-meta-card {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 24px;
	text-align: center;
}

.aiedu-preview-big-icon {
	margin-bottom: 16px;
}

.aiedu-preview-big-icon svg {
	width: 56px;
	height: 56px;
}

.aiedu-preview-meta-details {
	margin-top: 18px;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: 12px;
	text-align: left;
	background: #ffffff;
	padding: 14px;
	border-radius: 6px;
	border: 1px solid #e2e8f0;
}

.aiedu-preview-meta-item {
	font-size: 13px;
	color: #64748b;
}

.aiedu-preview-meta-item strong {
	color: #1e293b;
}

/* Responsive adjustments */
@media (max-width: 768px) {
	.aiedu-fm-toolbar {
		flex-direction: column;
		align-items: stretch;
	}
	.aiedu-fm-folder-filter select {
		width: 100%;
	}
	.aiedu-fm-col-size,
	.aiedu-fm-col-count {
		display: none;
	}
}

/* Single Document Embed Card ([aiedu_file]) */
.aiedu-fm-single-embed {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 16px 20px;
	margin: 20px 0;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-left: 4px solid #2563eb;
	border-radius: 10px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.aiedu-fm-single-embed:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.aiedu-fm-single-icon {
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.aiedu-fm-single-icon svg {
	width: 100%;
	height: 100%;
}

.aiedu-fm-single-details {
	flex: 1;
	min-width: 0;
}

.aiedu-fm-single-title {
	margin: 0 0 4px 0;
	font-size: 16px;
	font-weight: 600;
	color: #0f172a;
	line-height: 1.3;
}

.aiedu-fm-single-desc {
	margin: 0 0 6px 0;
	font-size: 13px;
	color: #475569;
	line-height: 1.4;
}

.aiedu-fm-single-meta {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 12px;
	color: #64748b;
	flex-wrap: wrap;
}

.aiedu-fm-single-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.aiedu-fm-single-error {
	padding: 12px 16px;
	margin: 15px 0;
	background: #fff5f5;
	border: 1px solid #fecaca;
	border-radius: 6px;
	color: #dc2626;
	font-size: 14px;
}

@media (max-width: 600px) {
	.aiedu-fm-single-embed {
		flex-direction: column;
		align-items: flex-start;
	}
	.aiedu-fm-single-actions {
		width: 100%;
		margin-top: 10px;
	}
	.aiedu-fm-single-actions .aiedu-fm-btn {
		flex: 1;
		text-align: center;
	}
}

