/**
 * Quiz Flow Editor - SVG Visual Editor Styles
 */

/* ===========================================
   MAIN CONTAINER
   =========================================== */

.quiz-flow-editor {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    background: var(--bg-primary);
    border-radius: 16px;
    overflow: hidden;
}

/* ===========================================
   TOOLBAR
   =========================================== */

.flow-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.flow-toolbar-left,
.flow-toolbar-center,
.flow-toolbar-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

.flow-zoom-level {
    font-size: 0.875rem;
    color: var(--text-muted);
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

/* ===========================================
   MAIN CONTENT (Split View)
   =========================================== */

.flow-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left: Canvas */
.flow-canvas-container {
    flex: 1;
    position: relative;
    background: transparent;
    overflow: hidden;
}

.flow-svg-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Right: Editor Panel */
.flow-editor-panel {
    width: 30vw;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
}

.flow-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.flow-panel-empty p {
    margin: 0.5rem 0 0;
    color: var(--text-primary);
}

/* ===========================================
   SVG NODES
   =========================================== */

.flow-node {
    cursor: move;
    transition: transform 0.1s ease;
}

.flow-node:hover .flow-node-bg {
    filter: brightness(1.1);
}

.flow-node-bg {
    transition: filter 0.2s ease, stroke 0.2s ease;
}

/* ===========================================
   SVG CONNECTIONS
   =========================================== */

.flow-connection {
    transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.flow-connection:hover {
    stroke-width: 3 !important;
    cursor: pointer;
}

.flow-connection-label {
    pointer-events: none;
    user-select: none;
}

/* ===========================================
   MINIMAP
   =========================================== */

.flow-minimap {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 0.5rem;
}

#flow-minimap-canvas {
    display: block;
    border-radius: 2px;
}

/* ===========================================
   STATUS BAR
   =========================================== */

.flow-status-bar {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-main);
    flex-shrink: 0;
}

.flow-status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flow-status-item i {
    color: var(--accent-primary);
}

.flow-status-item span {
    font-weight: 600;
    color: var(--text-primary);
}

/* ===========================================
   STEP EDITOR PANEL
   =========================================== */

.flow-step-editor {
    padding: 1.5rem;
}

.flow-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.flow-step-header .btn-danger{
    background:transparent;
    color:var(--danger)
}
.flow-step-header h3 {
    margin: 0;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flow-form-group {
    margin-bottom: 1.25rem;
}

.flow-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.flow-form-group input,
.flow-form-group select,
.flow-form-group textarea {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 16px;
}

.flow-form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.flow-form-group .form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.flow-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.flow-checkbox input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.flow-checkbox label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.75rem;
}

/* ===========================================
   SECTIONS
   =========================================== */

.flow-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.flow-section .btn{
    width:-webkit-fill-available;
}

.flow-section h4 {
    margin: 0 0 1rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.flow-section h4 i {
    color: var(--accent-primary);
}

/* ===========================================
   AUDIO ACTIONS
   =========================================== */

.flow-audio-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.flow-audio-actions .btn {
    flex: 1;
    min-width: 80px;
}

/* ===========================================
   OPTIONS & FIELDS LISTS
   =========================================== */

.flow-options-list,
.flow-fields-list {
    margin-top: 0.5rem;
}

.flow-options-list label,
.flow-fields-list label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.flow-option-item,
.flow-field-item {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.flow-option-item input,
.flow-field-item input,
.flow-field-item select {
    flex: 1;
}

.flow-option-item .btn,
.flow-field-item .btn {
    flex-shrink: 0;
}

/* ===========================================
   PANEL FOOTER
   =========================================== */

.flow-panel-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.flow-panel-footer .btn {
    width: 100%;
}

/* ===========================================
   EMPTY STATE
   =========================================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state i {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin: 0.5rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.empty-state small {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 1024px) {
    .flow-editor-panel {
        width: 300px;
    }

    .flow-toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .flow-toolbar-center {
        order: 3;
        flex: 1 0 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .quiz-flow-editor {
        height: calc(100vh - 100px);
        min-height: auto;
    }

    /* Toolbar - Make compact and scrollable */
    .flow-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.375rem;
        padding: 0.5rem 0.75rem;
        scrollbar-width: none; /* Firefox */
        display: flex;
        flex-direction: row;
        align-items: center;
    }

    .flow-toolbar::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }

    .flow-toolbar-left,
    .flow-toolbar-center,
    .flow-toolbar-right {
        gap: 0.375rem;
        flex-shrink: 0;
    }

    .flow-toolbar .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    .flow-toolbar .btn i {
        font-size: 0.875rem;
    }

    .flow-zoom-level {
        font-size: 0.8125rem;
        min-width: 40px;
    }

    .toolbar-separator {
        display: none;
    }

    /* Main Content - Stack vertically with better proportions */
    .flow-main-content {
        flex-direction: column;
    }

    .flow-canvas-container {
        min-height: 50vh;
        flex: 1;
    }

    /* Editor Panel - Resizable with toggle */
    .flow-editor-panel {
        width: 100%;
        max-height: 50vh;
        min-height: 200px;
        border-left: none;
        border-top: 2px solid var(--border-color);
        position: relative;
    }

    .flow-editor-panel::before {
        content: '';
        position: absolute;
        top: -6px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--border-color);
        border-radius: 2px;
        cursor: grab;
    }

    .flow-step-editor {
        padding: 0.75rem;
    }

    .flow-step-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .flow-step-header h3 {
        font-size: 1rem;
    }

    /* Editor Cards - Make more touch-friendly */
    .editor-card {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .editor-card-icon {
        width: 36px;
        height: 36px;
        font-size: 1.125rem;
    }

    .editor-card-title {
        font-size: 0.875rem;
    }

    .editor-card-preview {
        font-size: 0.8125rem;
    }

    /* Form inputs - Larger for mobile */
    .editor-input-title,
    .editor-select-type,
    .editor-select {
        padding: 0.75rem 1rem;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .editor-btn-primary,
    .editor-btn-secondary {
        padding: 0.875rem 1.25rem;
        font-size: 0.9375rem;
    }

    /* Status Bar - Simplify for mobile */
    .flow-status-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    .flow-status-item {
        gap: 0.375rem;
    }

    .flow-status-item i {
        font-size: 0.875rem;
    }

    /* Minimap - Hide on mobile for more canvas space */
    .flow-minimap {
        display: none;
    }

    /* Modal adjustments */
    .quiz-modal-dialog {
        width: 95%;
        max-width: none;
        max-height: 90vh;
        margin: 1rem;
    }

    .quiz-modal-header,
    .quiz-modal-body,
    .quiz-modal-footer {
        padding: 1rem;
    }

    .quiz-modal-header h3 {
        font-size: 1.125rem;
    }

    /* Type selector - Stack on mobile */
    .type-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .type-card {
        padding: 0.75rem 0.5rem;
    }

    .type-icon i {
        font-size: 1.5rem;
    }

    .type-name {
        font-size: 0.8125rem;
    }

    .type-desc {
        font-size: 0.6875rem;
    }

    /* Options/Fields lists */
    .option-row,
    .field-row {
        padding: 0.75rem 0.5rem;
        gap: 0.375rem;
    }

    .option-input,
    .field-label-input {
        padding: 0.625rem 0.75rem;
        font-size: 16px;
    }

    .option-delete,
    .field-delete {
        width: 36px;
        height: 36px;
    }

    /* Audio options */
    .audio-option-card {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .option-icon {
        width: 40px;
        height: 40px;
    }

    .option-icon i {
        font-size: 1.25rem;
    }

    .option-title {
        font-size: 0.875rem;
    }

    .option-desc {
        font-size: 0.75rem;
    }

    /* Audio actions - Stack vertically */
    .audio-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-btn-action {
        padding: 0.75rem 1rem;
    }

    /* Form groups */
    .flow-form-group {
        margin-bottom: 1rem;
    }

    .flow-form-group input,
    .flow-form-group select,
    .flow-form-group textarea {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .quiz-flow-editor {
        height: fit-content;
        border-radius: 8px;
    }

    /* Toolbar - Even more compact */
    .flow-toolbar {
        padding: 0.375rem 0.5rem;
        display: flex;
        flex-direction: row;
        align-items: center;
    }

    .flow-toolbar .btn {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }

    .flow-toolbar .btn span {
        display: none; /* Show only icons */
    }

    .flow-zoom-level {
        font-size: 0.75rem;
        min-width: 35px;
    }

    /* Editor Panel */
    .flow-editor-panel {
        max-height: 60vh;
    }

    .flow-step-editor {
        padding: 0.5rem;
    }

    .editor-card {
        padding: 0.75rem 0.625rem;
        border-radius: 12px;
    }

    .editor-card-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .editor-card-title {
        font-size: 0.8125rem;
    }

    .editor-badge {
        font-size: 10px;
        padding: 0.0625rem 0.375rem;
    }

    /* Status Bar - More compact */
    .flow-status-bar {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
        gap: 0.375rem;
    }

    /* Type selector - Single column on very small screens */
    .type-selector {
        grid-template-columns: 1fr;
    }

    /* Modal footer - Stack buttons */
    .quiz-modal-footer {
        flex-direction: column-reverse;
    }

    .quiz-modal-footer .btn {
        width: 100%;
    }

    /* Conditional fields - Stack on small screens */
    .conditional-fields {
        grid-template-columns: 1fr;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .quiz-flow-editor {
        height: calc(100vh - 60px);
    }

    .flow-canvas-container {
        min-height: 60vh;
    }

    .flow-editor-panel {
        max-height: 40vh;
    }

    .flow-status-bar {
        display: none; /* Save space in landscape */
    }
}

/* Touch-friendly improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .flow-node {
        cursor: pointer;
    }

    .editor-card.clickable {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
    }

    .btn {
        min-height: 44px; /* iOS recommended touch target */
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
    }

    /* Improve scroll behavior */
    .flow-editor-panel,
    .quiz-modal-body,
    .flow-toolbar {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Remove hover effects on touch devices */
    .flow-node:hover .flow-node-bg,
    .editor-card.clickable:hover {
        filter: none;
        transform: none;
        box-shadow: none;
    }

    /* Active states for touch */
    .flow-node:active,
    .editor-card.clickable:active {
        opacity: 0.7;
        transition: opacity 0.1s ease;
    }

    .btn:active {
        transform: scale(0.96);
        transition: transform 0.1s ease;
    }
}

/* ===========================================
   ANIMATIONS
   =========================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flow-step-editor {
    animation: fadeIn 0.2s ease;
}

/* ===========================================
   NODE ICONS (Font Awesome Unicode)
   =========================================== */

.flow-node-audio-icon {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===========================================
   CONDITIONAL LOGIC MODAL
   =========================================== */

.quiz-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.quiz-modal-dialog {
    background: var(--bg-secondary);
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.quiz-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.quiz-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.quiz-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s ease;
}

.quiz-modal-close:hover {
    color: var(--text-primary);
}

.quiz-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.quiz-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.conditional-help {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.conditional-help i {
    color: #3b82f6;
    font-size: 1.25rem;
}

.conditional-help p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.conditional-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.conditional-row {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
}

.conditional-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.conditional-index {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.875rem;
}


.conditional-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.conditional-field {
    display: flex;
    flex-direction: column;
}

.conditional-field label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.conditional-field .form-control {
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.conditional-field .form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Responsive modal */
@media (max-width: 768px) {
    .quiz-modal-dialog {
        width: 95%;
        max-height: 90vh;
    }

    .conditional-fields {
        grid-template-columns: 1fr;
    }
}

/* ===========================================
   QUIZ VARIABLES EDITOR
   =========================================== */

.quiz-variables-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
    padding: 1.5rem;
    overflow-y: auto;
    border-radius: 26px;
}

.variables-header {
    margin-bottom: 1.5rem;
}

.variables-header h3 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    flex-direction: row;
}

.variables-header .help-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Toolbar */
.variables-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.variables-search {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.variables-search i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.variables-search input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    color: var(--text-primary);
    font-size: 16px;
}

.variables-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Variables List */
.variables-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.variable-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.variable-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-primary);
}

.variable-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.variable-info {
    flex: 1;
}

.variable-name-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.variable-name-badge i {
    color: var(--accent-primary);
}

.variable-name-badge code {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.variable-type {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-main);
    background: var(--bg-dark);
    padding: 0.25rem 0.5rem;
    border-radius: 16px;
}

.variable-type i {
    font-size: 0.7rem;
}

.variable-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.variable-card-body {
    padding: 1rem;
}

.variable-detail {
    margin-bottom: 0.75rem;
}

.variable-detail:last-child {
    margin-bottom: 0;
}

.variable-detail label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.variable-detail p {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.variable-detail code {
    display: inline-block;
    background: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    color: var(--accent-primary);
}

.variable-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.variable-badge.required {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.variable-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.option-tag {
    display: inline-block;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    color: var(--text-primary);
}

/* Usage Info Panel */
.usage-info-panel {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.usage-info-panel h4 {
    margin: 0 0 1rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.usage-info-panel h4 i {
    color: #3b82f6;
}

.usage-examples {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.usage-example {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.usage-example strong {
    color: var(--text-primary);
    font-size: 0.875rem;
}

.usage-example code {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
}

.available-variables {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.var-tag {
    display: inline-block;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 600;
}

/* Variable Editor Modal */
.variable-help-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.variable-help-banner i {
    color: #3b82f6;
    font-size: 1.25rem;
}

.variable-help-banner p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.option-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.option-input-row .form-control {
    flex: 1;
}

.option-input-row .btn {
    flex-shrink: 0;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-wrapper input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.checkbox-wrapper label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
}

.required {
    color: #ef4444;
}

/* Responsive Variables Editor */
@media (max-width: 1024px) {
    .variables-list {
        grid-template-columns: 1fr;
    }

    .variables-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .variables-search {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .quiz-variables-editor {
        padding: 1rem;
    }
}

/* ===========================================
   QUIZ PREVIEW
   =========================================== */

.quiz-preview {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
    padding: 1.5rem;
    overflow-y: auto;
    border-radius: 26px;
}

.preview-header {
    margin-bottom: 1.5rem;
}

.preview-header h3 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

/* Preview Toolbar */
.preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.preview-device-selector {
    display: flex;
    gap: 0.5rem;
}

.device-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-radius: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.25rem;
}

.device-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.device-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--accent);
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

/* Preview Viewport */
.preview-viewport {
    flex: 1;
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    transition: all 0.3s ease;
    width: 100%;
}

.preview-viewport #quiz-preview-content{
    width:-webkit-fill-available;
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
}

.preview-viewport.desktop {
    max-width: 100%;
}

.preview-viewport.tablet {
    max-width: 768px;
    margin: 0 auto;
}

.preview-viewport.mobile {
    max-width: 375px;
    margin: 0 auto;
}

.preview-sandbox {
    width: 100%;
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 2.5rem;
    border: solid 1px var(--border);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.preview-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.preview-empty i {
    margin-bottom: 1rem;
    opacity: 0.4;
}

.preview-empty p {
    margin: 1rem 0 0.5rem;
    font-size: 1.125rem;
    color: var(--text-muted);
}

.preview-empty small {
    color: var(--text-muted);
}

/* Step Container */
.step-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Audio Player Preview */
.audio-player-preview {
    border: none;
    border-radius: 40px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.audio-player-preview > i {
    font-size: 1.5rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.audio-script {
    flex: 1;
}

.audio-script strong {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.audio-script p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.btn-play-audio {
    background:var(--accent);
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s ease;
}

.btn-play-audio:hover {
    background: var(--accent);
}

/* Step Question */
.step-question h2 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    color: var(--text-main);
}

/* Question Inputs */
.question-input {
    margin-bottom: 1.5rem;
}

/* Radio & Checkbox Groups */
.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-option,
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option:hover,
.checkbox-option:hover {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.05);
}

.radio-option input[type="radio"],
.checkbox-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.radio-label,
.checkbox-label {
    font-size: 1rem;
    color: #1f2937;
}

/* Rating Stars */
.rating-stars {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem 0;
}

.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 2rem;
    color: #d1d5db;
    transition: all 0.2s ease;
    padding: 0.25rem;
}

.star-btn:hover,
.star-btn.selected {
    color: #fbbf24;
    transform: scale(1.1);
}

/* Scale Slider */
.scale-slider {
    padding: 1.5rem;
    text-align: center;
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #6b7280;
}

.slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #3b82f6 0%, #3b82f6 50%, #e5e7eb 50%, #e5e7eb 100%);
    outline: none;
    margin-bottom: 1rem;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: none;
}

.scale-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* Text Inputs */
.text-input,
.textarea-input,
.number-input,
.date-input {
    width: 100%;
    padding: 0.875rem;
    border: solid 1px var(--border);
    border-radius: 26px;
    font-size: 16px;
    color: var(--text-main);
    transition: border-color 0.2s ease;
    background: var(--bg-tertiary);
}

.text-input:focus,
.textarea-input:focus,
.number-input:focus,
.date-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.textarea-input {
    resize: vertical;
    font-family: inherit;
}

/* Data Collection Fields */
.data-collection-fields {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #e5e7eb;
}

.data-collection-fields h4 {
    margin: 0 0 1.5rem;
    font-size: 1.125rem;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-group {
    margin-bottom: 1.25rem;
}

.field-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
}

/* Step Actions */
.step-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 1rem;
}

.step-actions .btn {
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Preview Messages */
.preview-message {
    text-align: center;
    padding: 2rem;
}

.preview-message i {
    font-size: 3rem;
    color: #3b82f6;
    margin-bottom: 1rem;
}

.preview-message p {
    font-size: 1.125rem;
    color: #374151;
    margin: 0;
}

.preview-end {
    text-align: center;
    padding: 3rem 2rem;
}

.preview-end i {
    font-size: 4rem;
    color: #10b981;
    margin-bottom: 1.5rem;
}

.preview-end h3 {
    margin: 0 0 1rem;
    font-size: 2rem;
    color: #1f2937;
}

.preview-end p {
    font-size: 1.125rem;
    color: #6b7280;
    margin: 0;
}

/* Variable Placeholder */
.var-placeholder {
    color: #3b82f6;
    font-style: normal;
    background: rgba(59, 130, 246, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
}

/* Preview Info Panel */
.preview-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.info-panel {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.info-item i {
    color: var(--accent-primary);
}

.info-item span {
    font-weight: 600;
    color: var(--text-primary);
}

/* Responsive Preview */
@media (max-width: 1024px) {
    .preview-viewport.desktop {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .quiz-preview {
        padding: 1rem;
    }

    .preview-viewport {
        padding: 1rem;
    }

    .preview-sandbox {
        padding: 1.5rem;
    }

    .preview-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .preview-device-selector {
        justify-content: center;
    }

    .preview-actions {
        flex-direction: column;
    }

    .info-panel {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .step-question h2 {
        font-size: 1.25rem;
    }

    .audio-player-preview {
        flex-direction: column;
        text-align: center;
    }
}

/* ===========================================
   VIEW MODE TABS
   =========================================== */

.flow-view-tabs {
    display: flex;
    gap: 0;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 0 1rem;
    flex-shrink: 0;
}

.flow-view-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flow-view-tab:hover {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.flow-view-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    font-weight: 600;
}

.flow-view-tab i {
    font-size: 1rem;
}

/* ===========================================
   VIEW PANES
   =========================================== */

.flow-view-pane {
    display: none;
    flex: 1;
    overflow: hidden;
}

.flow-view-pane.active {
    display: flex !important;
}

#view-graphic {
    flex-direction: row;
}

#view-json {
    flex-direction: column;
}

/* ===========================================
   JSON EDITOR
   =========================================== */

.json-editor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    background: var(--bg-main);
}

.json-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.json-status {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: 26px;
    font-size: 11px;
    font-weight: 500;
}

.json-status.valid {
    background: var(--accent);
    color: var(--text-secondary);
}

.json-status.invalid {
    background: #f8d7da;
    color: #721c24;
}

.json-status.modified {
    color: var(--warning);
}

.json-editor-textarea {
    flex: 1;
    width: 100%;
    padding: 1rem;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background: var(--bg-main);
    color: var(--text-main);
    border: none;
    resize: none;
    outline: none;
    tab-size: 2;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

.json-editor-textarea:focus {
    background: var(--bg-panel);
}

.json-editor-info {
    padding: 0.75rem 1rem;
    background: var(--bg-lighter);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.json-editor-info i {
    color: var(--info);
}

/* JSON Syntax Highlighting (Basic) */
.json-editor-textarea::selection {
    background: rgba(59, 130, 246, 0.3);
}

/* ===========================================
   PREVIEW QUIZ VIEW
   =========================================== */

#view-preview {
    flex-direction: column;
}

.quiz-preview-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-main);
}

.quiz-preview-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.preview-status {
    margin-left: auto;
    padding: 0.375rem 0.875rem;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.preview-status.running {
    color: var(--accent);
}

.preview-status.completed {
    color: var(--success-text);
}

.quiz-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-empty {
    text-align: center;
    max-width: 500px;
    color: var(--text-muted);
}

.preview-empty h3 {
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

.preview-step {
    width: 100%;
    max-width: 600px;
    background: var(--bg-dark);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: solid 1px var(--border);
}

.preview-step-header {
    padding: 1.5rem;
    color: var(--text-main);
    border-bottom: solid 1px var(--border);
}

.preview-step-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-lighter);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.preview-step-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.preview-step-body {
    padding: 2rem;
}

.preview-question-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

.preview-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preview-option:hover {
    border-color: var(--accent);
    background: var(--bg-dark);
}

.preview-option input[type="radio"],
.preview-option input[type="checkbox"] {
    margin-right: 0.875rem;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.preview-option input[type="radio"]:checked ~ span,
.preview-option input[type="checkbox"]:checked ~ span {
    color: var(--accent);
    font-weight: 600;
}

.preview-option span {
    flex: 1;
    font-size: 1rem;
    color: var(--text-main);
}

.preview-input,
.preview-textarea {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-main);
    color: var(--text-main);
    transition: border-color 0.2s ease;
}

.preview-input:focus,
.preview-textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.preview-rating {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem 0;
}

.preview-star {
    cursor: pointer;
}

.preview-star input[type="radio"] {
    display: none;
}

.preview-star i {
    font-size: 2rem;
    color: #d1d5db;
    transition: color 0.2s ease;
}

.preview-star:hover i,
.preview-star:hover ~ .preview-star i {
    color: #fbbf24;
}

.preview-star input[type="radio"]:checked ~ i,
.preview-star input[type="radio"]:checked ~ .preview-star i {
    color: #fbbf24;
}

.preview-range {
    width: 100%;
    margin: 1rem 0;
}

.preview-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.preview-range-labels span:nth-child(2) {
    font-size: 1.25rem;
    font-weight: 600;
    color: #3b82f6;
}

.preview-data-collection {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preview-field label {
    display: block;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.preview-step-footer {
    padding: 1.5rem;
    background: var(--bg-main);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.preview-completion {
    text-align: center;
    padding: 2rem;
}

.preview-completion h2 {
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.preview-completion-summary {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.preview-completion-summary h3 {
    color: var(--text-main);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.completion-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.completion-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.completion-stats .stat strong {
    font-size: 2rem;
    color: #3b82f6;
    margin-bottom: 0.25rem;
}

.completion-stats .stat span {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.quiz-preview-debug {
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.quiz-preview-debug h4 {
    margin-bottom: 0.75rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.debug-info {
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    color: var(--text-muted);
}

.debug-info strong {
    color: var(--text-main);
}

/* ===========================================
   COMPACT STEP EDITOR CARDS
   =========================================== */

.flow-step-editor.compact {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.editor-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    gap: 0.875rem;
    transition: all 0.2s ease;
}

.editor-card.clickable {
    cursor: pointer;
}

.editor-card.clickable:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.editor-card-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1.25rem;
}

.editor-card-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.editor-card-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.editor-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.editor-badge.configured {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.editor-badge.unconfigured {
    color: var(--warning);
}

.editor-card-preview {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.editor-card-arrow {
    flex-shrink: 0;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.editor-card.clickable:hover .editor-card-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

/* Basic Info Card Inputs */
.editor-input-title {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 26px;
    background: var(--bg-tertiary);
    color: var(--text-main);
    font-size: 16px;
    font-weight: 500;
    transition: border-color 0.2s ease;
}

.editor-input-title:focus {
    outline: none;
    border-color: var(--accent);
}

.editor-select-type {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 26px;
    background: var(--bg-tertiary);
    color: var(--text-main);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.editor-select-type:focus {
    outline: none;
    border-color: var(--accent);
}

.editor-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.375rem;
    display: block;
}

.editor-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 26px;
    background: var(--bg-tertiary);
    color: var(--text-main);
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.editor-select:focus {
    outline: none;
    border-color: var(--accent);
}

.editor-btn-secondary {
    width: 100%;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.editor-btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.editor-actions {
    padding-top: 10px;
    padding-bottom: 20px;
}

.editor-btn-primary {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--bg-lighter);
    border: none;
    border-radius: 26px;
    color: var(--accent);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    border: solid 1px var(--border);
    margin-top: 20px;
}

.editor-btn-primary:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

/* ===========================================
   MODAL CONFIGURATION STYLES
   =========================================== */

.question-config-modal,
.fields-config-modal,
.audio-config-modal {
    padding: 0;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

.modal-label i {
    color: var(--accent);
}

.modal-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-tertiary);
    color: var(--text-main);
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.modal-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-hint {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.modal-hint i {
    color: #fbbf24;
}

.modal-hint code {
    padding: 0.125rem 0.375rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 16px;
    font-family: 'Courier New', monospace;
    color: var(--accent);
}

.modal-badge {
    padding: 0.25rem 0.625rem;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: auto;
}

.modal-info-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border: solid 1px var(--accent-dim);
    border-radius: 16px;
    color: var(--accent);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.modal-info-box i {
    color: var(--accent);
    font-size: 1.25rem;
}

/* Question Type Selector */
.type-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.type-card:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
}

.type-card.selected {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.type-icon {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.type-icon i {
    font-size: 2rem;
}

.type-info {
    text-align: center;
}

.type-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.type-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.type-check {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: var(--accent);
    font-size: 1rem;
}

/* Options List in Modal */
.options-list-modal,
.fields-list-modal {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.option-row,
.field-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    transition: border-color 0.2s ease;
}

.option-row:hover,
.field-row:hover {
    border-color: var(--accent);
}

.option-handle,
.field-handle {
    flex-shrink: 0;
    width: 20px;
    color: var(--text-muted);
    cursor: grab;
}

.option-handle:active,
.field-handle:active {
    cursor: grabbing;
}

.option-input,
.field-label-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 26px;
    background: var(--bg-tertiary);
    color: var(--text-main);
    font-size: 16px;
}

.option-input:focus,
.field-label-input:focus {
    outline: none;
    border-color: var(--accent);
}

.option-delete,
.field-delete {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-delete:hover,
.field-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Checkbox link config extra row */
.field-row-extra.checkbox-link-config {
    margin-left: 2rem;
    margin-top: -0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.625rem;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
}

.field-link-inputs {
    display: flex;
    gap: 0.5rem;
}

.field-link-inputs input {
    flex: 1;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-main);
    font-size: 0.875rem;
}

.field-link-inputs input:focus {
    outline: none;
    border-color: var(--accent);
}

.field-link-inputs input::placeholder {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.modal-btn-add {
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.modal-btn-add:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

/* Fields Configuration */
.field-inputs {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-type-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 0.875rem;
    cursor: pointer;
}

.field-type-select:focus {
    outline: none;
    border-color: var(--accent);
}

.field-required-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-main);
    cursor: pointer;
}

.field-required-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Audio Configuration */
.audio-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.audio-option-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.audio-option-card:hover {
    border-color: var(--accent);
}

.audio-option-card.selected {
    border-color: var(--accent);
}

.audio-option-card input[type="radio"] {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.option-icon {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-main);
    border: solid 1px var(--border);
}

.option-icon i {
    font-size: 1.5rem;
}

.option-info {
    flex: 1;
}

.option-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.option-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.audio-actions {
    display: flex;
    gap: 0.75rem;
}

.modal-btn-action {
    flex: 1;
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.modal-btn-action:hover:not(:disabled) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
    color: var(--accent);
}

.modal-btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-btn-action.danger:hover:not(:disabled) {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
    color: #ef4444;
}

/* ===========================================
   Audio Archive Picker
   =========================================== */

.audio-archive-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.audio-archive-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 10px;
}

.archive-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.archive-file-icon {
    color: #818cf8;
    font-size: 18px;
    flex-shrink: 0;
}

.archive-file-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.archive-file-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.archive-file-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.archive-file-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.modal-btn-sm {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.15s;
}

.modal-btn-sm:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.modal-btn-sm.danger:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* Archive grid */
.audio-archive-grid {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
}

.audio-archive-grid::-webkit-scrollbar {
    width: 6px;
}

.audio-archive-grid::-webkit-scrollbar-track {
    background: transparent;
}

.audio-archive-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.archive-audio-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.archive-audio-item:last-child {
    border-bottom: none;
}

.archive-audio-item:hover {
    background: var(--bg-hover);
}

.archive-audio-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.1);
    color: #818cf8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.archive-audio-info {
    flex: 1;
    min-width: 0;
}

.archive-audio-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.archive-audio-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.archive-audio-ext {
    padding: 1px 6px;
    background: rgba(99, 102, 241, 0.1);
    color: #818cf8;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.archive-audio-play {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
    transition: all 0.15s;
}

.archive-audio-play:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: #818cf8;
    color: #818cf8;
}

.archive-loading,
.archive-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

.archive-loading i {
    color: #818cf8;
}

/* Question Preview in Modal */
.question-preview-box {
    min-height: 150px;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
}

.preview-empty {
    display: flex;
    align-items: center;
    min-height: 100px;
    color: var(--text-muted);
    font-size: 0.875rem;
    flex-direction: column;
    width: -webkit-fill-available;
}

.preview-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Scrollable options container for long lists (>5 options) */
.preview-options-scroll {
    max-height: 280px;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 0.5rem;
}

.preview-options-scroll::-webkit-scrollbar {
    width: 6px;
}

.preview-options-scroll::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.preview-options-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.preview-options-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.preview-input,
.preview-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 26px;
    background: var(--bg-tertiary);
    color: var(--text-main);
    font-size: 16px;
}

.preview-star {
    color: #fbbf24;
    font-size: 1.25rem;
    margin-right: 0.25rem;
}

/* Checkbox field (privacy consent style) */
.preview-field-checkbox {
    margin: 1.5rem 0;
}

.preview-field-checkbox .checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.preview-field-checkbox .checkbox-container:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.preview-field-checkbox .checkbox-container input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    accent-color: var(--accent);
    cursor: pointer;
    margin-top: 2px;
}

.preview-field-checkbox .checkbox-checkmark {
    display: none; /* Use native checkbox for now */
}

.preview-field-checkbox .checkbox-label {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-main);
}

.preview-field-checkbox .checkbox-link {
    color: var(--accent);
    text-decoration: underline;
    font-weight: 500;
}

.preview-field-checkbox .checkbox-link:hover {
    color: var(--accent-hover, #5eead4);
}

.preview-field-checkbox .required-asterisk {
    color: var(--error, #ef4444);
    font-weight: 600;
}

/* ===========================================
   DNA-DRIVEN STEP EDITOR
   =========================================== */

.flow-step-editor.dna-driven {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
}


.dna-badge i {
    font-size: 1rem;
}

.dna-badge .dna-type {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.dna-readonly-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dna-readonly-notice i {
    color: #fbbf24;
    margin-top: 2px;
}

.dna-config-card .dna-config-details {
    margin-top: 0.5rem;
}

.dna-config-item {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.dna-config-item:last-child {
    border-bottom: none;
}

.dna-config-item .config-label {
    color: var(--text-muted);
}

.dna-config-item .config-value {
    color: var(--text-main);
    font-weight: 500;
}

.dna-config-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-top: 0.375rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.85rem;
}

.dna-config-option i {
    color: var(--accent);
    width: 20px;
    text-align: center;
}

.dna-config-option .config-next {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.dna-nav-info p {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
}

/* ===========================================
   RESPONSIVE - JSON EDITOR
   =========================================== */

@media (max-width: 768px) {
    .flow-view-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .flow-view-tab {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    .json-editor-toolbar {
        flex-wrap: wrap;
    }

    .json-editor-textarea {
        font-size: 0.75rem;
        min-height: 50vh;
    }
}

/* Voice Selector Styles */
.voice-selector-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.voice-selector-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.voice-select {
    flex: 1;
    padding: 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    color: var(--text-main);
    font-size: 16px;
}

.voice-preview-btn {
    padding: 0.625rem 1rem;
    background: var(--accent);
    color: var(--text-secondary);
    border: none;
    border-radius: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.voice-preview-btn:hover {
    background: var(--accent);
    transform: translateY(-1px);
}

.voice-preview-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.voice-preview-btn i {
    font-size: 1rem;
}

/* ===========================================
   TOGGLE SWITCH STYLES
   =========================================== */

.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color, #ccc);
    transition: background-color 0.3s ease;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--bg-dark);
    transition: transform 0.3s ease;
    border-radius: 50%;
    box-shadow: var(--shadow-sm)
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: var(--shadow-sm)
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-label {
    font-size: 0.9375rem;
    color: var(--text-main);
    user-select: none;
}

