/**
 * FLATSOME UX BUILDER & LIVE THEME CUSTOMIZER STUDIO
 * Giao diện Studio thiết kế & tùy biến giao diện trực quan cho Phật Giáo Phú Thọ
 */

/* 1. NÚT MỞ BẢNG STUDIO NỔI BÊN CẠNH TRÁI */
#flatsome-builder-toggle-btn {
    position: fixed;
    top: 180px;
    left: 0;
    z-index: 99998;
    background: linear-gradient(135deg, #b8332a 0%, #8e44ad 100%);
    color: #ffffff;
    padding: 10px 14px 10px 10px;
    border-radius: 0 30px 30px 0;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(184, 51, 42, 0.45);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-left: none;
}

#flatsome-builder-toggle-btn:hover {
    padding-left: 14px;
    padding-right: 18px;
    background: linear-gradient(135deg, #d32f2f 0%, #673ab7 100%);
    box-shadow: 0 6px 24px rgba(142, 68, 173, 0.6);
    transform: translateX(2px);
}

#flatsome-builder-toggle-btn i {
    font-size: 16px;
    animation: pstSpinSlow 10s linear infinite;
}

@keyframes pstSpinSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 2. BẢNG ĐIỀU KHIỂN STUDIO TRƯỢT SANG TỪ BÊN TRÁI (FLATSOME UX SIDEBAR) */
#flatsome-builder-panel {
    position: fixed;
    top: 0;
    left: -430px;
    width: 420px;
    max-width: 90vw;
    height: 100vh;
    background: #ffffff;
    z-index: 99999;
    box-shadow: 5px 0 35px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: left 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
    color: #1f2937;
    border-right: 1px solid #e5e7eb;
}

#flatsome-builder-panel.open {
    left: 0;
}

/* Header Studio */
.fub-header {
    background: linear-gradient(135deg, #632d00 0%, #b8332a 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.fub-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fub-header-title i {
    font-size: 20px;
    color: #f59e0b;
}

.fub-header-title h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #ffffff;
}

.fub-header-title .fub-badge {
    background: rgba(255, 255, 255, 0.2);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.fub-close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
    outline: none;
    padding: 0;
}

.fub-close-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Thanh điều hướng Tab chuyên mục */
.fub-tabs-nav {
    display: flex;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    scrollbar-width: thin;
    flex-shrink: 0;
}

.fub-tab-btn {
    background: none;
    border: none;
    padding: 11px 13px;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    outline: none;
}

.fub-tab-btn:hover {
    color: #b8332a;
    background: #f1f5f9;
}

.fub-tab-btn.active {
    color: #b8332a;
    border-bottom-color: #b8332a;
    background: #ffffff;
}

/* Nội dung cuộn bên trong panel */
.fub-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    background: #fdfdfd;
}

.fub-tab-content {
    display: none;
}

.fub-tab-content.active {
    display: block;
}

/* Section Group trong mỗi tab */
.fub-group {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.fub-group-title {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fub-group-title i {
    color: #b8332a;
    margin-right: 6px;
}

/* Input Row */
.fub-control-row {
    margin-bottom: 12px;
}

.fub-control-row:last-child {
    margin-bottom: 0;
}

.fub-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 5px;
}

.fub-slider-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fub-slider-box input[type="range"] {
    flex: 1;
    accent-color: #b8332a;
    cursor: pointer;
}

.fub-slider-val {
    width: 65px;
    text-align: right;
    font-weight: 700;
    font-size: 12px;
    color: #b8332a;
    background: #fdf2f2;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid #fecaca;
}

/* Color Picker Row */
.fub-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.fub-color-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fub-color-picker {
    width: 34px;
    height: 30px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    padding: 1px;
    background: #fff;
}

.fub-color-text {
    width: 80px;
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    color: #374151;
}

/* Toggle Switch kiểu iOS */
.fub-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.fub-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
}

.fub-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.fub-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 24px;
}

.fub-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.fub-switch input:checked + .fub-slider {
    background-color: #22c55e;
}

.fub-switch input:checked + .fub-slider:before {
    transform: translateX(20px);
}

/* Bảng chọn layout grid */
.fub-grid-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 6px;
}

.fub-grid-btn {
    border: 1px solid #d1d5db;
    background: #f9fafb;
    border-radius: 6px;
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    color: #4b5563;
    transition: all 0.2s;
    outline: none;
}

.fub-grid-btn:hover, .fub-grid-btn.active {
    background: #fef2f2;
    border-color: #b8332a;
    color: #b8332a;
}

.fub-grid-icon-preview {
    display: flex;
    gap: 2px;
    height: 14px;
    margin-bottom: 5px;
    padding: 0 4px;
}

.fub-grid-col-box {
    background: #cbd5e1;
    border-radius: 2px;
    height: 100%;
}

.fub-grid-btn.active .fub-grid-col-box {
    background: #b8332a;
}

/* Footer Studio với các nút Lưu */
.fub-footer {
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.fub-btn-save {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    outline: none;
    width: 100%;
}

.fub-btn-save:hover {
    background: linear-gradient(135deg, #15803d 0%, #166534 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.45);
}

.fub-btn-row {
    display: flex;
    gap: 8px;
}

.fub-btn-secondary {
    flex: 1;
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #4b5563;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    text-align: center;
}

.fub-btn-secondary:hover {
    background: #f3f4f6;
    color: #111827;
}


/* ==========================================================================
   3. THANH CHIA CỘT KÉO THẢ TRỰC TIẾP TRÊN MÀN HÌNH (LIVE RESIZER HANDLE)
   ========================================================================== */
#pst-column-resizer-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 16px;
    cursor: col-resize;
    z-index: 100000;
    background: transparent;
    display: none;
    align-items: center;
    justify-content: center;
    user-select: none;
}

body.fub-live-edit-active #pst-column-resizer-handle,
#pst-column-resizer-handle.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#pst-column-resizer-line {
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #b8332a, #d4af37, #b8332a);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(184, 51, 42, 0.5);
    transition: all 0.2s;
}

#pst-column-resizer-handle:hover #pst-column-resizer-line,
#pst-column-resizer-handle.resizing #pst-column-resizer-line {
    width: 6px;
    background: #e52d27;
    box-shadow: 0 0 14px rgba(229, 45, 39, 0.8);
}

#pst-column-resizer-grip {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 48px;
    background: #b8332a;
    color: #fff;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 2px solid #fff;
    cursor: col-resize;
}

/* Tooltip hiển thị số đo thực khi kéo */
#pst-resizer-tooltip {
    position: fixed;
    z-index: 100000;
    background: #111827;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    display: none;
    border: 1px solid #374151;
    white-space: nowrap;
}

/* Đường viền bao quanh phần tử khi bật Live Edit Mode */
body.fub-live-edit-active .nvnews-fullwidth-main {
    outline: 2px dashed rgba(184, 51, 42, 0.4);
    outline-offset: 4px;
    position: relative;
}

body.fub-live-edit-active .nvnews-fullwidth-side {
    outline: 2px dashed rgba(212, 175, 55, 0.5);
    outline-offset: 4px;
    position: relative;
}

/* Banner tĩnh bên Trái / Bên Phải */
#pstStaticLeftBanner, #pstStaticRightBanner {
    position: fixed;
    top: 160px;
    z-index: 9990;
    transition: transform 0.3s;
}

#pstStaticLeftBanner {
    left: 10px;
}

#pstStaticRightBanner {
    right: 10px;
}

#pstStaticLeftBanner img, #pstStaticRightBanner img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 1px solid #e5e7eb;
}


/* ==========================================================================
   4. NÚT NỔI BẬT/TẮT NHANH KÉO THẢ ĐỘ RỘNG TRỰC TIẾP TRÊN WEB
   ========================================================================== */
#pst-live-resizer-floating-btn {
    position: fixed;
    top: 235px;
    left: 0;
    z-index: 99998;
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #ffffff;
    padding: 9px 14px 9px 10px;
    border-radius: 0 30px 30px 0;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(217, 119, 6, 0.45);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-left: none;
}

#pst-live-resizer-floating-btn:hover {
    padding-left: 14px;
    padding-right: 18px;
    background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
    box-shadow: 0 6px 24px rgba(234, 88, 12, 0.6);
    transform: translateX(2px);
}

#pst-live-resizer-floating-btn.active {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    box-shadow: 0 4px 18px rgba(22, 163, 74, 0.5);
}

#pst-live-resizer-floating-btn i {
    font-size: 14px;
}

/* THANH KÉO MÉP PHẢI CONTAINER & KHUNG TOÀN TRANG */
#pst-container-resizer-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 16px;
    cursor: ew-resize;
    z-index: 100000;
    background: transparent;
    display: none;
    align-items: center;
    justify-content: center;
    user-select: none;
}

body.fub-live-edit-active #pst-container-resizer-handle,
#pst-container-resizer-handle.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#pst-container-resizer-line {
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #d97706, #16a34a, #d97706);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(217, 119, 6, 0.5);
    transition: all 0.2s;
}

#pst-container-resizer-handle:hover #pst-container-resizer-line,
#pst-container-resizer-handle.resizing #pst-container-resizer-line {
    width: 6px;
    background: #16a34a;
    box-shadow: 0 0 14px rgba(22, 163, 74, 0.8);
}

#pst-container-resizer-grip {
    position: absolute;
    top: 25%;
    transform: translateY(-50%);
    width: 26px;
    height: 48px;
    background: #d97706;
    color: #fff;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 2px solid #fff;
    cursor: ew-resize;
}

/* Thông báo lưu tự động sau khi kéo thả */
#pst-autosave-toast {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: #15803d;
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    z-index: 100000;
    display: none;
    align-items: center;
    gap: 8px;
    animation: fadeInToast 0.3s ease;
}

@keyframes fadeInToast {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Đường viền bao quanh phần tử khi bật Live Edit Mode */
body.fub-live-edit-active #body.container,
body.fub-live-edit-active .nvnews-fullwidth-wrapper #body.container {
    outline: 2px dashed rgba(22, 163, 74, 0.5) !important;
    outline-offset: 4px;
    position: relative;
}

body.fub-live-edit-active .news_column,
body.fub-live-edit-active .panel-body.featured,
body.fub-live-edit-active .panel-body {
    outline: 1px dotted rgba(184, 51, 42, 0.3) !important;
}

/* Nút tiện ích mở nhanh bảng tùy biến Footer */
.pst-btn-edit-footer {
    background: #4a1d04 !important;
    color: #fde68a !important;
    border: 1px solid #7a350a !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
    padding: 3px 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    cursor: pointer !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.2s ease !important;
}

.pst-btn-edit-footer:hover {
    background: #6a2a07 !important;
    color: #ffffff !important;
    border-color: #8b3a0a !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    transform: translateY(-1px) !important;
}

