/* v6.10.138 - Công cụ sửa ảnh & nâng cấp chất lượng cho form đăng bài
 * Tích hợp ngay trong modal "Đăng video hoặc ảnh": sau khi chọn ảnh, người dùng có thể
 * chỉnh sửa, làm nét/màu sắc siêu đẹp trước khi đăng.
 */

/* Nút sửa ảnh trên mỗi ảnh trong thư viện (gallery preview) */
.fv-gallery-preview{position:relative}
.fv-gallery-preview .fv-gallery-item{
  position:relative;display:inline-block;margin:6px 6px 0 0;border-radius:10px;overflow:hidden;
  box-shadow:0 2px 8px rgba(0,0,0,.35);line-height:0;
}
.fv-gallery-preview .fv-gallery-item img{display:block;width:74px;height:74px;object-fit:cover;background:#111}
.fv-gallery-preview .fv-gallery-item.is-enhanced::after{
  content:"";position:absolute;top:4px;left:4px;width:14px;height:14px;border-radius:50%;
  background:linear-gradient(135deg,#ffcf33,#ff2d55);box-shadow:0 0 0 2px rgba(0,0,0,.5);
}
.fv-gallery-edit-btn{
  position:absolute;right:3px;bottom:3px;width:26px;height:26px;padding:0;border:0;border-radius:50%;
  background:rgba(15,15,20,.82);color:#fff;cursor:pointer;display:grid;place-items:center;
  backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);box-shadow:0 1px 4px rgba(0,0,0,.4);
  transition:transform .15s ease,background .15s ease;touch-action:manipulation;z-index:5;
}
.fv-gallery-edit-btn:hover{transform:scale(1.12);background:linear-gradient(135deg,#ffcf33,#ff2d55)}
.fv-gallery-edit-btn svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* Thanh công cụ sửa ảnh ngay trong form (hiện khi chọn ảnh) */
.fv-enhance-bar{
  display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:10px 0 4px;padding:10px 12px;
  border:1px solid rgba(255,207,51,.28);border-radius:14px;
  background:linear-gradient(135deg,rgba(255,207,51,.1),rgba(255,45,85,.08));
}
.fv-enhance-bar[hidden]{display:none!important}
.fv-enhance-bar .fv-enhance-label{font-size:12px;font-weight:800;color:#ffd766;flex:1 1 100%;display:flex;align-items:center;gap:6px}
.fv-enhance-bar .fv-enhance-label svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.fv-enhance-bar button{
  flex:1 1 auto;min-height:38px;padding:8px 10px;border:1px solid rgba(255,255,255,.18);border-radius:10px;
  background:rgba(255,255,255,.08);color:#fff;font:inherit;font-size:12.5px;font-weight:800;cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;gap:6px;touch-action:manipulation;
  transition:transform .15s ease,background .15s ease,border-color .15s ease;
}
.fv-enhance-bar button svg{width:15px;height:15px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.fv-enhance-bar button:hover{transform:translateY(-1px);background:rgba(255,255,255,.16)}
.fv-enhance-bar button.fv-enhance-ai{
  border-color:transparent;background:linear-gradient(135deg,#ffcf33,#ff9f1a 55%,#ff2d55);
  color:#1a1206;box-shadow:0 4px 14px rgba(255,159,26,.35);
}
.fv-enhance-bar button.fv-enhance-ai:hover{box-shadow:0 6px 20px rgba(255,159,26,.5)}

/* ===== Modal sửa ảnh (đè lên mọi thứ, kể cả fv-modal) ===== */
.fv-enhancer-modal{
  position:fixed;inset:0;z-index:99999;display:flex;align-items:center;justify-content:center;
  padding:12px;box-sizing:border-box;background:rgba(5,5,10,.82);backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);animation:fvEnhFade .18s ease;
}
.fv-enhancer-modal[hidden]{display:none!important}
@keyframes fvEnhFade{from{opacity:0}to{opacity:1}}
.fv-enhancer-panel{
  position:relative;width:min(980px,100%);max-height:96vh;display:flex;flex-direction:column;
  background:#141419;border:1px solid rgba(255,255,255,.12);border-radius:18px;overflow:hidden;
  box-shadow:0 30px 80px rgba(0,0,0,.6);animation:fvEnhPop .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes fvEnhPop{from{transform:scale(.94) translateY(10px);opacity:0}to{transform:none;opacity:1}}
.fv-enhancer-head{
  display:flex;align-items:center;gap:10px;padding:12px 14px;border-bottom:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg,rgba(255,255,255,.04),transparent);
}
.fv-enhancer-head strong{font-size:15px;flex:1;display:flex;align-items:center;gap:8px;min-width:0}
.fv-enhancer-head strong .fv-enhancer-spark{
  width:24px;height:24px;border-radius:8px;flex:none;display:grid;place-items:center;
  background:linear-gradient(135deg,#ffcf33,#ff2d55);color:#1a1206;
}
.fv-enhancer-head strong .fv-enhancer-spark svg{width:14px;height:14px;fill:currentColor}
.fv-enhancer-head small{font-size:11px;font-weight:600;opacity:.55;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fv-enhancer-close{
  width:34px;height:34px;flex:none;border:0;border-radius:10px;background:rgba(255,255,255,.08);
  color:#fff;font-size:20px;line-height:1;cursor:pointer;display:grid;place-items:center;
}
.fv-enhancer-close:hover{background:rgba(255,77,109,.3)}

.fv-enhancer-body{display:flex;flex:1;min-height:0;overflow:hidden}
.fv-enhancer-canvas-wrap{
  flex:1;min-width:0;display:flex;align-items:center;justify-content:center;padding:16px;
  background:
    linear-gradient(45deg,#1c1c22 25%,transparent 25%,transparent 75%,#1c1c22 75%),
    linear-gradient(45deg,#1c1c22 25%,#23232b 25%,#23232b 75%,#1c1c22 75%);
  background-size:24px 24px;background-position:0 0,12px 12px;position:relative;overflow:auto;
}
.fv-enhancer-canvas-wrap canvas{
  max-width:100%;max-height:62vh;width:auto;height:auto;display:block;border-radius:10px;
  box-shadow:0 10px 40px rgba(0,0,0,.55);background:transparent;
}
.fv-enhancer-canvas-wrap .fv-enhancer-loading{
  position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:12px;background:rgba(10,10,14,.72);backdrop-filter:blur(3px);color:#fff;font-size:13px;font-weight:700;z-index:5;
}
.fv-enhancer-canvas-wrap .fv-enhancer-loading[hidden]{display:none}
.fv-enhancer-spinner{
  width:42px;height:42px;border-radius:50%;border:3px solid rgba(255,255,255,.15);
  border-top-color:#ffcf33;animation:fvEnhSpin .8s linear infinite;
}
@keyframes fvEnhSpin{to{transform:rotate(360deg)}}
.fv-enhancer-progress{width:min(260px,70%);height:6px;border-radius:999px;background:rgba(255,255,255,.12);overflow:hidden}
.fv-enhancer-progress span{display:block;height:100%;width:0;border-radius:999px;background:linear-gradient(90deg,#ffcf33,#ff2d55);transition:width .2s ease}
.fv-enhancer-loading em{font-style:normal;font-size:11px;opacity:.6;font-weight:600;max-width:280px;text-align:center;line-height:1.4}

.fv-enhancer-tools{
  width:300px;flex:none;border-left:1px solid rgba(255,255,255,.08);background:#101015;
  overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:14px;
}
.fv-enhancer-section{display:flex;flex-direction:column;gap:8px}
.fv-enhancer-section>h4{
  margin:0;font-size:11px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;
  color:rgba(255,255,255,.45);display:flex;align-items:center;gap:6px;
}
.fv-enhancer-section>h4::after{content:"";flex:1;height:1px;background:rgba(255,255,255,.08)}

.fv-enhancer-row{display:grid;grid-template-columns:repeat(2,1fr);gap:7px}
.fv-enhancer-row.cols-3{grid-template-columns:repeat(3,1fr)}
.fv-enhancer-tool-btn{
  min-height:38px;padding:7px 6px;border:1px solid rgba(255,255,255,.12);border-radius:10px;
  background:rgba(255,255,255,.05);color:#fff;font:inherit;font-size:11.5px;font-weight:700;cursor:pointer;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;touch-action:manipulation;
  transition:background .15s ease,border-color .15s ease,transform .1s ease;
}
.fv-enhancer-tool-btn svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.fv-enhancer-tool-btn:hover{background:rgba(255,255,255,.12);border-color:rgba(255,255,255,.25)}
.fv-enhancer-tool-btn:active{transform:scale(.96)}
.fv-enhancer-tool-btn.is-active{border-color:#ffcf33;background:rgba(255,207,51,.14);color:#ffd766}
.fv-enhancer-tool-btn.is-ai{
  border-color:transparent;background:linear-gradient(135deg,#ffcf33,#ff9f1a 55%,#ff2d55);
  color:#1a1206;font-weight:900;
}
.fv-enhancer-tool-btn.is-ai:hover{filter:brightness(1.08)}
.fv-enhancer-tool-btn.is-danger{border-color:rgba(255,77,109,.4);color:#ff8aa0;background:rgba(255,77,109,.1)}

.fv-enhancer-slider{display:flex;flex-direction:column;gap:4px}
.fv-enhancer-slider label{display:flex;justify-content:space-between;font-size:11.5px;font-weight:700;color:rgba(255,255,255,.75)}
.fv-enhancer-slider label b{color:#ffd766;font-weight:800;font-variant-numeric:tabular-nums}
.fv-enhancer-slider input[type=range]{
  -webkit-appearance:none;appearance:none;width:100%;height:5px;border-radius:999px;
  background:rgba(255,255,255,.14);outline:none;cursor:pointer;
}
.fv-enhancer-slider input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;appearance:none;width:17px;height:17px;border-radius:50%;
  background:linear-gradient(135deg,#ffcf33,#ff2d55);border:2px solid #141419;
  box-shadow:0 1px 5px rgba(0,0,0,.5);cursor:grab;
}
.fv-enhancer-slider input[type=range]::-moz-range-thumb{
  width:15px;height:15px;border-radius:50%;background:linear-gradient(135deg,#ffcf33,#ff2d55);
  border:2px solid #141419;cursor:grab;
}

.fv-enhancer-presets{display:flex;flex-wrap:wrap;gap:6px}
.fv-enhancer-preset{
  padding:6px 10px;border:1px solid rgba(255,255,255,.12);border-radius:999px;background:rgba(255,255,255,.05);
  color:#fff;font:inherit;font-size:11px;font-weight:700;cursor:pointer;touch-action:manipulation;
  transition:all .15s ease;
}
.fv-enhancer-preset:hover{background:rgba(255,255,255,.14)}
.fv-enhancer-preset.is-active{border-color:#ffcf33;background:rgba(255,207,51,.18);color:#ffd766}
.fv-enhancer-preset.is-ai{border-color:transparent;background:linear-gradient(135deg,#ffcf33,#ff2d55);color:#1a1206;font-weight:900}

.fv-enhancer-bg-swatches{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.fv-enhancer-bg-swatch{
  width:30px;height:30px;border-radius:50%;border:2px solid rgba(255,255,255,.2);cursor:pointer;
  padding:0;transition:transform .15s ease,border-color .15s ease;flex:none;
}
.fv-enhancer-bg-swatch:hover{transform:scale(1.12)}
.fv-enhancer-bg-swatch.is-active{border-color:#ffcf33;box-shadow:0 0 0 3px rgba(255,207,51,.25)}
.fv-enhancer-bg-swatch.is-transparent{
  background:
    linear-gradient(45deg,#ccc 25%,transparent 25%,transparent 75%,#ccc 75%),
    linear-gradient(45deg,#ccc 25%,#fff 25%,#fff 75%,#ccc 75%);
  background-size:12px 12px;background-position:0 0,6px 6px;background-color:#fff;
}
.fv-enhancer-bg-custom{
  flex:1;min-width:70px;height:30px;border:1px solid rgba(255,255,255,.2);border-radius:999px;
  background:transparent;cursor:pointer;padding:0;overflow:hidden;
}
.fv-enhancer-bg-custom::-webkit-color-swatch-wrapper{padding:2px}
.fv-enhancer-bg-custom::-webkit-color-swatch{border:0;border-radius:999px}
.fv-enhancer-bg-custom::-moz-color-swatch{border:0;border-radius:999px}

.fv-enhancer-note{font-size:10.5px;line-height:1.45;color:rgba(255,255,255,.45);margin:0}
.fv-enhancer-note b{color:rgba(255,255,255,.7);font-weight:700}

.fv-enhancer-foot{
  display:flex;gap:10px;align-items:center;padding:12px 14px;border-top:1px solid rgba(255,255,255,.08);
  background:rgba(0,0,0,.25);
}
.fv-enhancer-foot .fv-enhancer-meta{flex:1;font-size:11px;color:rgba(255,255,255,.5);line-height:1.4}
.fv-enhancer-foot .fv-enhancer-meta b{color:#ffd766}
.fv-enhancer-btn{
  min-height:42px;padding:10px 18px;border:0;border-radius:12px;font:inherit;font-size:13.5px;font-weight:800;
  cursor:pointer;touch-action:manipulation;transition:transform .15s ease,filter .15s ease;
}
.fv-enhancer-btn:active{transform:scale(.97)}
.fv-enhancer-btn-cancel{background:rgba(255,255,255,.08);color:#fff;border:1px solid rgba(255,255,255,.15)}
.fv-enhancer-btn-cancel:hover{background:rgba(255,255,255,.16)}
.fv-enhancer-btn-apply{
  background:linear-gradient(135deg,#ffcf33,#ff9f1a 55%,#ff2d55);color:#1a1206;
  box-shadow:0 6px 18px rgba(255,159,26,.4);font-weight:900;
}
.fv-enhancer-btn-apply:hover{filter:brightness(1.07)}
.fv-enhancer-btn-apply:disabled{opacity:.5;cursor:not-allowed;box-shadow:none}

/* Toast thông báo nhỏ */
.fv-enhancer-toast{
  position:fixed;left:50%;bottom:28px;transform:translateX(-50%) translateY(20px);z-index:100000;
  padding:10px 18px;border-radius:999px;background:rgba(20,20,25,.95);color:#fff;font-size:13px;font-weight:700;
  border:1px solid rgba(255,255,255,.15);box-shadow:0 10px 30px rgba(0,0,0,.5);opacity:0;pointer-events:none;
  transition:opacity .2s ease,transform .2s ease;max-width:90vw;text-align:center;
}
.fv-enhancer-toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.fv-enhancer-toast.is-error{border-color:rgba(255,77,109,.5);color:#ffb3c0}

@media (max-width:720px){
  .fv-enhancer-body{flex-direction:column}
  .fv-enhancer-tools{width:auto;border-left:0;border-top:1px solid rgba(255,255,255,.08);max-height:46vh}
  .fv-enhancer-canvas-wrap canvas{max-height:38vh}
  .fv-enhancer-head small{display:none}
}

/* ===== v6.10.139: Dàn dựng ảnh tự động (auto collage) ===== */
.fv-enhance-bar button.fv-enhance-collage{
  border-color:rgba(120,255,180,.35);background:linear-gradient(135deg,rgba(16,185,129,.22),rgba(56,189,248,.22));
  color:#b8f5d4;
}
.fv-collage-templates{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.fv-collage-tpl{
  position:relative;height:64px;border:2px solid rgba(255,255,255,.14);border-radius:10px;
  background:rgba(255,255,255,.05);cursor:pointer;padding:0;overflow:hidden;transition:all .15s ease;
}
.fv-collage-tpl:hover{border-color:rgba(255,255,255,.35);transform:translateY(-1px)}
.fv-collage-tpl.is-active{border-color:#ffcf33;background:rgba(255,207,51,.1);box-shadow:0 0 0 3px rgba(255,207,51,.18)}
.fv-collage-tpl i{position:absolute;background:rgba(255,255,255,.35);border-radius:2px;display:block}
.fv-collage-tpl b{
  position:absolute;left:0;right:0;bottom:2px;text-align:center;font-size:9px;font-weight:800;
  color:rgba(255,255,255,.7);letter-spacing:.02em;pointer-events:none;
}
.fv-collage-ratio{display:flex;flex-wrap:wrap;gap:6px}
.fv-collage-ratio button{
  flex:1;min-width:52px;min-height:34px;padding:5px 6px;border:1px solid rgba(255,255,255,.12);border-radius:9px;
  background:rgba(255,255,255,.05);color:#fff;font:inherit;font-size:11px;font-weight:700;cursor:pointer;
}
.fv-collage-ratio button.is-active{border-color:#ffcf33;background:rgba(255,207,51,.16);color:#ffd766}
.fv-collage-bg{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.fv-collage-bg .fv-enhancer-bg-swatch{width:28px;height:28px}
.fv-collage-bg .fv-enhancer-bg-custom{flex:1;min-width:60px;height:28px}
.fv-collage-bg .fv-collage-bg-gradient{
  background:linear-gradient(135deg,#ffcf33,#ff2d55);
}
