/* Flow Builder - WooCommerce Style */

.wp-flow-builder-v1 {
    max-width: 1200px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Container principal */
.wp-flow-builder-container {
    background: #f8f9fa;
    padding: 0;
}

/* Header */
.wp-flow-builder-header {
    background: #fff;
    padding: 20px;
    border: 1px solid #c3c4c7;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 4px 4px 0 0;
}

.wp-flow-builder-title-row {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 20px;
}

.flow-name-input {
    font-size: 1.2em !important;
    font-weight: 600;
    width: 300px;
    border: 1px solid transparent !important;
    background: transparent !important;
    box-shadow: none !important;
}

.flow-name-input:hover,
.flow-name-input:focus {
    border: 1px solid #8c8f94 !important;
    background: #fff !important;
}

/* Status Switch */
.flow-status-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #50575e;
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #2271b1;
}

input:checked+.slider:before {
    transform: translateX(16px);
}

/* Main Content */
.wp-flow-builder-content {
    border: 1px solid #c3c4c7;
    background: #f6f7f7;
    border-top: 1px solid #dcdcde;
}

.builder-section {
    background: #fff;
    padding: 20px 30px;
    border-bottom: 1px solid #f0f0f1;
    position: relative;
}

.builder-section.trigger-section {
    border-left: 4px solid #2271b1;
}

.builder-section.conditions-section {
    border-left: 4px solid #f0b849;
    background: #fafafa;
}

.builder-section.actions-section {
    border-left: 4px solid #4ab866;
    border-bottom: none;
    border-radius: 0 0 4px 4px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.section-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: #fff;
    font-weight: bold;
    font-size: 11px;
}

.trigger-badge {
    background: #2271b1;
}

.condition-badge {
    background: #f0b849;
}

.action-badge {
    background: #4ab866;
}

/* Cards & Items */
.card {
    background: #fff;
    border: 1px solid #dcdcde;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}

.item-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.condition-config-fields,
.action-config-fields {
    display: flex;
    gap: 10px;
    flex-grow: 1;
    flex-wrap: wrap;
    align-items: center;
}

.action-config-fields {
    display: block;
    /* Actions take full width usually */
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #eee;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Form Elements */
select,
input[type="text"],
input[type="email"],
input[type="url"],
textarea {
    min-width: 200px;
    border-color: #8c8f94;
    border-radius: 4px;
    height: 32px;
    /* Standard WP input height */
    line-height: normal;
}

.action-field-row {
    margin-bottom: 15px;
}

.action-field-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 13px;
    color: #23282d;
}

/* Campos obligatorios */
.action-field-row label.required::after,
.field-required::after {
    content: " *";
    color: #dc3232;
    font-weight: bold;
}

.field-description {
    font-size: 12px;
    color: #646970;
    margin-top: 4px;
    font-style: italic;
}

.action-field-row .full-width {
    width: 100%;
    max-width: 100%;
}

.action-field-row textarea {
    height: auto;
    min-height: 80px;
}

.config-container {
    margin-top: 15px;
    padding: 15px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    display: none;
}

.config-container.active {
    display: block;
}

.remove-item {
    background: none;
    border: none;
    color: #d63638;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.6;
    padding: 5px;
    transition: opacity 0.2s;
}

.remove-item:hover {
    opacity: 1;
}

.section-footer {
    margin-top: 20px;
}

/* Preview Box */
.wp-flow-builder-preview {
    margin-top: 20px;
    background: #fff;
    border: 1px solid #c3c4c7;
    padding: 20px;
    border-radius: 4px;
}

.wp-flow-builder-preview h4 {
    margin: 0 0 15px;
    font-size: 12px;
    color: #646970;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-box {
    font-family: Consolas, Monaco, monospace;
    color: #2c3338;
    white-space: pre-wrap;
    line-height: 1.6;
    background: #f6f7f7;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #dcdcde;
    font-size: 13px;
}

/* Variable Selector */
.variable-selector-wrapper {
    position: relative;
    display: inline-block;
}

.variable-selector-wrapper .button-small {
    height: 28px;
    line-height: 1;
    padding: 4px 8px;
    vertical-align: middle;
}

.variable-selector-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 280px;
    max-height: 350px;
    overflow-y: auto;
}

.variable-selector-dropdown > div:first-child {
    padding: 10px 12px;
    border-bottom: 1px solid #ddd;
    background: #f6f7f7;
    font-weight: 600;
    font-size: 12px;
    color: #1d2327;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.variable-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.variable-item:hover {
    background: #f6f7f7;
}

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

.variable-item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: #1d2327;
}

.variable-item code {
    font-size: 11px;
    color: #2271b1;
    background: #f0f6fb;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: Consolas, Monaco, monospace;
}

/* Estilo WooCommerce moderno */
.card {
    transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
    border-color: #8c8f94;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.button-primary {
    background: #7f54b3 !important;
    border-color: #7f54b3 !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

.button-primary:hover {
    background: #96588a !important;
    border-color: #96588a !important;
}

/* Variable badge tipo */
.variable-type-badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 6px;
}

.variable-type-badge.type-email {
    background: #e3f2fd;
    color: #1976d2;
}

.variable-type-badge.type-string {
    background: #f3e5f5;
    color: #7b1fa2;
}

.variable-type-badge.type-number {
    background: #e8f5e9;
    color: #388e3c;
}

/* Input focus mejorado */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
    border-color: #7f54b3;
    box-shadow: 0 0 0 1px #7f54b3;
    outline: none;
}

/* Alert boxes */
.wpfa-notice {
    padding: 12px 16px;
    margin-bottom: 15px;
    border-left: 4px solid #00a0d2;
    background: #e5f5fa;
    border-radius: 0 4px 4px 0;
}

.wpfa-notice.notice-warning {
    border-left-color: #ffb900;
    background: #fff8e5;
}

.wpfa-notice.notice-error {
    border-left-color: #dc3232;
    background: #fef1f1;
}

/* Tooltips */
.wpfa-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    margin-left: 4px;
    color: #646970;
}

.wpfa-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: #23282d;
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 4px;
    z-index: 1000;
    margin-bottom: 5px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
}

.empty-state .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

/* Drag & Drop */
.action-item,
.condition-item {
    transition: opacity 0.2s, transform 0.2s;
}

.action-item.dragging,
.condition-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.action-item.drag-over,
.condition-item.drag-over {
    border-top: 3px solid #7f54b3;
    margin-top: 3px;
}

/* Solo el handle es draggable */
.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    cursor: grab;
    color: #8c8f94;
    margin-right: 8px;
    transition: color 0.2s, transform 0.2s;
    user-select: none; /* Prevenir selección de texto en el handle */
}

.drag-handle:hover {
    color: #7f54b3;
    transform: scale(1.1);
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    pointer-events: none; /* El icono no interfiere con el drag */
}

/* Preview Modal */
.wpfa-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: 100000;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.wpfa-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

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

.wpfa-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #dcdcde;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f6f7f7;
}

.wpfa-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #23282d;
}

.wpfa-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #646970;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.wpfa-modal-close:hover {
    background: #e0e0e0;
    color: #23282d;
}

.wpfa-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.wpfa-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #dcdcde;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f6f7f7;
}

/* Email Preview */
.email-preview-container {
    border: 1px solid #dcdcde;
    border-radius: 4px;
    background: #fff;
}

.email-preview-header {
    padding: 16px;
    background: #f6f7f7;
    border-bottom: 1px solid #dcdcde;
}

.email-preview-field {
    margin-bottom: 12px;
    font-size: 13px;
}

.email-preview-field strong {
    display: inline-block;
    width: 80px;
    color: #646970;
}

.email-preview-body {
    padding: 24px;
    min-height: 200px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
}

.email-preview-body.html-preview {
    background: #fafafa;
}

/* Autocomplete */
.variable-autocomplete {
    position: absolute;
    background: #fff;
    border: 1px solid #7f54b3;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10000;
    min-width: 250px;
}

.variable-autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.variable-autocomplete-item:hover,
.variable-autocomplete-item.selected {
    background: #f0f6fb;
}

.variable-autocomplete-item:last-child {
    border-bottom: none;
}

.variable-autocomplete-label {
    font-weight: 500;
    color: #23282d;
    font-size: 13px;
}

.variable-autocomplete-code {
    font-family: Consolas, Monaco, monospace;
    font-size: 11px;
    color: #7f54b3;
    background: #f6f7f7;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Onboarding */
.wpfa-onboarding {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 40px;
    text-align: center;
    border-radius: 8px;
    margin-bottom: 20px;
}

.wpfa-onboarding h2 {
    color: #fff;
    font-size: 28px;
    margin-bottom: 16px;
}

.wpfa-onboarding p {
    font-size: 16px;
    opacity: 0.9;
    margin-bottom: 24px;
}

.wpfa-onboarding-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.wpfa-onboarding .button {
    background: #fff !important;
    color: #667eea !important;
    border: none !important;
    padding: 12px 24px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.wpfa-onboarding .button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2) !important;
}

.wpfa-onboarding .button-secondary {
    background: transparent !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}

/* Test Mode Banner */
.test-mode-banner {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    padding: 16px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.test-mode-banner strong {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.test-mode-banner .dashicons {
    font-size: 20px;
}

/* Loading animation */
@keyframes rotation {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
/* Dashboard Extra Styles */
.status-tag { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.vortiflow-empty-state { padding: 40px 20px; text-align: center; background: #fff; border: 1px solid #ccd0d4; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
.vortiflow-empty-state dashicons { font-size: 50px; width: 50px; height: 50px; color: #ccd0d4; margin-bottom: 10px; }
.vortiflow-card { background: #fff; border: 1px solid #ccd0d4; box-shadow: 0 1px 1px rgba(0,0,0,.04); padding: 20px; border-radius: 4px; }
