/* ===== Image Cropper ===== */
.ic-overlay {
  position: fixed; inset: 0; z-index: 2000000;
  background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center;
  animation: ic-fadeIn .2s ease;
}
@keyframes ic-fadeIn { from { opacity: 0 } to { opacity: 1 } }
.ic-container {
  background: var(--bg-secondary, #1a1a2e); border-radius: 16px;
  width: 90vw; max-width: 900px; height: 85vh; max-height: 700px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.ic-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ic-title { margin: 0; font-size: 16px; color: var(--text, #fff); }
.ic-close {
  background: none; border: none; color: var(--text-muted, #888); font-size: 24px; cursor: pointer;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; transition: .15s;
}
.ic-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.ic-toolbar {
  display: flex; align-items: center; gap: 6px; padding: 10px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ic-ratio-btn, .ic-zoom-btn {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted, #aaa); padding: 6px 14px; border-radius: 8px;
  font-size: 13px; cursor: pointer; transition: .15s;
}
.ic-ratio-btn.active, .ic-ratio-btn:hover { background: var(--accent, #6c5ce7); color: #fff; border-color: transparent; }
.ic-zoom-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.ic-spacer { flex: 1; }
.ic-canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: auto; padding: 10px; background: rgba(0,0,0,0.3);
}
#ic-canvas { border-radius: 4px; max-width: 100%; }
.ic-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08);
}
.ic-btn {
  padding: 10px 24px; border-radius: 10px; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: .15s;
}
.ic-btn-cancel { background: rgba(255,255,255,0.06); color: var(--text-muted, #aaa); }
.ic-btn-cancel:hover { background: rgba(255,255,255,0.12); }
.ic-btn-confirm { background: var(--accent, #6c5ce7); color: #fff; }
.ic-btn-confirm:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ===== Lesson Visual Editor (drag-resize) ===== */
.lve-overlay {
  position: fixed; inset: 0; z-index: 1999999;
  background: rgba(0,0,0,0.9); display: flex; flex-direction: column;
  animation: ic-fadeIn .2s ease;
}
.lve-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  background: var(--bg-secondary, #1a1a2e); border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.lve-toolbar-title { font-size: 15px; font-weight: 600; color: var(--text, #fff); margin-right: auto; }
.lve-add-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 16px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: var(--text, #fff); border-radius: 10px; font-size: 13px; cursor: pointer; transition: .15s;
}
.lve-add-btn:hover { background: var(--accent, #6c5ce7); border-color: transparent; }
.lve-close-btn {
  background: var(--accent, #6c5ce7); color: #fff; border: none;
  padding: 8px 20px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.lve-canvas-area {
  flex: 1; overflow: auto; display: flex; justify-content: center; padding: 20px;
}
.lve-canvas {
  width: 900px; min-height: 600px; background: var(--bg-card, #1e1e36);
  border-radius: 12px; position: relative; border: 1px solid rgba(255,255,255,0.06);
}
.lve-element {
  position: absolute; border: 2px solid transparent; border-radius: 8px;
  cursor: move; transition: border-color .15s;
  min-width: 60px; min-height: 60px;
}
.lve-element:hover, .lve-element.selected { border-color: var(--accent, #6c5ce7); }
.lve-element.selected { box-shadow: 0 0 0 3px rgba(108,92,231,0.3); }

/* Element inner content */
.lve-element img, .lve-element video {
  width: 100%; height: 100%; object-fit: cover; border-radius: 6px;
  pointer-events: none;
}
.lve-element .lve-text-content {
  padding: 12px; color: var(--text, #fff); font-size: 14px; line-height: 1.5;
  outline: none; min-height: 40px; width: 100%; height: 100%;
}
.lve-element .lve-pdf-block {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 20px; background: rgba(255,255,255,0.04); border-radius: 6px;
  height: 100%; color: var(--text-muted, #aaa); font-size: 13px; text-align: center;
}
.lve-element .lve-pdf-block .lve-pdf-icon { font-size: 36px; }
.lve-element .lve-pdf-block .lve-pdf-name { font-weight: 600; color: var(--text, #fff); }
.lve-element .lve-pdf-block .lve-pdf-dl {
  background: var(--accent, #6c5ce7); color: #fff; padding: 6px 16px;
  border-radius: 8px; text-decoration: none; font-size: 12px; font-weight: 600;
}

/* Resize handles */
.lve-handle {
  position: absolute; width: 12px; height: 12px; background: #fff;
  border: 2px solid var(--accent, #6c5ce7); border-radius: 3px;
  z-index: 10; display: none;
}
.lve-element.selected .lve-handle { display: block; }
.lve-handle-tl { top: -6px; left: -6px; cursor: nw-resize; }
.lve-handle-tr { top: -6px; right: -6px; cursor: ne-resize; }
.lve-handle-bl { bottom: -6px; left: -6px; cursor: sw-resize; }
.lve-handle-br { bottom: -6px; right: -6px; cursor: se-resize; }
.lve-handle-t { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.lve-handle-b { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.lve-handle-l { left: -6px; top: 50%; transform: translateY(-50%); cursor: w-resize; }
.lve-handle-r { right: -6px; top: 50%; transform: translateY(-50%); cursor: e-resize; }

/* Element action bar */
.lve-actions {
  position: absolute; top: -36px; right: 0;
  display: none; gap: 4px; background: var(--bg-secondary, #1a1a2e);
  border-radius: 8px; padding: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.lve-element.selected .lve-actions { display: flex; }
.lve-action-btn {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-muted, #aaa); cursor: pointer;
  border-radius: 6px; font-size: 14px; transition: .15s;
}
.lve-action-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.lve-action-btn.danger:hover { background: rgba(239,68,68,0.2); color: #ef4444; }

/* Add element menu */
.lve-add-menu {
  position: absolute; top: 48px; left: 20px; z-index: 100;
  background: var(--bg-secondary, #1a1a2e); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 8px; min-width: 200px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); display: none;
}
.lve-add-menu.open { display: block; }
.lve-add-menu-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: 8px; cursor: pointer; color: var(--text, #fff); font-size: 13px;
  transition: .15s; border: none; background: none; width: 100%; text-align: left;
}
.lve-add-menu-item:hover { background: rgba(255,255,255,0.08); }
.lve-add-menu-item .lve-ami-icon { font-size: 18px; width: 28px; text-align: center; }

/* Wizard crop button enhancement */
.aw-cover-actions {
  display: flex; gap: 8px; margin-top: 8px; justify-content: center;
}
.aw-crop-btn {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-muted, #aaa); padding: 6px 14px; border-radius: 8px;
  font-size: 12px; cursor: pointer; transition: .15s; display: flex; align-items: center; gap: 4px;
}
.aw-crop-btn:hover { background: var(--accent, #6c5ce7); color: #fff; border-color: transparent; }
.aw-cover-preview { max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: cover; }

/* Formation editor thumbnail crop */
.fe-thumb-crop {
  position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.7);
  color: #fff; border: none; padding: 4px 10px; border-radius: 6px;
  font-size: 11px; cursor: pointer; opacity: 0; transition: .15s;
}
.fe-thumb-wrap:hover .fe-thumb-crop { opacity: 1; }

@media (max-width: 768px) {
  .ic-container { width: 98vw; height: 90vh; border-radius: 12px; }
  .lve-canvas { width: 100%; min-width: unset; }
}

/* ===== Formation Editor Tabs — Premium ===== */
.fce-tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.fce-tabs::-webkit-scrollbar { display: none; }

.fce-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted, #8b8ba3);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.fce-tab:hover {
  color: var(--text, #fff);
  background: rgba(255,255,255,0.06);
}
.fce-tab--active {
  color: #fff !important;
  background: linear-gradient(135deg, var(--accent, #6c5ce7), color-mix(in srgb, var(--accent, #6c5ce7) 70%, #a78bfa)) !important;
  box-shadow:
    0 2px 8px rgba(108,92,231,0.35),
    0 0 0 1px rgba(108,92,231,0.15),
    inset 0 1px 0 rgba(255,255,255,0.12);
  font-weight: 600;
}
.fce-tab--active:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow:
    0 4px 16px rgba(108,92,231,0.4),
    0 0 0 1px rgba(108,92,231,0.2),
    inset 0 1px 0 rgba(255,255,255,0.15);
}

@media (max-width: 640px) {
  .fce-tabs { gap: 4px; padding: 4px; }
  .fce-tab { padding: 8px 14px; font-size: 12.5px; }
}

/* ===== Formation Card — kill hover overlay (removed from HTML, override bundle remnants) ===== */
.fcard-hover-actions,
.fcard-overlay {
  display: none !important;
}

/* ===== Formation Card — uniform height ===== */
.formation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.formation-card.fcard {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.fcard-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.formation-card-desc {
  max-height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
}
.fcard-footer {
  margin-top: auto;
}

/* ===== Formation Card Thumbnail — cover fix ===== */
.fcard-thumb {
  position: relative;
  height: 170px;
  width: 100%;
  overflow: hidden;
}
.fcard-thumb-image {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center;
}

/* ===== Theme Picker Enhancements (sidebar) ===== */
.fce-theme-picker {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0;
}
.fce-theme-swatch {
  width: 32px !important; height: 32px !important; border-radius: 10px !important;
  border: 3px solid transparent !important; cursor: pointer;
  transition: all .2s !important; position: relative;
}
.fce-theme-swatch:hover {
  transform: scale(1.2) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}
.fce-theme-swatch--active {
  border-color: #fff !important;
  box-shadow: 0 0 0 3px rgba(167,139,250,0.5), 0 4px 12px rgba(0,0,0,0.3) !important;
  transform: scale(1.15) !important;
}
.fce-theme-swatch--active::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: bold;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
/* Theme preview box */
#fce-theme-preview {
  border-radius: 10px !important;
}
