/* ─── Text Repeater — Premium Stylesheet ─────────────────────────────────────
   Scoped entirely to #fu-text-repeater.
   Uses standard design system variables (--fu-*).
   ─────────────────────────────────────────────────────────────────────────── */

#fu-text-repeater {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

/* Stacked Layout Card Structure */
#fu-text-repeater .fu-tr-input-panel,
#fu-text-repeater .fu-tr-output-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

/* Base Textarea styling matching Sort/Deduplicate lines */
#fu-text-repeater .fu-textarea {
    background: var(--fu-input-bg);
    border: 1px solid var(--fu-border);
    border-radius: var(--fu-radius);
    padding: 0.875rem;
    font-family: var(--fu-font-family);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--fu-text);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: border-color var(--fu-transition), box-shadow var(--fu-transition);
    box-sizing: border-box;
    resize: none; /* Disallow resizing */
}

/* Compact Source Input Textarea styling */
#fu-text-repeater .fu-tr-input-textarea {
    min-height: 52px !important;
    height: 52px !important;
    padding: 0.5rem 0.75rem;
    line-height: 1.4;
    overflow-y: auto;
}

/* Standard Output Textarea styling */
#fu-text-repeater .fu-tr-output-textarea {
    min-height: 200px !important;
    height: 200px !important;
}

#fu-text-repeater .fu-textarea:focus {
    outline: none;
    border-color: var(--fu-accent);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04), 0 0 0 3px var(--fu-accent-light);
}

/* Select element overrides (Fixed width, styled dropdown) */
#fu-text-repeater .fu-select {
    background: var(--fu-input-bg);
    border: 1px solid var(--fu-border);
    border-radius: var(--fu-radius);
    padding: 0.45rem 2rem 0.45rem 0.75rem;
    font-family: var(--fu-font-family);
    font-size: 0.9rem;
    color: var(--fu-text);
    transition: border-color var(--fu-transition), box-shadow var(--fu-transition);
    box-sizing: border-box;
    width: 100%;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    appearance: none;
}

#fu-text-repeater .fu-select:focus {
    outline: none;
    border-color: var(--fu-accent);
    box-shadow: 0 0 0 3px var(--fu-accent-light);
}

/* Input Field overrides */
#fu-text-repeater .fu-input {
    background: var(--fu-input-bg);
    border: 1px solid var(--fu-border);
    border-radius: var(--fu-radius);
    padding: 0.45rem 0.75rem;
    font-family: var(--fu-font-family);
    font-size: 0.9rem;
    color: var(--fu-text);
    transition: border-color var(--fu-transition), box-shadow var(--fu-transition);
    box-sizing: border-box;
    width: 100%;
}

#fu-text-repeater .fu-input:focus {
    outline: none;
    border-color: var(--fu-accent);
    box-shadow: 0 0 0 3px var(--fu-accent-light);
}

/* Controls Grid Area in Stacked Panel (Flex row on desktop with fixed, compact columns) */
#fu-text-repeater .fu-tr-controls-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 1.5rem;
    align-items: flex-end;
    justify-content: flex-start;
    border-top: 1px dashed var(--fu-border);
    margin-top: 0.25rem;
    padding-top: 1rem;
    width: 100%;
}

#fu-text-repeater .fu-tr-setting-col {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

/* Lock columns to compact, fixed sizes to guarantee settings never wrap on desktop */
#fu-text-repeater .fu-tr-count-col {
    width: 100px;
    flex-shrink: 0;
}

#fu-text-repeater .fu-tr-separator-col {
    width: 140px;
    flex-shrink: 0;
}

#fu-text-repeater .fu-tr-toggles-col {
    width: 290px;
    flex-shrink: 0;
}

/* Toggles arranging checkboxes horizontally */
#fu-text-repeater .fu-tr-toggles {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.5rem;
    width: 100%;
}

#fu-text-repeater .fu-toggle-label {
    display: inline-flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    user-select: none;
}

#fu-text-repeater .fu-toggle-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

#fu-text-repeater .fu-toggle-pills-text {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.875rem; /* Matches input's vertical padding */
    border-radius: var(--fu-radius); /* Matches corners radius of text/select fields */
    border: 1px solid var(--fu-border);
    background: transparent;
    font-family: var(--fu-font-family);
    font-size: 0.9rem; /* Matches input font size exactly */
    font-weight: 500;
    color: var(--fu-text-muted);
    transition: border-color var(--fu-transition), color var(--fu-transition),
                background var(--fu-transition);
    line-height: 1.4; /* Matches input line-height */
    white-space: nowrap;
    box-sizing: border-box;
}

#fu-text-repeater .fu-toggle-label:hover .fu-toggle-pills-text {
    border-color: var(--fu-accent);
    color: var(--fu-accent);
    background: var(--fu-accent-light);
}

#fu-text-repeater .fu-toggle-checkbox:checked + .fu-toggle-pills-text {
    background: var(--fu-accent);
    border-color: var(--fu-accent);
    color: var(--fu-btn-primary-text);
    font-weight: 600;
}

#fu-text-repeater .fu-toggle-checkbox:focus-visible + .fu-toggle-pills-text {
    outline: 2px solid var(--fu-accent);
    outline-offset: 2px;
}

/* Centered Stats Bar below both cards */
#fu-text-repeater .fu-tr-stats-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--fu-text-muted);
    line-height: 1;
}

/* Disabled Copy Button styling override */
#fu-text-repeater .fu-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

/* Animation */
@keyframes fuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Grid stacking rules */
@media (max-width: 768px) {
    #fu-text-repeater .fu-tr-controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 1.15rem;
    }
    #fu-text-repeater .fu-tr-count-col,
    #fu-text-repeater .fu-tr-separator-col,
    #fu-text-repeater .fu-tr-toggles-col {
        width: 100%;
    }
    #fu-text-repeater .fu-tr-toggles {
        flex-wrap: wrap;
    }
}
