/* ============================================================
   Visual Builder — sửa trực tiếp section trên frontend
   Chỉ tải khi admin có quyền manage_page_sections
   ============================================================ */
.vb-enabled .vs-wrap {
    position: relative;
    cursor: pointer;
    transition: outline-color .15s ease;
    outline: 2px dashed transparent;
    outline-offset: -2px;
}
.vb-enabled .vs-wrap:hover,
.vb-enabled .vs-wrap.vb-active {
    outline-color: #0f766e;
    z-index: 5;
}
.vb-enabled .vs-wrap:hover {
    background: rgba(15, 118, 110, .04);
}

/* Ảnh trong section: click để đổi ảnh trực tiếp */
.vb-enabled .vs-wrap img {
    cursor: pointer;
    transition: outline-color .15s ease, box-shadow .15s ease;
    outline: 2px dashed transparent;
    outline-offset: 2px;
}
.vb-enabled .vs-wrap img:hover {
    outline-color: #0f766e;
    box-shadow: 0 0 0 6px rgba(15, 118, 110, .15);
}

/* Thanh công cụ nổi trên từng section — LUÔN hiển thị khi bật chế độ edit */
.vb-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #0f172a;
    color: #fff;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .35);
    transform: translateY(0);
    opacity: 1;
    transition: opacity .18s ease, transform .18s ease;
    font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
    pointer-events: auto;
}
.vb-enabled .vs-wrap:hover .vb-toolbar,
.vb-enabled .vs-wrap.vb-active .vb-toolbar {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.vb-toolbar button {
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 12px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.vb-toolbar button:hover {
    background: #0f766e;
    color: #fff;
}
.vb-toolbar button.vb-danger:hover {
    background: #dc2626;
}
.vb-toolbar .vb-type-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 0 8px;
    color: #94a3b8;
    white-space: nowrap;
}

/* Thanh builder nổi cuối trang */
.vb-bar {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #0f172a;
    color: #fff;
    border-radius: 40px;
    padding: 8px 10px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, .45);
    font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
}
.vb-bar .vb-page-name {
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
    padding: 0 10px;
    border-right: 1px solid #334155;
}
.vb-bar button {
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 13px;
    height: 32px;
    padding: 0 12px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background .15s, color .15s;
    font-weight: 600;
}
.vb-bar button:hover {
    background: #1e293b;
    color: #fff;
}
.vb-bar button.vb-primary {
    background: #0f766e;
    color: #fff;
}
.vb-bar button.vb-primary:hover {
    background: #115e59;
}
.vb-bar .vb-save-status {
    font-size: 11px;
    color: #94a3b8;
    padding: 0 6px;
}

/* Panel chỉnh sửa inline (dock phải) */
.vb-editor {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    z-index: 10050;
    background: #fff;
    color: #0f172a;
    box-shadow: -12px 0 40px rgba(15, 23, 42, .25);
    display: flex;
    flex-direction: column;
    transition: right .28s cubic-bezier(.4, 0, .2, 1);
    font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
}
.vb-editor.vb-open { right: 0; }
.vb-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 18px;
    background: #0f766e;
    color: #fff;
}
.vb-editor-header h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.vb-editor-header button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    opacity: .85;
    line-height: 1;
}
.vb-editor-header button:hover { opacity: 1; }
.vb-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}
.vb-editor-body label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.vb-editor-body .form-control {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    margin-bottom: 14px;
    box-sizing: border-box;
}
.vb-editor-body .form-control:focus {
    outline: none;
    border-color: #0f766e;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}
.vb-editor-body textarea.form-control {
    resize: vertical;
    min-height: 120px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
}
.vb-editor-group-head {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #0f766e;
    margin: 18px 0 8px;
    padding-top: 12px;
    border-top: 1px solid #eef2f7;
}
.vb-editor-group-head:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.vb-editor-body .form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}
.vb-editor-footer {
    padding: 12px 18px;
    border-top: 1px solid #e3edf3;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #f8fafc;
}
.vb-editor-footer .btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
.vb-editor-footer .btn-primary {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}
.vb-editor-footer .btn-primary:hover { background: #115e59; }

/* Trình soạn thảo nội dung (contenteditable) */
.vb-html-edit {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px;
    min-height: 140px;
    font-size: 13px;
    line-height: 1.6;
    overflow-y: auto;
    background: #fff;
}
.vb-html-edit:focus {
    outline: none;
    border-color: #0f766e;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}

/* Trạng thái lưu / lỗi */
.vb-editor .vb-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    margin-bottom: 12px;
}
.vb-editor .vb-info {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    margin-bottom: 12px;
}

/* Nút add section */
.vb-add-btn {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 10000;
    background: #0f172a;
    color: #fff;
    border: none;
    border-radius: 40px;
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 40px rgba(15, 23, 42, .45);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
    transition: background .15s;
}
.vb-add-btn:hover { background: #1e293b; }

/* Toast */
.vb-toast {
    position: fixed;
    left: 50%;
    top: 18px;
    transform: translateX(-50%);
    z-index: 10060;
    background: #0f172a;
    color: #fff;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .35);
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
    font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
}
.vb-toast.vb-show { opacity: 1; }
.vb-toast.vb-success { background: #059669; }
.vb-toast.vb-error { background: #dc2626; }

/* Danh sách chọn loại section (add block) */
.vb-types {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.vb-types button {
    text-align: left;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
.vb-types button:hover {
    border-color: #0f766e;
    box-shadow: 0 2px 8px rgba(15, 118, 110, .15);
}
.vb-types button i { color: #0f766e; margin-right: 6px; }
.vb-types button .vb-type-label {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    display: block;
    margin-top: 4px;
}

/* Chế độ di chuyển: highlight drop zone */
.vb-drop-zone {
    position: relative;
}
.vb-drop-zone::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: #0f766e;
    border-radius: 2px;
    pointer-events: none;
}

/* Overlay mờ khi panel mở để tránh thao tác lạ */
.vb-scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .28);
    z-index: 10040;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.vb-scrim.vb-show {
    opacity: 1;
    pointer-events: auto;
}

/* About: visual hint khi hover media */
.vb-enabled .vs-about-media { outline: 2px dashed transparent; outline-offset: 2px; transition: outline-color .15s ease, box-shadow .15s ease; }
.vb-enabled .vs-about-media:hover { outline-color: #0f766e; box-shadow: 0 0 0 6px rgba(15,118,110,.14), var(--vs-shadow-lg); }

/* Trên mobile: toolbar luôn hiển thị đầy đủ */
@media (max-width: 575px) {
    .vb-toolbar { opacity: 1; transform: none; pointer-events: auto; }
    .vb-editor { width: 100vw; }
}

/* ============ Section map / iframe ============
   Iframe (Google Maps) nuốt mọi click — không bubble lên document,
   visual builder không intercept được. Chặn pointer-events để click
   đi tới .vs-wrap (chọn section / toolbar) thay vì map. Muốn tương
   tác bản đồ thật, dùng nút "Xem thật" trên thanh builder. */
.vb-enabled .vs-wrap iframe { pointer-events: none; }
