/**
 * THX FORM - COMPREHENSIVE DESIGN SYSTEM
 * Version: 1.1.0
 * Author: Thanh BC
 */

:root {
    --thx-primary: #3182ce;
    --thx-primary-hover: #2b6cb0;
    --thx-primary-light: #ebf8ff;
    --thx-success: #10b981;
    --thx-success-hover: #059669;
    --thx-danger: #ef4444;
    --thx-danger-hover: #dc2626;
    --thx-warning: #f59e0b;
    --thx-bg: #f8fafc;
    --thx-card-bg: #ffffff;
    --thx-border: #e2e8f0;
    --thx-border-hover: #cbd5e1;
    --thx-text: #1e293b;
    --thx-text-muted: #64748b;
    --thx-radius-sm: 8px;
    --thx-radius: 14px;
    --thx-radius-lg: 20px;
    --thx-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --thx-shadow-lg: 0 20px 35px -10px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   GLOBAL LAYOUT & RESET
   ========================================================================== */
.thx-form-wrapper-global, .thx-form-dashboard-wrapper {
    background: var(--thx-bg);
    min-height: 100vh;
    padding-bottom: 60px;
    font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--thx-text);
    box-sizing: border-box;
}

.thx-form-wrapper-global *, .thx-form-dashboard-wrapper * {
    box-sizing: border-box;
}

/* Sticky Sub-Header */
.thx-sub-header {
    background: #ffffff;
    border-bottom: 1px solid var(--thx-border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.thx-container-fluid {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thx-brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 8px;
}

.thx-brand-title {
    font-weight: 800;
    font-size: 19px;
    color: var(--thx-text);
    letter-spacing: -0.3px;
}

.thx-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Buttons */
.thx-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--thx-primary);
    color: #ffffff !important;
    padding: 10px 20px;
    border-radius: var(--thx-radius-sm);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(49, 130, 206, 0.2);
}

.thx-btn-primary:hover {
    background: var(--thx-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(49, 130, 206, 0.3);
}

.thx-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #ffffff;
    color: var(--thx-text);
    padding: 10px 18px;
    border-radius: var(--thx-radius-sm);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border: 1px solid var(--thx-border);
    cursor: pointer;
    transition: all 0.2s;
}

.thx-btn-secondary:hover {
    background: #f1f5f9;
    border-color: var(--thx-border-hover);
    color: var(--thx-text);
}

.thx-btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--thx-danger);
    color: #fff !important;
    padding: 8px 16px;
    border-radius: var(--thx-radius-sm);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.thx-btn-danger:hover {
    background: var(--thx-danger-hover);
}

.thx-mini-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: var(--thx-primary);
    transition: all 0.2s;
}

.thx-mini-btn.outline {
    background: transparent;
    color: var(--thx-text-muted);
    border: 1px solid var(--thx-border);
}

.thx-mini-btn:hover {
    background: var(--thx-primary-hover);
    color: #fff;
    transform: translateY(-1px);
}

.thx-mini-btn.outline:hover {
    background: #f1f5f9;
    color: var(--thx-text);
}

.thx-btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--thx-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #64748b;
    text-decoration: none;
    transition: all 0.18s ease;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.thx-btn-icon .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thx-btn-icon:hover:not(:disabled) {
    background: #eff6ff;
    color: var(--thx-primary);
    border-color: #93c5fd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.thx-btn-icon.danger:hover:not(:disabled) {
    color: var(--thx-danger);
    background: #fef2f2;
    border-color: #fecaca;
    box-shadow: 0 2px 4px rgba(239,68,68,0.1);
}

.thx-btn-icon:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #94a3b8;
}

/* ==========================================================================
   SINGLE FORM RENDERER UI
   ========================================================================== */
.survey-card {
    max-width: 780px;
    margin: 40px auto;
    background: var(--thx-card-bg);
    border-radius: var(--thx-radius);
    box-shadow: var(--thx-shadow);
    padding: 45px 40px;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

@media (max-width: 640px) {
    .survey-card {
        padding: 25px 18px;
        margin: 20px 12px;
        border-radius: 12px;
    }
}

.survey-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--thx-text);
    text-align: center;
    margin: 0 0 14px;
    line-height: 1.35;
    letter-spacing: -0.5px;
}

.survey-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--thx-text-muted);
    font-size: 13px;
    margin-bottom: 25px;
}

.thx-meta-divider {
    color: #cbd5e1;
}

.survey-desc {
    color: #475569;
    font-size: 15px;
    line-height: 1.65;
    margin-bottom: 35px;
    text-align: center;
    background: #f8fafc;
    padding: 16px 20px;
    border-radius: var(--thx-radius-sm);
    border-left: 4px solid var(--thx-primary);
}

/* Field Groups */
.thx-field-group {
    margin-bottom: 32px;
    position: relative;
}

.thx-field-header {
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 10px;
}

.thx-field-label {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--thx-text);
    line-height: 1.4;
}

.thx-req-star {
    color: var(--thx-danger);
    margin-left: 3px;
    font-weight: 700;
}

.thx-field-desc {
    font-size: 13px;
    color: var(--thx-text-muted);
    margin-top: 4px;
    line-height: 1.5;
}

.thx-field-instruction {
    font-size: 12px;
    color: var(--thx-text-muted);
    font-weight: 600;
    background: #f1f5f9;
    padding: 3px 9px;
    border-radius: 12px;
    white-space: nowrap;
}

/* Heading / Section Separator */
.thx-heading-section {
    padding: 20px 0 10px;
    margin: 35px 0 20px;
    border-top: 2px dashed var(--thx-border);
}

.thx-heading-section h3 {
    font-size: 20px;
    font-weight: 800;
    color: var(--thx-text);
    margin: 0 0 6px;
}

.thx-heading-section p {
    color: var(--thx-text-muted);
    font-size: 14px;
    margin: 0;
}

/* Option Cards (Radio & Checkbox) & Columns Grid */
.thx-options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.thx-options-list.thx-grid-1 {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.thx-options-list.thx-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.thx-options-list.thx-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 640px) {
    .thx-options-list.thx-grid-2,
    .thx-options-list.thx-grid-3 {
        grid-template-columns: 1fr;
    }
}

.thx-option-wrapper {
    border: 2px solid var(--thx-border);
    border-radius: 12px;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    overflow: hidden;
    position: relative;
}

.thx-option-wrapper:hover {
    border-color: var(--thx-border-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.thx-input-label {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    margin: 0;
    position: relative;
    z-index: 2;
    width: 100%;
}

.thx-input-label input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.thx-custom-indicator {
    width: 22px;
    height: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    margin-right: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    background: #ffffff;
}

.thx-input-label input[type="checkbox"] ~ .thx-label-content .thx-custom-indicator {
    border-radius: 6px;
}

/* Active State for Choices */
.thx-option-wrapper.is-selected,
.thx-option-wrapper.thx-row-voted {
    border-color: var(--thx-primary);
    background: #f0f9ff;
}

.thx-option-wrapper.is-selected .thx-custom-indicator,
.thx-option-wrapper.thx-row-voted .thx-custom-indicator {
    border-color: var(--thx-primary);
    background: var(--thx-primary);
}

.thx-option-wrapper.is-selected .thx-custom-indicator::after,
.thx-option-wrapper.thx-row-voted .thx-custom-indicator::after {
    content: '';
    display: block;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translateY(-1px);
}

.thx-option-wrapper.is-selected .thx-radio-text,
.thx-option-wrapper.thx-row-voted .thx-radio-text {
    color: var(--thx-primary);
    font-weight: 600;
}

/* Reverse Mode Priority Highlight */
.thx-option-wrapper.thx-row-priority {
    border-color: #2f855a !important;
    background: #f0fdf4 !important;
}

.thx-option-wrapper.thx-row-priority .thx-radio-text {
    color: #166534;
    font-weight: 600;
}

.thx-label-content {
    flex: 1;
    display: flex;
    align-items: center;
    width: 100%;
}

.thx-radio-text {
    font-size: 15px;
    color: #334155;
    font-weight: 500;
    transition: color 0.2s;
    flex: 1;
}

/* Info toggle */
.thx-info-btn {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--thx-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.thx-info-btn:hover, .thx-info-btn.active {
    background: #e2e8f0;
    color: var(--thx-text);
}

.thx-info-content {
    display: none;
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px dashed var(--thx-border);
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
}

.thx-info-content.active {
    display: block;
    animation: thxSlideDown 0.25s ease;
}

.thx-info-content img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
}

/* Progress bar for Survey Live Results */
.thx-progress-bg {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: rgba(49, 130, 206, 0.12);
    width: 0%;
    z-index: 1;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    border-right: 2px solid rgba(49, 130, 206, 0.4);
}

.thx-percent-text {
    margin-left: 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--thx-primary);
    display: none;
}

.show-results .thx-percent-text {
    display: inline-block;
}

/* White Vote Section */
.thx-white-vote-section .thx-option-wrapper {
    border: 2px dashed #cbd5e1;
    background: #fafaf9;
}

.thx-white-vote-section .thx-option-wrapper.is-selected {
    border-color: var(--thx-primary);
    background: #f0f9ff;
}

/* Dual Login Container */
.thx-login-wrap {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-radius: var(--thx-radius);
    padding: 35px;
    box-shadow: var(--thx-shadow);
    margin-bottom: 30px;
}

.thx-login-row {
    display: flex;
    gap: 30px;
    align-items: stretch;
}

.thx-login-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.thx-login-col h3 {
    margin: 0 0 8px;
    font-size: 19px;
    font-weight: 800;
    color: var(--thx-text);
}

.thx-login-col p {
    color: var(--thx-text-muted);
    font-size: 14px;
    margin: 0 0 20px;
}

.thx-auth-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0 10px;
}

.thx-auth-divider::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: var(--thx-border);
}

.thx-auth-or {
    background: #ffffff;
    padding: 6px 14px;
    border: 1px solid var(--thx-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    color: var(--thx-text-muted);
    position: relative;
    z-index: 2;
}

@media (max-width: 768px) {
    .thx-login-row {
        flex-direction: column;
        gap: 25px;
    }
    .thx-auth-divider::before {
        width: 100%;
        height: 1px;
        top: 50%;
        left: 0;
    }
}

/* Text, Email, Phone, Number, Date, Select Inputs */
.thx-text-input, .thx-select-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--thx-border);
    border-radius: 10px;
    font-size: 15px;
    color: var(--thx-text);
    font-family: inherit;
    transition: all 0.2s;
    background: #f8fafc;
}

.thx-text-input:focus, .thx-select-input:focus {
    outline: none;
    border-color: var(--thx-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(49, 130, 206, 0.12);
}

textarea.thx-text-input {
    min-height: 110px;
    resize: vertical;
}

/* Rating Stars / Point Selector */
.thx-rating-container {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    background: #f8fafc;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--thx-border);
}

.thx-rating-star {
    font-size: 28px;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.18s;
}

.thx-rating-star:hover,
.thx-rating-star.is-active {
    color: #f59e0b;
    transform: scale(1.15);
}

/* Submit Action Button */
.thx-submit-btn {
    background: var(--thx-primary);
    color: #ffffff;
    padding: 16px 30px;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(49, 130, 206, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.thx-submit-btn:hover {
    background: var(--thx-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(49, 130, 206, 0.4);
}

.thx-submit-btn:active {
    transform: translateY(0);
}

/* Alert boxes */
.thx-alert {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.thx-alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.thx-alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.thx-alert-success {
    background: #f0fdf4;
    color: #166534;
    border-left: 4px solid #22c55e;
}

.thx-alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* ==========================================================================
   DASHBOARD & FORM BUILDER UI
   ========================================================================== */
/* Đảm bảo Header trang web và Menu THX App Launcher luôn luôn nổi trên cùng */
header,
#masthead,
#site-header,
.site-header,
.main-navigation,
#site-navigation,
.thx-membar,
.thx-al-menu-item,
.thx-al-submenu {
    z-index: 999999 !important;
}

.thx-form-dashboard-wrapper {
    position: relative;
    z-index: 1; /* Cố định stacking context nội bộ của form ở tầng cơ bản */
}

.thx-dashboard-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 20px;
}

.thx-dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.thx-dash-header h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--thx-text);
    margin: 0;
}

.thx-dash-header p {
    color: var(--thx-text-muted);
    font-size: 14px;
    margin: 4px 0 0;
}

/* ==========================================================================
   DASHBOARD 2-COLUMN SIDEBAR REAL-TIME FILTER LAYOUT
   ========================================================================== */
.thx-dash-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .thx-dash-layout {
        grid-template-columns: 1fr;
    }
}

/* Sidebar Filter Container */
.thx-dash-sidebar {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-radius: var(--thx-radius);
    padding: 18px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    position: sticky;
    top: 80px;
}

/* Sidebar Search */
.thx-sidebar-search {
    position: relative;
    margin-bottom: 18px;
}

.thx-sidebar-search .dashicons-search {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 16px;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.thx-sidebar-search input {
    width: 100%;
    padding: 8px 30px 8px 32px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.thx-sidebar-search input:focus {
    background: #ffffff;
    border-color: var(--thx-primary);
    box-shadow: 0 0 0 3px rgba(47, 133, 90, 0.12);
    outline: none;
}

.thx-sidebar-search #thx-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
}

.thx-sidebar-search #thx-search-clear:hover {
    color: #ef4444;
}

/* Sidebar Section & Headings */
.thx-sidebar-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.thx-sidebar-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.thx-sidebar-heading {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
    margin-bottom: 10px;
    padding-left: 4px;
}

/* Sidebar Filter Nav */
.thx-filter-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.thx-filter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    color: #475569;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
}

.thx-filter-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.thx-filter-item.active {
    background: #f0fdf4;
    color: #166534;
    font-weight: 700;
}

.thx-filter-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.thx-filter-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.thx-filter-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thx-filter-count {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 12px;
    background: #f1f5f9;
    color: #64748b;
}

.thx-filter-item.active .thx-filter-count {
    background: #bbf7d0;
    color: #14532d;
}

/* Status & Context Filter Chips */
.thx-status-filter-chips,
.thx-context-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.thx-filter-chip {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.18s ease;
}

.thx-filter-chip:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.thx-filter-chip.active {
    background: #1e293b;
    border-color: #1e293b;
    color: #ffffff;
}

/* Main Dashboard Canvas & Active Status Bar */
.thx-dash-main {
    min-width: 0;
}

.thx-filter-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #475569;
}

.thx-btn-link {
    background: none;
    border: none;
    color: #ef4444;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

.thx-btn-link:hover {
    text-decoration: underline;
}

.thx-empty-state {
    text-align: center;
    padding: 50px 20px;
    background: #ffffff;
    border-radius: var(--thx-radius);
    border: 2px dashed #cbd5e1;
}

.thx-dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* Form Card in Dashboard */
.thx-form-card {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.thx-form-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
}

.thx-form-card:hover .thx-card-cover-img {
    transform: scale(1.05);
}

.thx-card-header {
    padding: 12px 18px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafaf9;
    flex-wrap: wrap;
    gap: 8px;
}

.thx-type-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.thx-source-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.thx-card-body {
    padding: 18px 20px;
    flex: 1;
}

.thx-card-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.4;
    color: var(--thx-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.thx-card-title a {
    text-decoration: none;
    color: inherit;
}

.thx-card-title a:hover {
    color: var(--thx-primary);
}

.thx-card-meta {
    font-size: 12px;
    color: var(--thx-text-muted);
}

.thx-card-footer {
    padding: 12px 18px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thx-stats {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.thx-actions {
    display: flex;
    gap: 6px;
}

/* ==========================================================================
   ERGONOMIC FORM BUILDER TOPBAR & TABS (FLOATING PANEL)
   ========================================================================== */
.thx-builder-topbar {
    position: sticky;
    top: 10px;
    z-index: 20; /* Luôn thấp hơn Header Menu và THX App Launcher (z-index: 999999) */
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 20px;
    margin: 0 0 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
    transition: top 0.2s ease, box-shadow 0.2s ease;
}

/* Tương thích khoảng cách khi có WordPress Admin Bar */
body.admin-bar .thx-builder-topbar {
    top: 42px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .thx-builder-topbar {
        top: 56px;
    }
}

@media screen and (max-width: 600px) {
    body.admin-bar .thx-builder-topbar {
        top: 10px;
    }
}

.thx-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.thx-btn-back {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0;
}

.thx-btn-back:hover {
    background: #e2e8f0;
    color: var(--thx-primary);
}

.thx-topbar-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.thx-topbar-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.thx-topbar-title {
    font-size: 16px;
    font-weight: 800;
    margin: 0;
    color: var(--thx-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.thx-status-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.thx-status-pill.open {
    background: #ecfdf5;
    color: #065f46;
}

.thx-status-pill.locked {
    background: #fef2f2;
    color: #991b1b;
}

.thx-topbar-subtitle {
    font-size: 12px;
    color: var(--thx-text-muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thx-builder-tabs {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.thx-tab-btn {
    padding: 7px 16px;
    border-radius: 7px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.thx-tab-btn:hover {
    color: var(--thx-text);
}

.thx-tab-btn.active {
    background: #ffffff;
    color: var(--thx-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.thx-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

@media (max-width: 960px) {
    .thx-builder-topbar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 16px;
    }
    .thx-topbar-left {
        width: 100%;
    }
    .thx-topbar-title {
        max-width: 220px;
    }
}

.thx-tab-pane {
    display: none;
}

.thx-tab-pane.active {
    display: block;
    animation: thxSlideDown 0.22s ease;
}

/* ==========================================================================
   FORM BUILDER CANVAS & CARDS
   ========================================================================== */
.thx-editor-container {
    background: transparent;
    padding: 0;
    margin-bottom: 40px;
    border: none;
    box-shadow: none;
}

/* Builder Form Type & Quick Template Section */
.thx-builder-type-section {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-radius: var(--thx-radius);
    padding: 22px 24px;
    margin-bottom: 24px;
    box-shadow: var(--thx-shadow);
}

.thx-type-selector-header {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid #f1f5f9;
}

.thx-type-pills-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.thx-type-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.thx-type-pill:hover {
    border-color: #94a3b8;
    background: #f1f5f9;
    transform: translateY(-1px);
}

.thx-type-pill.active {
    background: #f0fdf4;
    border-color: var(--thx-primary);
    color: var(--thx-primary);
    box-shadow: 0 2px 8px rgba(47, 133, 90, 0.15);
}

.thx-pill-icon {
    font-size: 16px;
}

.thx-pill-check {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: var(--thx-primary);
    margin-left: 2px;
}

.thx-builder-templates-wrap {
    background: #fcfcfb;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 18px 20px;
}

.thx-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 10px;
}

.thx-template-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.thx-template-card:hover {
    border-color: var(--thx-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(47, 133, 90, 0.12);
}

.thx-template-card.active {
    border-color: var(--thx-primary);
    background: #f0fdf4;
    border-width: 2px;
}

.thx-tpl-icon {
    font-size: 26px;
    flex-shrink: 0;
    background: #f8fafc;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thx-tpl-info h4 {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}

.thx-tpl-info p {
    margin: 0;
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
}

.thx-builder-meta-card {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-radius: var(--thx-radius);
    padding: 22px 26px;
    margin-bottom: 22px;
    box-shadow: var(--thx-shadow);
}

.thx-palette-section {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-radius: var(--thx-radius);
    padding: 20px 24px;
    margin-bottom: 22px;
    box-shadow: var(--thx-shadow);
}

.thx-palette-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 10px;
}

.thx-palette-group {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
}

.thx-palette-group-title {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
}

.thx-palette-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.thx-palette-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.18s;
}

.thx-palette-btn.choice:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(59, 130, 246, 0.15);
}

.thx-palette-btn.text:hover {
    border-color: #10b981;
    background: #ecfdf5;
    color: #047857;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(16, 185, 129, 0.15);
}

.thx-palette-btn.layout:hover {
    border-color: #8b5cf6;
    background: #f5f3ff;
    color: #6d28d9;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(139, 92, 246, 0.15);
}

.thx-builder-canvas {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: var(--thx-radius);
    padding: 24px;
    min-height: 250px;
}

.thx-field-editor {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-left: 4px solid var(--thx-primary);
    border-radius: 12px;
    margin-bottom: 18px;
    padding: 20px 22px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.03);
    transition: all 0.2s;
}

.thx-field-editor:hover {
    border-color: #cbd5e1;
    border-left-color: var(--thx-primary);
    box-shadow: 0 5px 12px rgba(0,0,0,0.06);
}

.thx-field-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.thx-field-type-badge {
    background: #ebf8ff;
    color: #2b6cb0;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.thx-options-editor {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--thx-border);
}

.thx-chip-toggle {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    transition: all 0.18s;
    user-select: none;
    line-height: 1.4;
}

.thx-chip-toggle:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.thx-chip-toggle.active {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.12);
}

.thx-option-row-edit {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    transition: all 0.18s;
}

.thx-option-row-edit:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.thx-option-row-edit-main {
    display: flex;
    gap: 8px;
    align-items: center;
}

.thx-option-row-edit-main input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    background: #ffffff;
}

.thx-option-row-edit-main input:focus {
    outline: none;
    border-color: var(--thx-primary);
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.thx-imdb-live-card {
    transition: all 0.2s;
}

.thx-imdb-live-card:hover {
    border-color: #f59e0b;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
}

/* ==========================================================================
   SETTINGS TAB - 5 CATEGORIZED PANELS
   ========================================================================== */
.thx-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
}

.thx-settings-card {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-radius: var(--thx-radius);
    overflow: hidden;
    box-shadow: var(--thx-shadow);
    display: flex;
    flex-direction: column;
}

.thx-settings-card.full-width {
    grid-column: 1 / -1;
}

.thx-settings-card-header {
    background: #f8fafc;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.thx-settings-card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--thx-text);
}

.thx-settings-card-body {
    padding: 20px 22px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.thx-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    user-select: none;
}

.thx-switch-label input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--thx-primary);
    cursor: pointer;
}

.thx-hint-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #1e40af;
    line-height: 1.5;
}

/* ==========================================================================
   ERGONOMIC FLOATING / STICKY FOOTER
   ========================================================================== */
.thx-builder-footer {
    background: #ffffff;
    border: 1px solid var(--thx-border);
    border-radius: var(--thx-radius);
    padding: 16px 24px;
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--thx-shadow);
}

.thx-footer-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Responses / Entries Table */
.thx-table-responsive {
    width: 100%;
    overflow-x: auto;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--thx-border);
    box-shadow: var(--thx-shadow);
}

.thx-entries-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.thx-entries-table th {
    background: #f8fafc;
    color: var(--thx-text);
    font-weight: 700;
    text-align: left;
    padding: 14px 18px;
    border-bottom: 2px solid var(--thx-border);
}

.thx-entries-table td {
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
}

.thx-entries-table tr:hover td {
    background: #f8fafc;
}

/* Detail Modal */
.thx-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.thx-modal-card {
    background: #ffffff;
    border-radius: var(--thx-radius);
    max-width: 650px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--thx-shadow-lg);
    padding: 30px;
    position: relative;
    animation: thxPopIn 0.25s ease;
}

.thx-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: var(--thx-text-muted);
}

.thx-modal-close:hover {
    background: #e2e8f0;
    color: var(--thx-text);
}

/* Animations */
@keyframes thxSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes thxPopIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
