/* =============================================================
   Turbo H&F Builder — Admin Dashboard v1.1.8
   ============================================================= */
:root {
    --thfb-primary:       #2e3195;
    --thfb-primary-dark:  #1e2070;
    --thfb-primary-light: #eef0ff;
    --thfb-accent:        #ff8800;
    --thfb-success:       #1a9e5c;
    --thfb-success-bg:    #edfaf3;
    --thfb-warning:       #e67e22;
    --thfb-warning-bg:    #fff8ee;
    --thfb-danger:        #e53e3e;
    --thfb-danger-bg:     #fff5f5;
    --thfb-text:          #1e1e2d;
    --thfb-muted:         #6b7280;
    --thfb-border:        #e5e7eb;
    --thfb-bg:            #f4f5fa;
    --thfb-white:         #ffffff;
    --thfb-radius:        12px;
    --thfb-shadow:        0 2px 12px rgba(46,49,149,.08);
    --thfb-shadow-hover:  0 6px 24px rgba(46,49,149,.16);
}

/* ── Layout ─────────────────────────────────────────────────── */
#thfb-dashboard {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--thfb-text);
    max-width: 98%;
    margin: 20px 20px 60px 0;
}
#thfb-dashboard * { box-sizing: border-box; }

/* ── Hero ────────────────────────────────────────────────────── */
.thfb-hero {
    background: linear-gradient(135deg, var(--thfb-primary) 0%, #df04cd 100%);
    border-radius: var(--thfb-radius);
    padding: 20px 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    box-shadow: var(--thfb-shadow);
    overflow: hidden;
    position: relative;
}
.thfb-hero::before {
    content:''; position:absolute; right:-60px; top:-60px;
    width:260px; height:260px; border-radius:50%;
    background:rgba(255,255,255,.06); pointer-events:none;
}
.thfb-hero-text h1 { color:#fff; font-size:24px; font-weight:700; margin:0 0 6px; line-height:1.2; }
.thfb-hero-text p  { color:rgba(255,255,255,.78); font-size:16px; margin:0; line-height:1.6; }
.thfb-hero-logo    { height:60px; width:auto; flex-shrink:0; filter:brightness(0) invert(1); opacity:.9; position:relative; z-index:1; }
.thfb-hero-actions { display:flex; gap:10px; flex-shrink:0; position:relative; z-index:1; }
.thfb-version-badge {
    display:inline-flex; align-items:center; gap:4px;
    background:rgba(255,255,255,.18); color:rgba(255,255,255,.9);
    padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600; margin-top:10px;
}
.thfb-version-badge .dashicons { font-size:12px; width:12px; height:12px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.thfb-btn {
    display:inline-flex; 
    align-items:center; 
    gap:6px;
    padding:9px 18px; 
    border-radius:8px; 
    font-size:16px; 
    font-weight:600;
    text-decoration:none; 
    cursor:pointer; 
    border:none;
    transition:all .15s ease; 
    line-height:1; white-space:nowrap; font-family:inherit;
}
.thfb-btn.thfb-sm { padding:10px 12px; font-size:16px; }
.thfb-btn .dashicons { font-size:15px; width:15px; height:15px; line-height:1; }
.thfb-btn-white         { background:#fff; color:var(--thfb-primary); }
.thfb-btn-white:hover   { background:#f0f1ff; color:var(--thfb-primary-dark); transform:translateY(-1px); box-shadow:0 4px 12px rgba(0,0,0,.15); }
.thfb-btn-outline-white { background:transparent; color:#fff; border:1.5px solid rgba(255,255,255,.55); }
.thfb-btn-outline-white:hover { background:rgba(255,255,255,.12); color:#fff; border-color:rgba(255,255,255,.9); }
.thfb-btn-primary       { background:var(--thfb-primary); color:#fff; }
.thfb-btn-primary:hover { background:var(--thfb-primary-dark); color:#fff; transform:translateY(-1px); box-shadow:var(--thfb-shadow-hover); }
.thfb-btn-success       { background:var(--thfb-success); color:#fff; }
.thfb-btn-success:hover { background:#157a48; color:#fff; transform:translateY(-1px); }
.thfb-btn-ghost         { background:#f3f4f6; color:var(--thfb-text); }
.thfb-btn-ghost:hover   { background:#e5e7eb; color:var(--thfb-text); }

/* ── Main Grid ───────────────────────────────────────────────── */
.thfb-main-grid { display:grid; grid-template-columns:1fr 320px; gap:20px; align-items:start; }

/* ── Panel ───────────────────────────────────────────────────── */
.thfb-panel {
    background:var(--thfb-white); border-radius:var(--thfb-radius);
    box-shadow:var(--thfb-shadow); border:1px solid var(--thfb-border);
    overflow:hidden; margin-bottom:20px;
}
.thfb-panel-header {
    padding:16px 22px; border-bottom:1px solid var(--thfb-border);
    display:flex; align-items:center; justify-content:space-between; gap:12px;
}
.thfb-panel-title {
    font-size:16px; font-weight:700; color:var(--thfb-text);
    display:flex; align-items:center; gap:8px; margin:0;
}
.thfb-panel-title .dashicons { color:var(--thfb-primary); font-size:17px; width:17px; height:17px; }
.thfb-panel-body { padding:0; }
.thfb-table-wrap { padding:0; }

/* ── Template Table ──────────────────────────────────────────── */
.thfb-template-table { width:100%; border-collapse:collapse; }
.thfb-template-table th {
    text-align:left; font-size:13px; font-weight:500;
    text-transform:uppercase; letter-spacing:.5px; color:var(--thfb-muted);
    padding:10px 16px 10px; border-bottom:1px solid var(--thfb-border);
    background:#fafbff;
}
.thfb-template-table td {
     padding:13px 16px; 
     font-size:16px; 
     border-bottom:1px solid #f3f4f6; 
     vertical-align:middle; 
    }
.thfb-template-table tr:last-child td { border-bottom:none; }
.thfb-template-table tr:hover td { background:#fafbff; }
.thfb-template-name { display:flex; align-items:center; gap:8px; }
.thfb-template-name .dashicons { color:var(--thfb-primary); font-size:16px; width:16px; height:16px; flex-shrink:0; }
.thfb-template-name strong { font-weight:600; color:var(--thfb-text); }
.thfb-template-meta { font-size:11px; color:var(--thfb-muted); margin-top:2px; }

/* ── Badges ──────────────────────────────────────────────────── */
.thfb-badge {
    display:inline-flex; align-items:center; gap:4px;
    padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600; white-space:nowrap;
}
.thfb-badge-active { background:var(--thfb-success-bg); color:var(--thfb-success); }
.thfb-badge-active::before { content:''; width:6px; height:6px; border-radius:50%; background:var(--thfb-success); flex-shrink:0; }
.thfb-badge-draft  { background:#f3f4f6; color:var(--thfb-muted); }
.thfb-badge-draft::before  { content:''; width:6px; height:6px; border-radius:50%; background:var(--thfb-muted); flex-shrink:0; }
.thfb-toggle-status { cursor:pointer !important; transition:opacity .15s ease; }
.thfb-toggle-status:hover { opacity:.75; }

/* ── Condition tags ──────────────────────────────────────────── */
.thfb-condition-tag {
    display:inline-flex; align-items:center; gap:3px;
    background:var(--thfb-primary-light); color:var(--thfb-primary);
    padding:2px 8px; border-radius:5px; font-size:11px; font-weight:500; margin:2px 2px 2px 0;
}
.thfb-condition-none { color:var(--thfb-muted); font-size:12px; font-style:italic; }

/* ── Row Actions ─────────────────────────────────────────────── */
.thfb-row-actions { display:flex; gap:5px; align-items:center; flex-wrap:wrap; }
.thfb-action-btn {
    display:inline-flex; align-items:center; gap:4px;
    padding:5px 10px; border-radius:6px; font-size:11px; font-weight:500;
    text-decoration:none; border:1px solid transparent; cursor:pointer;
    transition:all .13s ease; background:none; white-space:nowrap; font-family:inherit;
}
.thfb-action-btn .dashicons { font-size:13px; width:13px; height:13px; line-height:1; }
.thfb-action-edit       { color:var(--thfb-primary); border-color:var(--thfb-primary-light); background:var(--thfb-primary-light); }
.thfb-action-edit:hover { background:var(--thfb-primary); color:#fff; border-color:var(--thfb-primary); }
.thfb-action-conditions       { color:var(--thfb-warning); border-color:var(--thfb-warning-bg); background:var(--thfb-warning-bg); }
.thfb-action-conditions:hover { background:var(--thfb-warning); color:#fff; border-color:var(--thfb-warning); }
.thfb-action-delete       { color:var(--thfb-danger); border-color:var(--thfb-danger-bg); background:var(--thfb-danger-bg); }
.thfb-action-delete:hover { background:var(--thfb-danger); color:#fff; border-color:var(--thfb-danger); }

/* ── Empty State ─────────────────────────────────────────────── */
.thfb-empty-state { text-align:center; padding:48px 24px; }
.thfb-empty-icon { width:60px; height:60px; background:var(--thfb-primary-light); border-radius:50%; display:flex; align-items:center; justify-content:center; margin:0 auto 14px; }
.thfb-empty-icon .dashicons { font-size:26px; width:26px; height:26px; color:var(--thfb-primary); }
.thfb-empty-state h3 { font-size:15px; font-weight:600; color:var(--thfb-text); margin:0 0 6px; }
.thfb-empty-state p  { font-size:13px; color:var(--thfb-muted); margin:0; }

/* ── Quick Actions ───────────────────────────────────────────── */
.thfb-quick-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.thfb-quick-action-card {
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:8px; padding:18px 10px; border-radius:10px;
    border:1.5px dashed var(--thfb-border); text-decoration:none; color:var(--thfb-text);
    transition:all .15s ease; text-align:center; cursor:pointer;
    background:none; width:100%; font-family:inherit;
}
.thfb-quick-action-card:hover { border-color:var(--thfb-primary); background:var(--thfb-primary-light); color:var(--thfb-primary); transform:translateY(-2px); box-shadow:var(--thfb-shadow); }
.thfb-quick-action-card .dashicons { font-size:24px; width:24px; height:24px; color:var(--thfb-primary); }
.thfb-quick-action-card span { font-size:12px; font-weight:600; line-height:1.3; }

/* ── Promo ───────────────────────────────────────────────────── */
.thfb-promo { background:linear-gradient(135deg,#ff8800 0%,#ff5e00 100%); border-radius:var(--thfb-radius); padding:20px 22px; color:#fff; margin-bottom:20px; box-shadow:0 4px 16px rgba(255,136,0,.25); }
.thfb-promo h3 { font-size:14px; font-weight:700; margin:0 0 6px; color:#fff; }
.thfb-promo p  { font-size:14px; margin:0 0 12px; opacity:.9; line-height:1.5; }
.thfb-btn-promo { background:#fff; color:#ff5e00; font-size:12px; font-weight:700; padding:7px 14px; border-radius:6px; text-decoration:none; display:inline-flex; align-items:center; gap:5px; transition:all .13s ease; }
.thfb-btn-promo:hover { background:#fff3e0; color:#e65c00; }
.thfb-btn-promo .dashicons { font-size:14px; width:14px; height:14px; }

/* ── Soft Feedback CTA ──────────────────────────────────────── */
.thfb-feedback-banner { margin-top:4px; }
.thfb-btn-feedback {
    width:100%; justify-content:center; text-align:center;
    background:var(--thfb-warning-bg); color:var(--thfb-warning);
    border:1.5px dashed var(--thfb-warning);
    font-size:14px; padding:14px 16px;
}
.thfb-btn-feedback:hover { background:#fff1db; color:var(--thfb-warning); transform:none; box-shadow:none; }

/* ── Feedback checkbox list ─────────────────────────────────── */
.thfb-checkbox-list { display:flex; flex-direction:column; gap:8px; }
.thfb-checkbox-row {
    display:flex; align-items:flex-start; gap:10px;
    font-size:13px; color:var(--thfb-text); cursor:pointer;
    padding:10px 12px; border:1px solid var(--thfb-border); border-radius:8px;
    transition:border-color .13s ease, background .13s ease;
}
.thfb-checkbox-row:hover { border-color:var(--thfb-primary); background:var(--thfb-primary-light); }
.thfb-checkbox-row input[type="checkbox"] { margin-top:2px; }
#thfb-feedback-msg.thfb-feedback-success { color:var(--thfb-success); }
#thfb-feedback-msg.thfb-feedback-error   { color:var(--thfb-danger); }

/* ── Tips ────────────────────────────────────────────────────── */
.thfb-tip-list { list-style:none; margin:0; padding:16px 22px; display:flex; flex-direction:column; gap:6px; }
.thfb-tip-list li { display:flex; align-items:flex-start; gap:9px; font-size:13px; color:var(--thfb-text); line-height:1.5; }
.thfb-tip-list li .dashicons { color:var(--thfb-success); font-size:16px; width:16px; height:16px; flex-shrink:0; margin-top:1px; }

/* ══════════════════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════════════════ */
.thfb-modal-overlay {
    position:fixed; inset:0; z-index:999999;
    background:rgba(15,15,30,.55); backdrop-filter:blur(3px);
    display:flex; align-items:center; justify-content:center; padding:20px;
}
.thfb-modal {
    background:#fff; border-radius:16px; width:100%; max-width:560px;
    box-shadow:0 20px 60px rgba(0,0,0,.25); display:flex; flex-direction:column;
    max-height:90vh; overflow:hidden;
    animation:thfbSlideIn .2s ease;
}
@keyframes thfbSlideIn {
    from { opacity:0; transform:translateY(-16px) scale(.97); }
    to   { opacity:1; transform:translateY(0) scale(1); }
}
.thfb-modal-header {
    padding:20px 24px 16px; border-bottom:1px solid var(--thfb-border);
    display:flex; align-items:center; justify-content:space-between; flex-shrink:0;
}
.thfb-modal-header h2 { font-size:17px; font-weight:700; color:var(--thfb-text); margin:0; }
.thfb-modal-close {
    width:32px; height:32px; border-radius:8px; border:none; background:#f3f4f6;
    cursor:pointer; font-size:18px; line-height:1; color:var(--thfb-muted);
    display:flex; align-items:center; justify-content:center; transition:all .13s ease;
}
.thfb-modal-close:hover { background:#e5e7eb; color:var(--thfb-text); }
.thfb-modal-body { padding:20px 24px; overflow-y:auto; flex:1; }
.thfb-modal-footer {
    padding:16px 24px; border-top:1px solid var(--thfb-border);
    display:flex; gap:10px; align-items:center; flex-shrink:0; background:#fafbff;
}

/* ── Form fields inside modal ────────────────────────────────── */
.thfb-field-label { display:block; font-size:13px; font-weight:600; color:var(--thfb-text); margin-bottom:6px; }
.thfb-optional { font-weight:400; color:var(--thfb-muted); font-size:12px; }
.thfb-input {
    width:100%; padding:10px 14px; border:1.5px solid var(--thfb-border);
    border-radius:8px; font-size:14px; color:var(--thfb-text); font-family:inherit;
    transition:border-color .13s ease; outline:none;
}
.thfb-input:focus { border-color:var(--thfb-primary); box-shadow:0 0 0 3px rgba(46,49,149,.1); }
.thfb-select { width:100%; }
.thfb-divider { border:none; border-top:1px solid var(--thfb-border); margin:18px 0; }

/* Toggle switch */
.thfb-header-opts { margin-top:4px; }
.thfb-toggle-row { display:flex; flex-direction:column; gap:12px; }
.thfb-toggle-label {
    display:flex; align-items:center; gap:10px;
    font-size:13px; color:var(--thfb-text); cursor:pointer; user-select:none;
}
.thfb-toggle-label input[type="checkbox"] { display:none; }
.thfb-toggle-switch {
    width:40px; height:22px; background:#d1d5db; border-radius:11px;
    position:relative; flex-shrink:0; transition:background .15s ease;
}
.thfb-toggle-switch::after {
    content:''; position:absolute; top:3px; left:3px;
    width:16px; height:16px; border-radius:50%; background:#fff;
    transition:transform .15s ease; box-shadow:0 1px 3px rgba(0,0,0,.2);
}
.thfb-toggle-label input:checked + .thfb-toggle-switch { background:var(--thfb-primary); }
.thfb-toggle-label input:checked + .thfb-toggle-switch::after { transform:translateX(18px); }

/* Select2 inside modal */
.thfb-modal .select2-container { z-index:9999999 !important; }
.thfb-modal .select2-dropdown  { z-index:9999999 !important; }
.thfb-modal .select2-container--default .select2-selection--multiple {
    border:1.5px solid var(--thfb-border) !important; border-radius:8px !important;
    min-height:40px !important; padding:4px 8px !important;
}
.thfb-modal .select2-container--default .select2-selection--multiple:focus-within {
    border-color:var(--thfb-primary) !important;
    box-shadow:0 0 0 3px rgba(46,49,149,.1) !important;
}
.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color:#e9f2ff !important; color:#0b3d91 !important;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width:1100px) {
    .thfb-main-grid { grid-template-columns:1fr; }
}
@media (max-width:640px) {
    .thfb-hero { flex-direction:column; align-items:flex-start; }
    .thfb-hero-logo { display:none; }
    .thfb-hero-actions { flex-wrap:wrap; }
    .thfb-modal { max-width:100%; border-radius:12px; }
}

/* ── Video Button ────────────────────────────────────────────── */
.thfb-video-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ff3b3b 0%, #cc0000 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: all .15s ease;
    box-shadow: 0 2px 8px rgba(204,0,0,.30);
    flex-shrink: 0;
}
.thfb-video-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(204,0,0,.40);
    background: linear-gradient(135deg, #ff1a1a 0%, #aa0000 100%);
    color: #fff;
}
.thfb-video-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    font-size: 9px;
    line-height: 1;
    flex-shrink: 0;
}

/* ── Video Modal ─────────────────────────────────────────────── */
.thfb-video-modal-inner {
    max-width: 800px !important;
    padding: 0;
}
.thfb-video-modal-inner .thfb-modal-header {
    padding: 16px 20px;
}
.thfb-video-wrap {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    background: #000;
}
.thfb-video-wrap iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: none;
}



/* ── Field label row (label + Select All button side by side) ── */
.thfb-field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.thfb-field-label-row .thfb-field-label {
    margin: 0;
}

/* ── Select All button ───────────────────────────────────────── */
.thfb-select-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--thfb-primary-light, #eef0ff);
    background: var(--thfb-primary-light, #eef0ff);
    color: var(--thfb-primary, #2e3195);
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all .13s ease;
    line-height: 1;
    margin-bottom: 4px;
}
.thfb-select-all-btn:hover {
    background: var(--thfb-primary, #2e3195);
    color: #fff;
    border-color: var(--thfb-primary, #2e3195);
}
.thfb-select-all-btn.thfb-select-all-active {
    background: var(--thfb-warning-bg, #fff8ee);
    color: var(--thfb-warning, #e67e22);
    border-color: var(--thfb-warning, #e67e22);
}
.thfb-select-all-btn.thfb-select-all-active:hover {
    background: var(--thfb-warning, #e67e22);
    color: #fff;
}
